Chombo + EB  3.2
NodeBC.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 // NodeBC.H
12 // adapted from GhostBC by DTGraves, Mon, July 19, 1999
13 // petermc, 13 Feb 2001
14 // petermc, 21 Oct 2002, removed m_inhomogeneous, which can be in
15 // derived class of FaceNodeBC.
16 
17 #ifndef _NODEBC_H_
18 #define _NODEBC_H_
19 
20 #include "ProblemDomain.H"
21 #include "NodeFArrayBox.H"
22 #include "REAL.H"
23 #include "SPACE.H"
24 #include "Tuple.H"
25 #include "Interval.H"
26 #include "Vector.H"
27 #include "LoHiSide.H"
28 #include "NamespaceHeader.H"
29 
30 /// A class to encapsulate the operations of boundary conditions on a face
31 /** FaceNodeBC is a class to encapsulate the
32  operations of boundary conditions at a face.
33 
34  If the solution is phi and the face normal direction is x,
35  the boundary conditions usually used can be expressed as<br>
36  A*dphi/dx + B*phi = C.<br>
37  The derived class provides a function to fill A and B and C.
38 
39  These functions are meant to be called by DomainNodeBC only.
40 */
42 {
43 public:
44  friend class DomainNodeBC;
45 
46  /**
47  \name Constructors, destructor and defines
48  */
49  /*@{*/
50 
51  ///
52  /** Default constructor, sets interval to (-1:-1).
53  */
55  :m_components(-1,-1)
56  {
57  }
58 
59  ///
60  /** Constructor for face on side <i>a_sd</i> in direction <i>a_idir</i>.
61  This constructor sets the components interval to be (0:0).
62  */
63  FaceNodeBC(int a_dir, Side::LoHiSide a_sd);
64 
65  ///
66  /** Constructor for face on side <i>a_sd</i> in direction <i>a_idir</i>,
67  for data components <i>a_comps</i>.
68  */
69  FaceNodeBC(int a_dir, Side::LoHiSide a_sd, const Interval& a_comps);
70 
71  ///
72  /** Destructor.
73  */
74  virtual ~FaceNodeBC()
75  {
76  }
77 
78 protected:
79 
80  ///
81  /** Virtual constructor workaround.
82  Need this in derived class.
83  */
84  virtual FaceNodeBC* new_boxBC() const = 0;
85 
86  ///
87  /** Defines face on side <i>a_sd</i> in direction <i>a_idir</i>.
88  Sets the components interval to be (0:0).
89  */
90  void
91  define(int a_dir, Side::LoHiSide a_sd);
92 
93  ///
94  /** Defines face on side <i>a_sd</i> in direction <i>a_idir</i>,
95  for data components <i>a_comps</i>.
96  */
97  void
98  define(int a_dir, Side::LoHiSide a_sd, const Interval& a_comps);
99 
100  /*@}*/
101 
102  /**
103  \name Functions to apply boundary conditions
104  */
105  /*@{*/
106 
107  ///
108  /** Apply inhomogeneous boundary conditions on this face.
109  */
110  virtual void
111  applyInhomogeneousBCs(/// NODE-centered data to be modified by boundary condition
112  FArrayBox& a_state,
113  /// CELL-centered physical domain
114  const ProblemDomain& a_domain,
115  /// mesh spacing
116  Real a_dx) const;
117 
118  ///
119  /** Apply inhomogeneous boundary conditions on this face.
120  */
121  virtual void
122  applyInhomogeneousBCs(/// NODE-centered data to be modified by boundary condition
123  FArrayBox& a_state,
124  /// CELL-centered physical domain
125  const Box& a_domain,
126  /// mesh spacing
127  Real a_dx) const;
128 
129  ///
130  /** Apply homogeneous boundary conditions on this face.
131  */
132  virtual void
133  applyHomogeneousBCs(/// NODE-centered data to be modified by boundary condition
134  FArrayBox& a_state,
135  /// CELL-centered physical domain
136  const ProblemDomain& domain,
137  /// mesh spacing
138  Real a_dx) const;
139  ///
140  /** Apply homogeneous boundary conditions on this face.
141  */
142  virtual void
143  applyHomogeneousBCs(/// NODE-centered data to be modified by boundary condition
144  FArrayBox& a_state,
145  /// CELL-centered physical domain
146  const Box& domain,
147  /// mesh spacing
148  Real a_dx) const;
149  ///
150  /** Apply boundary conditions on this face.
151  */
152  virtual void
153  applyEitherBCs(/// NODE-centered data to be modified by boundary condition
154  FArrayBox& a_state,
155  /// CELL-centered physical domain
156  const ProblemDomain& domain,
157  /// mesh spacing
158  Real a_dx,
159  /// flag for homogeneous boundary condition
160  bool a_homogeneous) const;
161 
162  ///
163  /** Apply boundary conditions on this face.
164  */
165  virtual void
166  applyEitherBCs(/// NODE-centered data to be modified by boundary condition
167  FArrayBox& a_state,
168  /// CELL-centered physical domain
169  const Box& domain,
170  /// mesh spacing
171  Real a_dx,
172  /// flag for homogeneous boundary condition
173  bool a_homogeneous) const;
174 
175  ///
176  /** Apply boundary condition A*dphi/dx + B*phi = C, with
177  the coefficients having been set in fillBCValues().
178  */
179  virtual void
180  applyBCs(/// NODEs on this boundary face
181  const Box& a_bcbox,
182  /// NODE-centered data to be modified by boundary condition
183  FArrayBox& a_state,
184  /// coefficients of dphi/dx
185  const FArrayBox& a_neumfac,
186  /// coefficients of phi
187  const FArrayBox& a_dircfac,
188  /// constant coefficients
189  const FArrayBox& a_inhmval,
190  /// mesh spacing
191  Real a_dx) const;
192 
193  /*@}*/
194 
195  /**
196  \name Functions to fill in boundary-condition coefficients
197  */
198  /*@{*/
199 
200  ///
201  /** Set A and B and C in the boundary condition
202  A*dphi/dx + B*phi = C.<br>
203  The FArrayBoxes are all based on the NODEs of this face.
204 
205  Need this function in derived class.
206  */
207  virtual void
208  fillBCValues(/// coefficients of dphi/dx
209  FArrayBox& a_neumfac,
210  /// coefficients of phi
211  FArrayBox& a_dircfac,
212  /// constant coefficients
213  FArrayBox& a_inhmval,
214  /// mesh spacing
215  Real a_dx,
216  /// CELL-centered physical domain
217  const ProblemDomain& domain) const = 0;
218 
219  ///
220  /** Set A and B and C in the boundary condition
221  A*dphi/dx + B*phi = C.<br>
222  The FArrayBoxes are all based on the NODEs of this face.
223 
224  Need this function in derived class.
225  */
226  virtual void
227  fillBCValues(/// coefficients of dphi/dx
228  FArrayBox& a_neumfac,
229  /// coefficients of phi
230  FArrayBox& a_dircfac,
231  /// constant coefficients
232  FArrayBox& a_inhmval,
233  /// mesh spacing
234  Real a_dx,
235  /// CELL-centered physical domain
236  const Box& domain) const = 0;
237 
238  /*@}*/
239 
240  /** low or high face
241  */
243 
244  /** dimension of face
245  */
247 
248  /** components of data
249  */
251 
252 private:
254  :m_components(-1,-1)
255  {
256  }
257 
258  virtual void operator=(const FaceNodeBC&)
259  {
260  }
261 };
262 
263 
264 /// Class to enforce boundary conditions
265 /** This class holds a domain's worth of FaceNodeBCs,
266  one for each face of the physical domain.
267  The user adds a FaceNodeBC-derived class
268  for each face to enforce boundary conditions.
269 
270  If the solution is phi and the face normal direction is x,
271  the boundary conditions at a face are expressed as<br>
272  A*dphi/dx + B*phi = C.
273 
274  The class derived from FaceNodeBC provides a function to
275  to fill A and B and C. DomainNodeBC calls this function
276  and fills the boundary nodes appropriately.
277 */
279 {
280 public:
281 
282  /**
283  \name Constructors, destructor and defines
284  */
285  /*@{*/
286 
287  ///
288  /** Empty constructor. Need to assign boundary conditions for each face
289  with calls to setFaceNodeBC().
290  */
291  DomainNodeBC();
292 
293  ///
294  /** Destructor.
295  */
296  ~DomainNodeBC();
297 
298  ///
299  /** Assignment, copies input.
300  */
302 
303  ///
304  /** Copy constructor.
305  */
306  DomainNodeBC(const DomainNodeBC&);
307 
308  /*@}*/
309 
310  /**
311  \name Access functions
312  */
313  /*@{*/
314 
315  ///
316  /**
317  Retrieve FaceNodeBC for a particular face.
318  */
319  const FaceNodeBC&
320  operator() (int direction, Side::LoHiSide side) const;
321 
322  /*@}*/
323 
324  /**
325  \name Setting functions
326  */
327  /*@{*/
328 
329  ///
330  /** Set boundary condition object at a face.
331  */
332  void
333  setFaceNodeBC(const FaceNodeBC& a_bc);
334 
335  /*@}*/
336 
337  /**
338  \name Functions to apply boundary conditions
339  */
340  /*@{*/
341 
342  ///
343  /** Apply homogeneous boundary conditions on all faces of physical domain.
344  */
345  void
346  applyHomogeneousBCs(/// array on which boundary conditions will be applied
347  NodeFArrayBox& a_state,
348  /// CELL-centered physical domain
349  const ProblemDomain& a_domain,
350  /// mesh spacing
351  Real a_dx) const;
352 
353  ///
354  /** Apply homogeneous boundary conditions on all faces of physical domain.
355  */
356  void
357  applyHomogeneousBCs(/// array on which boundary conditions will be applied
358  NodeFArrayBox& a_state,
359  /// CELL-centered physical domain
360  const Box& a_domain,
361  /// mesh spacing
362  Real a_dx) const;
363 
364  ///
365  /** Apply inhomogeneous boundary conditions on all faces of physical domain.
366  */
367  void
368  applyInhomogeneousBCs(/// array on which boundary conditions will be applied
369  NodeFArrayBox& a_state,
370  /// CELL-centered physical domain
371  const ProblemDomain& a_domain,
372  /// mesh spacing
373  Real a_dx) const;
374 
375  ///
376  /** Apply inhomogeneous boundary conditions on all faces of physical domain.
377  */
378  void
379  applyInhomogeneousBCs(/// array on which boundary conditions will be applied
380  NodeFArrayBox& a_state,
381  /// CELL-centered physical domain
382  const Box& a_domain,
383  /// mesh spacing
384  Real a_dx) const;
385 
386  /*@}*/
387 
388 protected:
389 
390  /** Return <tt>true</tt> if the FaceNodeBC for the specified face
391  is defined.
392  */
393  bool isBCDefined(int a_dir, const Side::LoHiSide a_side) const;
394 
395  /** Reset the FaceNodeBC for the specified face to NULL.
396  */
397  void resetFaceNodeBC(const int a_dir, const Side::LoHiSide a_side);
398 
401 
402 private:
403 };
404 
405 #include "NamespaceFooter.H"
406 
407 #endif
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
virtual void applyHomogeneousBCs(FArrayBox &a_state, const ProblemDomain &domain, Real a_dx) const
Tuple< FaceNodeBC *, SpaceDim > m_hiBC
Definition: NodeBC.H:400
virtual void fillBCValues(FArrayBox &a_neumfac, FArrayBox &a_dircfac, FArrayBox &a_inhmval, Real a_dx, const ProblemDomain &domain) const =0
virtual FaceNodeBC * new_boxBC() const =0
virtual void operator=(const FaceNodeBC &)
Definition: NodeBC.H:258
Side::LoHiSide m_side
Definition: NodeBC.H:242
friend class DomainNodeBC
Definition: NodeBC.H:44
virtual void applyBCs(const Box &a_bcbox, FArrayBox &a_state, const FArrayBox &a_neumfac, const FArrayBox &a_dircfac, const FArrayBox &a_inhmval, Real a_dx) const
void define(int a_dir, Side::LoHiSide a_sd)
Structure for passing component ranges in code.
Definition: Interval.H:23
virtual void applyEitherBCs(FArrayBox &a_state, const ProblemDomain &domain, Real a_dx, bool a_homogeneous) const
double Real
Definition: REAL.H:33
LoHiSide
Definition: LoHiSide.H:27
Class to enforce boundary conditions.
Definition: NodeBC.H:278
virtual void applyInhomogeneousBCs(FArrayBox &a_state, const ProblemDomain &a_domain, Real a_dx) const
FaceNodeBC()
Definition: NodeBC.H:54
Tuple< FaceNodeBC *, SpaceDim > m_loBC
Definition: NodeBC.H:399
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
int m_direction
Definition: NodeBC.H:246
virtual ~FaceNodeBC()
Definition: NodeBC.H:74
Definition: FArrayBox.H:45
Interval m_components
Definition: NodeBC.H:250
A class to encapsulate the operations of boundary conditions on a face.
Definition: NodeBC.H:41
FaceNodeBC(const FaceNodeBC &)
Definition: NodeBC.H:253
A wrapper for an FArrayBox to contain NODE-centered data.
Definition: NodeFArrayBox.H:122