Chombo + EB  3.0
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 every cell in a_box is a
141  covered cell.
142  */
143  bool isCovered(const Box& a_box) const;
144 
145  ///
146  /**
147  Return true if every cell in a_box is a
148  regular cell.
149  */
150  bool isRegular(const Box& a_box) const;
151 
152  ///
153  /**
154  Return the faces on the side and direction
155  of the input VoF.
156  */
157  Vector<FaceIndex> getFaces(const VolIndex& a_vof,
158  const int& a_idir,
159  const Side::LoHiSide& a_sd) const;
160 
161  ///
163  const int& a_idir,
164  const Side::LoHiSide& a_sd) const;
165  ///
166  /**
167  Returns a RealVect whose component in the uninteresting
168  direction normal to the face is undefined.
169  Returns the centroid of input face in the (one or two)
170  interesting directions. Return the
171  zero vector if the face is covered or regular.
172  The answer is given as a normalized (by grid spacing)
173  offset from the center of the cell face
174  (all numbers range from -0.5 to 0.5).
175  */
176  RealVect centroid(const FaceIndex& facein) const;
177 
178  ///
179  /**
180  Return the number of faces on the side and direction
181  of the input VoF.
182  */
183  int numFaces(const VolIndex& a_vof,
184  const int& a_idir,
185  const Side::LoHiSide& a_sd) const;
186 
187  ///
188  /**
189  Return the volume fraction of teh input VoF.
190  */
191  Real volFrac(const VolIndex& a_vof) const;
192 
193  ///
194  /**
195  Return the area fraction scaling of the input VoF.
196  Currently, this is 1/Max_faces(areaFrac).
197  */
198  Real areaFracScaling(const VolIndex& a_vof) const;
199 
200  ///
201  /**
202  Return true if the two VoFs are connected.
203  */
204  bool isConnected(const VolIndex& a_vof1,
205  const VolIndex& a_vof2) const;
206 
207  ///
208  /**
209  Return the area fraction of the face.
210  Returns zero if the two vofs in the face
211  are not actually connected.
212  */
213  Real areaFrac(const FaceIndex& a_face1) const;
214 
215  ///
216  /**
217  Return the sum of area fractions of the high
218  side of the vof in the given direction.
219  */
220  Real sumArea(const VolIndex& a_vof,
221  const int& a_idir,
222  const Side::LoHiSide& a_sd) const;
223 
224  ///
225  /**
226  Returns the centroid of the input VoF. Return the zero
227  vector if the VoF is regular or covered. The answer is given
228  as a normalized (by grid spacing) offset from the center
229  of the cell (all numbers range from -0.5 to 0.5).
230  */
231  RealVect centroid(const VolIndex& a_vof) const;
232 
233  ///
234  /**
235  Returns the corresponding set of VoFs from the next finer
236  EBISBox (factor of two refinement). The result is only
237  defined if this {\tt EBISBox} was defined by coarsening.
238  */
239  Vector<VolIndex> refine(const VolIndex& a_coarVoF) const;
240 
241  ///
242  /**
243  Returns the corresponding VoF from the next coarser
244  EBISBox (same solution location, different index space, factor
245  of two refinement ratio).
246  */
247  VolIndex coarsen(const VolIndex& a_fineVoF) const;
248 
249  ///
250  /**
251  */
252  RealVect bndryCentroid(const VolIndex& a_vof) const;
253  RealVect bndryCentroid(const VolIndex& a_vof, int face) const;
254 
255  ///
256  /**
257  */
258  Real bndryArea(const VolIndex& a_vof) const;
259  Real bndryArea(const VolIndex& a_vof, int face) const;
260 
261  ///
262  int numFacePhase(const VolIndex& a_vof) const ;
263 
264  /// used by multi-fluid code
265  int facePhase(const VolIndex& a_vof, int face) const ;
266 
267  /// used by multi-fluid code
268  const VolIndex& faceIndex(const VolIndex& a_vof, int face) const ;
269  ///
270  /**
271  Return the normal to the boundary at the
272  input VoF. If said normal is undefined,
273  returns the zero vector.
274  */
275  RealVect normal(const VolIndex& a_vof) const;
276  RealVect normal(const VolIndex& a_vof, int face) const;
277 
278  ///
279  const Box& getRegion() const;
280 
281  ///
282  const ProblemDomain& getDomain() const;
283 
284  ///
285  void setDomain(const ProblemDomain& a_domain);
286 
287  ///
288  /**
289  Returns the corresponding set of faces from the next finer
290  EBISBox (factor of two refinement). The result is only
291  defined if this EBISBox was defined by coarsening.
292  */
293  Vector<FaceIndex> refine(const FaceIndex& a_coarFace,const EBISBox& a_fineEBISBox) const;
294 
295  ///
296  /**
297  Returns the corresponding face from the next coarser
298  {\tt EBISLevel} (same solution location,
299  different index space, factor
300  of two refinement ratio).
301  */
302  FaceIndex coarsen(const FaceIndex& a_fineFace) const;
303 
304  ///
305  /**
306  Set the graph to all regular cells (sparse);
307  */
308  void setToAllRegular();
309 
310  ///
311  /**
312  Set the graph to all covered cells (sparse);
313  */
314  void setToAllCovered();
315 
316  /// define from scratch using irregular graph
317  void
318  define(const BaseFab<int>& a_regIrregCovered,
319  const Vector<IrregNode>& a_irregGraph,
320  const Box& a_validRegion,
321  const ProblemDomain& a_domain);
322 
323  ///
324  /**
325  */
326  const EBGraph& getEBGraph() const;
327 
328  ///
329  /**
330  */
331  const EBData& getEBData() const;
332 
333  /// define from scratch using a graph and an ebdata
334  void
335  define(const EBGraph& a_graph,
336  const EBData& a_data);
337 
338  ///pointer copy
339  EBISBox& operator=(const EBISBox& ebiin);
340 
341  ///pointer copy
342  EBISBox(const EBISBox& ebiin);
343 
344  ///pointer comparison
345  bool operator==(const EBISBox& ebiin);
346 
347 private:
348 
349  ///this is already a ref-counted object
351 
352  ///this is already a ref-counted objecto
354 
355 };
356 
357 
358 
359 /*******************************/
360 inline bool
361 EBISBox::isRegular(const IntVect& a_iv) const
362 {
363  return m_graph.isRegular(a_iv);
364 }
365 /*******************************/
366 inline bool
367 EBISBox::isIrregular(const IntVect& a_iv) const
368 {
369  return m_graph.isIrregular(a_iv);
370 }
371 /*******************************/
372 inline bool
374 {
375  return m_graph.isAllCovered();
376 }
377 /*******************************/
378 inline bool
380 {
381  return m_graph.isAllRegular();
382 }
383 /*******************************/
384 inline bool
385 EBISBox::isCovered(const IntVect& a_iv) const
386 {
387  return m_graph.isCovered(a_iv);
388 }
389 /*******************************/
390 inline bool
391 EBISBox::isCovered(const Box& a_box) const
392 {
393  return m_graph.isCovered(a_box);
394 }
395 /*******************************/
396 inline bool
397 EBISBox::isRegular(const Box& a_box) const
398 {
399  return m_graph.isRegular(a_box);
400 }
401 
402 inline Vector<VolIndex>
403 EBISBox::getVoFs(const IntVect& a_iv) const
404 {
405  return m_graph.getVoFs(a_iv);
406 }
407 
408 /*******************************/
409 inline Vector<FaceIndex>
411  const int& a_idir,
412  const Side::LoHiSide& a_sd) const
413 {
414  return m_graph.getAllFaces(a_iv, a_idir, a_sd);
415 }
416 /*******************************/
417 inline Vector<FaceIndex>
419  const int& a_idir,
420  const Side::LoHiSide& a_sd) const
421 {
422  return m_graph.getFaces(a_vof, a_idir, a_sd);
423 }
424 
425 inline int
426 EBISBox::numVoFs(const IntVect& a_iv) const
427 {
428  return m_graph.numVoFs(a_iv);
429 }
430 #include "NamespaceFooter.H"
431 #endif
RealVect centroid(const FaceIndex &facein) const
EBData m_data
this is already a ref-counted objecto
Definition: EBISBox.H:353
const VolIndex & faceIndex(const VolIndex &a_vof, int face) const
used by multi-fluid code
An irregular domain on an integer lattice.
Definition: IntVectSet.H:44
Vector< VolIndex > refine(const VolIndex &a_coarVoF) const
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:130
IntVectSet getMultiCells(const Box &a_subbox) const
const EBGraph & getEBGraph() const
Definition: FaceIndex.H:28
void setDomain(const ProblemDomain &a_domain)
IntVectSet getIrregIVS(const Box &a_subbox) const
bool isAllCovered() const
Definition: EBGraph.H:869
const EBData & getEBData() const
int numFaces(const VolIndex &a_vof, const int &a_idir, const Side::LoHiSide &a_sd) const
Definition: EBISBox.H:46
bool isIrregular(const IntVect &a_iv) const
Definition: EBGraph.H:874
Real bndryArea(const VolIndex &a_vof) const
Vector< FaceIndex > getAllFaces(const IntVect &a_iv, const int &a_idir, const Side::LoHiSide &a_sd) const
Definition: EBGraph.H:974
int numVoFs(const IntVect &a_iv) const
Definition: EBISBox.H:426
Vector< VolIndex > getVoFs(const IntVect &a_iv) const
Definition: EBISBox.H:403
Geometric description within a box.
Definition: EBGraph.H:432
Definition: EBData.H:321
Vector< FaceIndex > getFaces(const VolIndex &a_vof, const int &a_idir, const Side::LoHiSide &a_sd) const
Definition: EBISBox.H:418
VolIndex coarsen(const VolIndex &a_fineVoF) const
Real areaFracScaling(const VolIndex &a_vof) const
void define(const BaseFab< int > &a_regIrregCovered, const Vector< IrregNode > &a_irregGraph, const Box &a_validRegion, const ProblemDomain &a_domain)
define from scratch using irregular graph
const Box & getRegion() const
bool isCovered(const Box &a_box) const
Definition: EBGraph.H:884
const ProblemDomain & getDomain() const
Real volFrac(const VolIndex &a_vof) const
double Real
Definition: REAL.H:33
bool isCovered(const IntVect &a_iv) const
Definition: EBISBox.H:385
LoHiSide
Definition: LoHiSide.H:27
bool isRegular(const IntVect &a_iv) const
Definition: EBISBox.H:361
RealVect bndryCentroid(const VolIndex &a_vof) const
Vector< VolIndex > getVoFs(const IntVect &a_iv) const
Definition: EBGraph.H:854
int facePhase(const VolIndex &a_vof, int face) const
used by multi-fluid code
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
Real sumArea(const VolIndex &a_vof, const int &a_idir, const Side::LoHiSide &a_sd) const
IntVectSet boundaryIVS(const Box &a_subbox) const
RealVect normal(const VolIndex &a_vof) const
bool isAllRegular() const
Definition: EBGraph.H:864
Vector< FaceIndex > getFaces(const VolIndex &a_vof, const int &a_idir, const Side::LoHiSide &a_sd) const
Definition: EBGraph.H:895
void setToAllRegular()
EBISBox & operator=(const EBISBox &ebiin)
pointer copy
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Real areaFrac(const FaceIndex &a_face1) const
Volume of Fluid Index.
Definition: VolIndex.H:31
bool isIrregular(const IntVect &a_iv) const
Definition: EBISBox.H:367
bool operator==(const EBISBox &ebiin)
pointer comparison
EBGraph m_graph
this is already a ref-counted object
Definition: EBISBox.H:350
int numVoFs(const IntVect &a_iv) const
Definition: EBGraph.H:984
Vector< FaceIndex > getAllFaces(const IntVect &a_iv, const int &a_idir, const Side::LoHiSide &a_sd) const
Definition: EBISBox.H:410
void setToAllCovered()
bool isAllRegular() const
Definition: EBISBox.H:379
bool isAllCovered() const
Definition: EBISBox.H:373
int numFacePhase(const VolIndex &a_vof) const
bool isRegular(const Box &a_box) const
Definition: EBGraph.H:889
bool isConnected(const VolIndex &a_vof1, const VolIndex &a_vof2) const