Saras
Finite   Difference   Solver   for   Fluid   Dynamics   Simulations
boundary.h
Go to the documentation of this file.
1/********************************************************************************************************************************************
2 * Saras
3 *
4 * Copyright (C) 2019, Mahendra K. Verma
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the copyright holder nor the
16 * names of its contributors may be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 ********************************************************************************************************************************************
31 */
43#ifndef BOUNDARY_H
44#define BOUNDARY_H
45
46#include <blitz/array.h>
47
48#include "field.h"
49#include "grid.h"
50
51class boundary {
52 public:
53 boundary(const grid &mesh, field &inField, const int bcWall);
54
55 virtual void imposeBC();
56
57 protected:
59 const grid &mesh;
60
63
66
68 const int wallNum;
69
72
75};
76
113class dirichletCC: public boundary {
114 public:
115 dirichletCC(const grid &mesh, field &inField, const int bcWall, const real bcValue);
116
117 inline void imposeBC();
118 private:
119 const real fieldValue;
120};
121
130class dirichletFC: public boundary {
131 public:
132 dirichletFC(const grid &mesh, field &inField, const int bcWall, const real bcValue);
133
134 inline void imposeBC();
135 private:
136 const real fieldValue;
137};
138
147class periodicCC: public boundary {
148 public:
149 periodicCC(const grid &mesh, field &inField, const int bcWall);
150
151 inline void imposeBC();
152};
153
162class periodicFC: public boundary {
163 public:
164 periodicFC(const grid &mesh, field &inField, const int bcWall);
165
166 inline void imposeBC();
167};
168
177class neumannCC: public boundary {
178 public:
179 neumannCC(const grid &mesh, field &inField, const int bcWall, const real bcValue);
180
181 inline void imposeBC();
182 private:
183 const real fieldValue;
184};
185
194class neumannFC: public boundary {
195 public:
196 neumannFC(const grid &mesh, field &inField, const int bcWall, const real bcValue);
197
198 inline void imposeBC();
199 private:
200 const real fieldValue;
201};
202
211class hotPlateCC: public boundary {
212 public:
213 hotPlateCC(const grid &mesh, field &inField, const int bcWall, const real plateRad);
214
215 void imposeBC();
216 private:
217 blitz::Array<bool, 3> wallMask;
218 blitz::Array<real, 3> wallData;
219
220 blitz::Array<real, 1> x, y, z;
221 blitz::Array<real, 1> xGlo, yGlo, zGlo;
222
223 const real patchRadius;
224
225 void setXYZ();
226
227 void createPatch(real patchRadius);
228};
229
238class nullBC: public boundary {
239 public:
240 nullBC(const grid &mesh, field &inField, const int bcWall): boundary(mesh, inField, bcWall) { };
241
242 inline void imposeBC() { };
243};
244
253#endif
Contains all the global variables related to the imposing of boundary conditions, and functions to im...
Definition: boundary.h:51
const grid & mesh
A const reference to the global variables stored in the grid class to access mesh data.
Definition: boundary.h:59
bool rankFlag
The flag is true for MPI ranks on which the boundary condition has to be applied.
Definition: boundary.h:65
int shiftVal
The number of points by which the view of the wall slice is shifted to when applying the boundary con...
Definition: boundary.h:74
field & dField
Reference to the field onto which the boundary condition has to be applied.
Definition: boundary.h:62
int shiftDim
Denotes the dimension normal to the wall at which the boundary condition is applied.
Definition: boundary.h:71
virtual void imposeBC()
Prototype function to impose the boundary conditions on the given field.
Definition: boundary.cc:101
const int wallNum
The const integer denotes the wall at which the boundary condition is being applied.
Definition: boundary.h:68
boundary(const grid &mesh, field &inField, const int bcWall)
Constructor of the boundary class.
Definition: boundary.cc:57
The derived class from boundary to apply dirichlet boundary condition for a cell-centered variable.
Definition: boundary.h:113
dirichletCC(const grid &mesh, field &inField, const int bcWall, const real bcValue)
Constructor of the dirichletCC class.
Definition: dirichletCC.cc:58
void imposeBC()
Function to impose Dirichlet BC on a cell centered variable.
Definition: dirichletCC.cc:71
The derived class from boundary to apply dirichlet boundary condition for a face-centered variable.
Definition: boundary.h:130
dirichletFC(const grid &mesh, field &inField, const int bcWall, const real bcValue)
Constructor of the boundary class.
Definition: dirichletFC.cc:58
void imposeBC()
Function to impose Dirichlet BC on a face centered variable.
Definition: dirichletFC.cc:71
Field class to store data and perform finite difference operations on the data.
Definition: field.h:52
Contains all the global variables related to the grid, its slices, limits, and grid derivatives used ...
Definition: grid.h:53
The derived class from boundary to apply mixed boundary condition involving a heated plate for a cell...
Definition: boundary.h:211
hotPlateCC(const grid &mesh, field &inField, const int bcWall, const real plateRad)
Constructor of the hotPlateCC class.
Definition: hotPlateCC.cc:58
void imposeBC()
Function to impose Mixed BC of a heating plate on a cell centered variable.
Definition: hotPlateCC.cc:128
The derived class from boundary to apply neumann boundary condition for a cell-centered variable.
Definition: boundary.h:177
void imposeBC()
Function to impose Neumann BC on a cell centered variable.
Definition: neumannCC.cc:71
neumannCC(const grid &mesh, field &inField, const int bcWall, const real bcValue)
Constructor of the neumannCC class.
Definition: neumannCC.cc:58
The derived class from boundary to apply neumann boundary condition for a face-centered variable.
Definition: boundary.h:194
neumannFC(const grid &mesh, field &inField, const int bcWall, const real bcValue)
Constructor of the neumannFC class.
Definition: neumannFC.cc:58
void imposeBC()
Function to impose Neumann BC on a face centered variable.
Definition: neumannFC.cc:71
The derived class from boundary to impose null boundary condition that leaves the data unchanged.
Definition: boundary.h:238
void imposeBC()
Prototype function to impose the boundary conditions on the given field.
Definition: boundary.h:242
The derived class from boundary to apply periodic boundary condition for a cell-centered variable.
Definition: boundary.h:147
periodicCC(const grid &mesh, field &inField, const int bcWall)
Constructor of the periodicCC class.
Definition: periodicCC.cc:57
void imposeBC()
Function to impose periodic BC on a cell centered variable.
Definition: periodicCC.cc:72
The derived class from boundary to apply periodic boundary condition for a face-centered variable.
Definition: boundary.h:162
periodicFC(const grid &mesh, field &inField, const int bcWall)
Constructor of the periodicFC class.
Definition: periodicFC.cc:57
void imposeBC()
Function to impose periodic BC on a face centered variable.
Definition: periodicFC.cc:72
Class declaration of field.
Class declaration of grid.