Chombo + EB  3.2
EBISBox.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 // ANAG, LBNL
12 
13 #ifndef _EBISBOX_H_
14 #define _EBISBOX_H_
15 
16 #include "REAL.H"
17 #include "IntVect.H"
18 #include "IntVectSet.H"
19 #include "VolIndex.H"
20 #include "Interval.H"
21 #include "FaceIndex.H"
22 #include "Tuple.H"
23 #include "IntVectSet.H"
24 #include "RealVect.H"
25 #include "BaseFab.H"
26 #include "RefCountedPtr.H"
27 #include "SPMD.H"
28 #include "EBGraph.H"
29 #include "EBData.H"
30 #include "NamespaceHeader.H"
31 
32 /// Geometric description within a box
33 ///
34 /**
35  EBISBox represents the geometric information
36  of the domain at a given refinement
37  within the boundaries of a particular box.
38  It is implemented as a reference-counted
39  pointer to an EBISBox object. This means
40  that assignment and copying are computationally
41  inexpensive but it also means that these functions
42  have the reference-counted pointer semantic. If
43  one copies an EBISBox and changes the copy,
44  the original one changes too.
45 */
46 class EBISBox
47 {
48 public:
49 
50  ///
51  /**
52  Makes an EBISBox whose contents are undefined.
53  */
54  EBISBox();
55 
56  ///
57  ~EBISBox();
58 
59  ///
60  /**
61  Returns all the multi-valued cells
62  within the input Box a_subbox.
63  */
64  IntVectSet getMultiCells(const Box& a_subbox) const;
65 
66  ///
67  /**
68  Returns the irregular cells of the EBISBox that are
69  within the input subbox.
70  */
71  IntVectSet getIrregIVS(const Box& a_subbox) const;
72 
73  ///
74  /**
75  Returns the irregular cells that have non-zero boundary area
76  */
77  IntVectSet boundaryIVS(const Box& a_subbox) const;
78 
79  ///
80  /**
81  Returns the number of VoFs in the cell
82  */
83  int numVoFs(const IntVect& a_iv) const;
84 
85  ///
86  /**
87  Return the VoFs in the cell.
88  */
89  Vector<VolIndex> getVoFs(const IntVect& a_iv) const;
90 
91  ///
92  /**
93  Return the VoFs in the direction and distance given.
94  Chases the connectivity the number of steps given.
95  a_steps = 0 just returns the vof input.
96  a_steps < 0 is an error. Stops at the domain
97  boundary without error. Will be an error if the
98  number of steps steps out of the EBISBox region
99  without stepping out of the domain. If this happens,
100  you probably need to define your EBISLayout with
101  more ghost cells.
102  */
103  Vector<VolIndex> getVoFs(const VolIndex& a_vof,
104  const int& a_dir,
105  const Side::LoHiSide& a_sd,
106  const int& a_steps) const;
107 
108  ///
109  /**
110  Return true if every cell in the EBISBox is a regular cell.
111  */
112  bool isAllRegular() const;
113 
114  ///
115  /**
116  Return true if every cell in the EBISBox is a covered cell.
117  */
118  bool isAllCovered() const;
119 
120  ///
121  /**
122  Return true if a_iv is a regular cell.
123  */
124  bool isRegular(const IntVect& a_iv) const;
125 
126  ///
127  /**
128  Return true if a_iv is an irregular cell.
129  */
130  bool isIrregular(const IntVect& a_iv) const;
131 
132  ///
133  /**
134  Return true if a_iv is a covered cell.
135  */
136  bool isCovered(const IntVect& a_iv) const;
137 
138  ///
139  /**
140  Return true if this cell is multi-valued.
141  */
142  bool isMultiValued(const IntVect& a_iv) const;
143 
144  ///
145  /**
146  Return true if every cell in a_box is a
147  covered cell.
148  */
149  bool isCovered(const Box& a_box) const;
150 
151  ///
152  /**
153  Return true if every cell in a_box is a
154  regular cell.
155  */
156  bool isRegular(const Box& a_box) const;
157 
158  ///
159  /**
160  Return the faces on the side and direction
161  of the input VoF.
162  */
163  Vector<FaceIndex> getFaces(const VolIndex& a_vof,
164  const int& a_idir,
165  const Side::LoHiSide& a_sd) const;
166 
167  ///
169  const int& a_idir,
170  const Side::LoHiSide& a_sd) const;
171  ///
172  /**
173  Returns a RealVect whose component in the uninteresting
174  direction normal to the face is undefined.
175  Returns the centroid of input face in the (one or two)
176  interesting directions. Return the
177  zero vector if the face is covered or regular.
178  The answer is given as a normalized (by grid spacing)
179  offset from the center of the cell face
180  (all numbers range from -0.5 to 0.5).
181  */
182  RealVect centroid(const FaceIndex& facein) const;
183 
184  ///
185  /**
186  Return the number of faces on the side and direction
187  of the input VoF.
188  */
189  int numFaces(const VolIndex& a_vof,
190  const int& a_idir,
191  const Side::LoHiSide& a_sd) const;
192 
193  ///
194  /**
195  Return the volume fraction of teh input VoF.
196  */
197  Real volFrac(const VolIndex& a_vof) const;
198 
199  ///
200  /**
201  Return the area fraction scaling of the input VoF.
202  Currently, this is 1/Max_faces(areaFrac).
203  */
204  Real areaFracScaling(const VolIndex& a_vof) const;
205 
206  ///
207  /**
208  Return true if the two VoFs are connected.
209  */
210  bool isConnected(const VolIndex& a_vof1,
211  const VolIndex& a_vof2) const;
212 
213  ///
214  /**
215  Return the area fraction of the face.
216  Returns zero if the two vofs in the face
217  are not actually connected.
218  */
219  Real areaFrac(const FaceIndex& a_face1) const;
220 
221  ///
222  /**
223  Return the sum of area fractions of the high
224  side of the vof in the given direction.
225  */
226  Real sumArea(const VolIndex& a_vof,
227  const int& a_idir,
228  const Side::LoHiSide& a_sd) const;
229 
230  ///
231  /**
232  Returns the centroid of the input VoF. Return the zero
233  vector if the VoF is regular or covered. The answer is given
234  as a normalized (by grid spacing) offset from the center
235  of the cell (all numbers range from -0.5 to 0.5).
236  */
237  RealVect centroid(const VolIndex& a_vof) const;
238 
239  ///
240  /**
241  Returns the corresponding set of VoFs from the next finer
242  EBISBox (factor of two refinement). The result is only
243  defined if this {\tt EBISBox} was defined by coarsening.
244  */
245  Vector<VolIndex> refine(const VolIndex& a_coarVoF) const;
246 
247  ///
248  /**
249  Returns the corresponding VoF from the next coarser
250  EBISBox (same solution location, different index space, factor
251  of two refinement ratio).
252  */
253  VolIndex coarsen(const VolIndex& a_fineVoF) const;
254 
255  ///
256  /**
257  */
258  RealVect bndryCentroid(const VolIndex& a_vof) const;
259  RealVect bndryCentroid(const VolIndex& a_vof, int face) const;
260 
261  ///
262  /**
263  */
264  Real bndryArea(const VolIndex& a_vof) const;
265  Real bndryArea(const VolIndex& a_vof, int face) const;
266 
267  ///
268  int numFacePhase(const VolIndex& a_vof) const ;
269 
270  /// used by multi-fluid code
271  int facePhase(const VolIndex& a_vof, int face) const ;
272 
273  /// used by multi-fluid code
274  const VolIndex& faceIndex(const VolIndex& a_vof, int face) const ;
275  ///
276  /**
277  Return the normal to the boundary at the
278  input VoF. If said normal is undefined,
279  returns the zero vector.
280  */
281  RealVect normal(const VolIndex& a_vof) const;
282  RealVect normal(const VolIndex& a_vof, int face) const;
283 
284  ///
285  const Box& getRegion() const;
286 
287  ///
288  const ProblemDomain& getDomain() const;
289 
290  ///
291  void setDomain(const ProblemDomain& a_domain);
292 
293  ///
294  /**
295  Returns the corresponding set of faces from the next finer
296  EBISBox (factor of two refinement). The result is only
297  defined if this EBISBox was defined by coarsening.
298  */
299  Vector<FaceIndex> refine(const FaceIndex& a_coarFace,const EBISBox& a_fineEBISBox) const;
300 
301  ///
302  /**
303  Returns the corresponding face from the next coarser
304  {\tt EBISLevel} (same solution location,
305  different index space, factor
306  of two refinement ratio).
307  */
308  FaceIndex coarsen(const FaceIndex& a_fineFace) const;
309 
310  ///
311  /**
312  Set the graph to all regular cells (sparse);
313  */
314  void setToAllRegular();
315 
316  ///
317  /**
318  Set the graph to all covered cells (sparse);
319  */
320  void setToAllCovered();
321 
322  /// define from scratch using irregular graph
323  //dtg--- i don't think this one exists
324  //void
325  //define(const BaseFab<int>& a_regIrregCovered,
326  // const Vector<IrregNode>& a_irregGraph,
327  // const Box& a_validRegion,
328  // const ProblemDomain& a_domain,
329  // const DataIndex& a_dit);
330 
331  ///
332  /**
333  */
334  const EBGraph& getEBGraph() const;
335 
336  ///
337  /**
338  */
339  const EBData& getEBData() const;
340 
341  /// define from scratch using a graph and an ebdata
342  void
343  define(const EBGraph& a_graph,
344  const EBData& a_data,
345  const DataIndex & a_dit);
346 
347  ///pointer copy
348  EBISBox& operator=(const EBISBox& ebiin);
349 
350  ///pointer copy
351  EBISBox(const EBISBox& ebiin);
352 
353  ///pointer comparison
354  bool operator==(const EBISBox& ebiin);
355 
356  /// get the moment at the VoF associated with the monomial with the input exponents
357  /**
358  Given VoF variables x, y, z, p = mono(0), q = mono(1), r = mono(2),
359  returns integral_over_VoF(x^p y^q z^r dV) for all p q
360  **/
362  {
363  return m_data.getVolumeMoments(a_vof);
364  }
365 
366  /// get the normal the irregular face associated with the monomial with the input exponents
367  /**
368  Given VoF variables x, y, z, p = mono(0), q = mono(1), r = mono(2),
369  returns integral_over_VoF((x^p y^q z^r) dV) for p q r
370  **/
372  {
373  return m_data.getEBMoments(a_vof);
374  }
375 
376  /// get the moment at the face associated with the monomial with the input exponents
377  /**
378  Given face variables x, y, p = mono(0), q = mono(1)),
379  returns integral_over_face(x^p y^q dA) for all p q
380  **/
382  {
383  return m_data.getFaceMoments(a_face);
384  }
385 
386  /// I am sick of guessing this name wrong
388  {
389  return getFaceMoments(a_face);
390  }
391 
392  ///
393  /**
394  gets the partial derivs of the normal component.
395  **/
396  IndMomSpaceDim getEBNormalPartialDerivs(const VolIndex& a_vof, int a_normalComponent) const
397  {
398  return m_data.getEBNormalPartialDerivs(a_vof, a_normalComponent);
399  }
400 
402  {
403  return m_dit;
404  }
405 private:
406 
407  ///this is already a ref-counted object
409 
410  ///this is already a ref-counted objecto
412 
414 
415 };
416 
417 
418 
419 /*******************************/
420 inline bool
421 EBISBox::isRegular(const IntVect& a_iv) const
422 {
423  return m_graph.isRegular(a_iv);
424 }
425 /*******************************/
426 inline bool
427 EBISBox::isIrregular(const IntVect& a_iv) const
428 {
429  return m_graph.isIrregular(a_iv);
430 }
431 /*******************************/
432 inline bool
434 {
435  return m_graph.isAllCovered();
436 }
437 /*******************************/
438 inline bool
440 {
441  return m_graph.isAllRegular();
442 }
443 /*******************************/
444 inline bool
445 EBISBox::isCovered(const IntVect& a_iv) const
446 {
447  return m_graph.isCovered(a_iv);
448 }
449 
450 inline bool
451 EBISBox::isMultiValued(const IntVect& a_iv) const
452 {
453  return m_graph.isMultiValued(a_iv);
454 }
455 
456 /*******************************/
457 inline bool
458 EBISBox::isCovered(const Box& a_box) const
459 {
460  return m_graph.isCovered(a_box);
461 }
462 /*******************************/
463 inline bool
464 EBISBox::isRegular(const Box& a_box) const
465 {
466  return m_graph.isRegular(a_box);
467 }
468 
469 inline Vector<VolIndex>
470 EBISBox::getVoFs(const IntVect& a_iv) const
471 {
472  return m_graph.getVoFs(a_iv);
473 }
474 
475 /*******************************/
476 inline Vector<FaceIndex>
478  const int& a_idir,
479  const Side::LoHiSide& a_sd) const
480 {
481  return m_graph.getAllFaces(a_iv, a_idir, a_sd);
482 }
483 /*******************************/
484 inline Vector<FaceIndex>
486  const int& a_idir,
487  const Side::LoHiSide& a_sd) const
488 {
489  return m_graph.getFaces(a_vof, a_idir, a_sd);
490 }
491 
492 inline int
493 EBISBox::numVoFs(const IntVect& a_iv) const
494 {
495  return m_graph.numVoFs(a_iv);
496 }
497 #include "NamespaceFooter.H"
498 #endif
Vector< VolIndex > refine(const VolIndex &a_coarVoF) const
bool isConnected(const VolIndex &a_vof1, const VolIndex &a_vof2) const
Vector< VolIndex > getVoFs(const IntVect &a_iv) const
Definition: EBGraph.H:854
EBData m_data
this is already a ref-counted objecto
Definition: EBISBox.H:411
An irregular domain on an integer lattice.
Definition: IntVectSet.H:44
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
bool isCovered(const IntVect &a_iv) const
Definition: EBISBox.H:445
Real bndryArea(const VolIndex &a_vof) const
bool isAllRegular() const
Definition: EBGraph.H:864
VolIndex coarsen(const VolIndex &a_fineVoF) const
const EBGraph & getEBGraph() const
define from scratch using irregular graph
IntVectSet getIrregIVS(const Box &a_subbox) const
IntVectSet getMultiCells(const Box &a_subbox) const
Definition: FaceIndex.H:28
const ProblemDomain & getDomain() const
void setDomain(const ProblemDomain &a_domain)
Vector< FaceIndex > getAllFaces(const IntVect &a_iv, const int &a_idir, const Side::LoHiSide &a_sd) const
Definition: EBISBox.H:477
IndMomSDMinOne getFaceMoments(const FaceIndex &a_face) const
get the moment at the face associated with the monomial with the input exponents
Definition: EBData.H:615
bool isMultiValued(const IntVect &a_iv) const
Definition: EBISBox.H:451
int numFacePhase(const VolIndex &a_vof) const
Definition: EBISBox.H:46
bool isAllCovered() const
Definition: EBGraph.H:869
Real areaFrac(const FaceIndex &a_face1) const
Real sumArea(const VolIndex &a_vof, const int &a_idir, const Side::LoHiSide &a_sd) const
void define(const EBGraph &a_graph, const EBData &a_data, const DataIndex &a_dit)
define from scratch using a graph and an ebdata
bool isIrregular(const IntVect &a_iv) const
Definition: EBGraph.H:874
int numFaces(const VolIndex &a_vof, const int &a_idir, const Side::LoHiSide &a_sd) const
Vector< VolIndex > getVoFs(const IntVect &a_iv) const
Definition: EBISBox.H:470
Vector< FaceIndex > getFaces(const VolIndex &a_vof, const int &a_idir, const Side::LoHiSide &a_sd) const
Definition: EBISBox.H:485
IndMomSpaceDim getEBNormalPartialDerivs(const VolIndex &a_vof, int a_normalComponent) const
Definition: EBData.H:630
Geometric description within a box.
Definition: EBGraph.H:427
bool isIrregular(const IntVect &a_iv) const
Definition: EBISBox.H:427
Definition: EBData.H:503
int facePhase(const VolIndex &a_vof, int face) const
used by multi-fluid code
long long numVoFs(const IntVect &a_iv) const
Definition: EBGraph.H:989
IndMomSDMinOne getFaceMoments(const FaceIndex &a_face) const
get the moment at the face associated with the monomial with the input exponents
Definition: EBISBox.H:381
IndMomSpaceDim getVolumeMoments(const VolIndex &a_vof) const
get the moment at the VoF associated with the monomial with the input exponents
Definition: EBData.H:595
Real areaFracScaling(const VolIndex &a_vof) const
bool isAllRegular() const
Definition: EBISBox.H:439
Vector< FaceIndex > getFaces(const VolIndex &a_vof, const int &a_idir, const Side::LoHiSide &a_sd) const
Definition: EBGraph.H:900
double Real
Definition: REAL.H:33
RealVect bndryCentroid(const VolIndex &a_vof) const
int numVoFs(const IntVect &a_iv) const
Definition: EBISBox.H:493
bool isRegular(const Box &a_box) const
Definition: EBGraph.H:894
LoHiSide
Definition: LoHiSide.H:27
RealVect normal(const VolIndex &a_vof) const
IndMomSpaceDim getVolumeMoments(const VolIndex &a_vof) const
get the moment at the VoF associated with the monomial with the input exponents
Definition: EBISBox.H:361
RealVect centroid(const FaceIndex &facein) const
bool isMultiValued(const IntVect &a_iv) const
Definition: EBGraph.H:884
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
IndMomSpaceDim getEBNormalPartialDerivs(const VolIndex &a_vof, int a_normalComponent) const
Definition: EBISBox.H:396
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
const EBData & getEBData() const
Definition: DataIndex.H:112
IndMomSpaceDim getEBMoments(const VolIndex &a_vof) const
get the normal the irregular face associated with the monomial with the input exponents ...
Definition: EBISBox.H:371
IndMomSpaceDim getEBMoments(const VolIndex &a_vof) const
get the normal the irregular face associated with the monomial with the input exponents ...
Definition: EBData.H:605
DataIndex dataIndex() const
Definition: EBISBox.H:401
const Box & getRegion() const
bool isAllCovered() const
Definition: EBISBox.H:433
void setToAllRegular()
EBISBox & operator=(const EBISBox &ebiin)
pointer copy
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
bool isRegular(const IntVect &a_iv) const
Definition: EBISBox.H:421
bool isCovered(const Box &a_box) const
Definition: EBGraph.H:889
Volume of Fluid Index.
Definition: VolIndex.H:31
Vector< FaceIndex > getAllFaces(const IntVect &a_iv, const int &a_idir, const Side::LoHiSide &a_sd) const
Definition: EBGraph.H:979
bool operator==(const EBISBox &ebiin)
pointer comparison
DataIndex m_dit
Definition: EBISBox.H:413
IndMomSDMinOne getAreaMoments(const FaceIndex &a_face) const
I am sick of guessing this name wrong.
Definition: EBISBox.H:387
EBGraph m_graph
this is already a ref-counted object
Definition: EBISBox.H:408
IntVectSet boundaryIVS(const Box &a_subbox) const
void setToAllCovered()
Real volFrac(const VolIndex &a_vof) const
const VolIndex & faceIndex(const VolIndex &a_vof, int face) const
used by multi-fluid code