Chombo + EB + MF  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 
330  ///
331  /**
332  */
333  const EBGraph& getEBGraph() const;
334 
335  ///
336  /**
337  */
338  const EBData& getEBData() const;
339 
340  /// define from scratch using a graph and an ebdata
341  void
342  define(const EBGraph& a_graph,
343  const EBData& a_data,
344  const DataIndex & a_dit);
345 
346  ///pointer copy
347  EBISBox& operator=(const EBISBox& ebiin);
348 
349  ///pointer copy
350  EBISBox(const EBISBox& ebiin);
351 
352  ///pointer comparison
353  bool operator==(const EBISBox& ebiin);
354 
356  {
357  return m_dit;
358  }
359 
360 private:
361 
362  ///this is already a ref-counted object
364 
365  ///this is already a ref-counted objecto
367 
369 };
370 
371 
372 
373 /*******************************/
374 inline bool
375 EBISBox::isRegular(const IntVect& a_iv) const
376 {
377  return m_graph.isRegular(a_iv);
378 }
379 /*******************************/
380 inline bool
381 EBISBox::isIrregular(const IntVect& a_iv) const
382 {
383  return m_graph.isIrregular(a_iv);
384 }
385 /*******************************/
386 inline bool
388 {
389  return m_graph.isAllCovered();
390 }
391 /*******************************/
392 inline bool
394 {
395  return m_graph.isAllRegular();
396 }
397 /*******************************/
398 inline bool
399 EBISBox::isCovered(const IntVect& a_iv) const
400 {
401  return m_graph.isCovered(a_iv);
402 }
403 
404 inline bool
405 EBISBox::isMultiValued(const IntVect& a_iv) const
406 {
407  return m_graph.isMultiValued(a_iv);
408 }
409 
410 /*******************************/
411 inline bool
412 EBISBox::isCovered(const Box& a_box) const
413 {
414  return m_graph.isCovered(a_box);
415 }
416 /*******************************/
417 inline bool
418 EBISBox::isRegular(const Box& a_box) const
419 {
420  return m_graph.isRegular(a_box);
421 }
422 
423 inline Vector<VolIndex>
424 EBISBox::getVoFs(const IntVect& a_iv) const
425 {
426  return m_graph.getVoFs(a_iv);
427 }
428 
429 /*******************************/
430 inline Vector<FaceIndex>
432  const int& a_idir,
433  const Side::LoHiSide& a_sd) const
434 {
435  return m_graph.getAllFaces(a_iv, a_idir, a_sd);
436 }
437 /*******************************/
438 inline Vector<FaceIndex>
440  const int& a_idir,
441  const Side::LoHiSide& a_sd) const
442 {
443  return m_graph.getFaces(a_vof, a_idir, a_sd);
444 }
445 
446 inline int
447 EBISBox::numVoFs(const IntVect& a_iv) const
448 {
449  return m_graph.numVoFs(a_iv);
450 }
451 #include "NamespaceFooter.H"
452 #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:366
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:399
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
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:431
bool isMultiValued(const IntVect &a_iv) const
Definition: EBISBox.H:405
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:424
Vector< FaceIndex > getFaces(const VolIndex &a_vof, const int &a_idir, const Side::LoHiSide &a_sd) const
Definition: EBISBox.H:439
Geometric description within a box.
Definition: EBGraph.H:427
bool isIrregular(const IntVect &a_iv) const
Definition: EBISBox.H:381
Definition: EBData.H:322
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
Real areaFracScaling(const VolIndex &a_vof) const
bool isAllRegular() const
Definition: EBISBox.H:393
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:447
bool isRegular(const Box &a_box) const
Definition: EBGraph.H:894
LoHiSide
Definition: LoHiSide.H:27
RealVect normal(const VolIndex &a_vof) const
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:469
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
const EBData & getEBData() const
Definition: DataIndex.H:114
DataIndex dataIndex() const
Definition: EBISBox.H:355
const Box & getRegion() const
bool isAllCovered() const
Definition: EBISBox.H:387
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:375
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:368
EBGraph m_graph
this is already a ref-counted object
Definition: EBISBox.H:363
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