Chombo + EB + MF  3.2
EBData.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 _EBDATA_H_
14 #define _EBDATA_H_
15 
16 #include "REAL.H"
17 #include "RealVect.H"
18 
19 #include "EBGraph.H"
20 #include "IrregNode.H"
21 #include "BaseIVFAB.H"
22 #include "BaseIFFAB.H"
23 
24 #include "NamespaceHeader.H"
25 
26 class EBIndexSpace;
27 
28 template <class T>
29 int linearSize(const T& inputT);
30 
31 template <class T>
32 void linearIn(T& a_outputT, const void* const inBuf);
33 
34 template <class T>
35 void linearOut(void* const a_outBuf, const T& inputT);
36 
38 {
39 public:
40  BoundaryData();
41 
42  BoundaryData(const Real& bndryArea, const RealVect& normal,
43  const RealVect& bndryCentroid, int phase,const VolIndex& index)
44  :
45  m_bndryArea(bndryArea),
46  m_normal(normal),
47  m_bndryCentroid(bndryCentroid),
48  m_bndryPhase(phase),
49  m_volIndex(index)
50  {
51  }
52 
58 };
59 
60 ///
61 /**
62  */
63 class VolData
64 {
65 public:
66  VolData();
71 };
72 
73 /// VolData specializations of linear* functions used by LevelData
74 //[NOTE: see also SPMD.H. <dbs>]
75 template < >
76 int linearSize(const VolData& vdata);
77 template < >
78 void linearIn(VolData& a_outputT, const void* const inBuf);
79 template < >
80 void linearOut(void* const a_outBuf, const VolData& a_inputT);
81 
82 
83 
84 std::ostream& operator<< (std::ostream& a_os,
85  const VolData& a_iv);
86 ///
87 /**
88  */
89 class FaceData
90 {
91 public:
94 };
95 
96 template < >
97 int linearSize(const FaceData& vdata);
98 template < >
99 void linearIn(FaceData& a_outputT, const void* const inBuf);
100 template < >
101 void linearOut(void* const a_outBuf, const FaceData& a_inputT);
102 
103 ///
104 /**
105  This class contains all the geometric information
106  for an ebisbox.
107  */
109 {
110 
111 public:
112 
113  ///
114  EBDataImplem();
115 
116  ///
117  ~EBDataImplem();
118 
119  ///
120  /**
121  Noop.
122  */
123  void define(const Box& box, int comps);
124 
125  ///
126  /**
127  Noop
128  */
129  EBDataImplem(const Box& a_box, int a_comps);
130 
131  ///
132  /**
133  Copy the information from a_source to the over the intersection
134  of the box a_region, the box of the current EBDataImplem and
135  the box of a_source. The Interval arguments are ignored.
136  This function is required by LevelData.
137  */
138  void copy(const Box& a_regionFrom,
139  const Interval& a_Cd,
140  const Box& a_regionto,
141  const EBDataImplem& a_source,
142  const Interval& a_Cs);
143 
144  /// each data holder is defined over the irregular cells of the graph
145  void
146  defineVoFData(const EBGraph& a_graph, const Box& a_region);
147 
148  /// each data holder is defined over the irregular cells of the graph
149  void
150  defineFaceData(const EBGraph& a_graph, const Box& a_region);
151 
152  ///define the whole thing
153  void
154  define(const EBGraph& a_graph,
155  const Vector<IrregNode>& a_irregData,
156  const Box& a_validBox);
157 
158  ///
159  void
160  coarsenVoFs(const EBDataImplem& a_fineEBDataImplem,
161  const EBGraph& a_fineGraph,
162  const EBGraph& a_coarGraph,
163  const Box& a_validRegion);
164 
165  ///
166  void
167  coarsenFaces(const EBDataImplem& a_fineEBDataImplem,
168  const EBGraph& a_fineGraph,
169  const EBGraph& a_coarGraph,
170  const Box& a_validRegion);
171  ///
172  const Real& volFrac(const VolIndex& a_vof) const;
173 
174  ///
175  const Real& areaFrac(const FaceIndex& a_face1) const;
176 
177  ///
178  const RealVect& centroid(const FaceIndex& facein) const;
179 
180  ///
181  const RealVect& centroid(const VolIndex& a_vof) const;
182 
183  ///
184  const RealVect& bndryCentroid(const VolIndex& a_vof) const;
185  const RealVect& bndryCentroid(const VolIndex& a_vof, int face) const;
186 
187  ///
188  const Real& bndryArea(const VolIndex& a_vof) const;
189  const Real& bndryArea(const VolIndex& a_vof, int face) const;
190 
191  ///
192  const RealVect& normal(const VolIndex& a_vof) const;
193  const RealVect& normal(const VolIndex& a_vof, int face) const;
194 
195  // New set of boundary inquiry functions to support multi-fluid applications
196  /// used by multi-fluid applications
197 
198  /// used by multi-fluid code
199  int facePhase(const VolIndex& a_vof, int face) const ;
200 
201  /// used by multi-fluid code
202  const VolIndex& faceIndex(const VolIndex& a_vof, int face) const ;
203 
204  /// used by multi-fluid code
205  void setFacePhase(const VolIndex& a_vof, int face, int phase);
206  ///
207  /// used by multi-fluid code
208  void setFaceIndex(const VolIndex& a_vof, int face, const VolIndex& index);
209 
210  ///
211  int numFacePhase(const VolIndex& a_vof) const ;
212 
213  void clearMultiBoundaries();
214  void setBoundaryPhase(int phase);
215  /**
216  This stuff required by LevelData in parallel:
217  */
218  int size(const Box& R, const Interval& comps) const;
219 
220  ///
221  void linearOut(void* buf, const Box& R, const Interval& comps) const;
222 
223  ///
224  void linearIn(void* buf, const Box& R, const Interval& comps);
225 
226  ///
227  static int preAllocatable()
228  {
229  return 2; // dyanmic allocatable.
230  }
231 
233  {
234  return m_volData;
235  }
237  {
238  return m_volData;
239  }
240 
241  ///
242  void addFullIrregularVoFs(const IntVectSet& a_vofsToChange,
243  const EBGraph& a_newGhostGraph,
244  const BaseIVFAB<VolData>& a_newGhostData,
245  const EBGraph& a_oldGhostGraph);
246 
247  ///multifluid angels dancing on the heads of pins.
248  void addEmptyIrregularVoFs(const IntVectSet& a_vofsToChange,
249  const EBGraph& a_newGraph);
250  ///
251  static void setVerbose(bool a_verbose);
252  ///
253  static void setVerboseDebug(bool a_verboseDebug);
254 private:
255 
256  static bool s_verbose;
257  static bool s_verboseDebug;
258  ///
260 
261  ///
263 
264  ///
266 
267  ///
269 
270  void operator=(const EBDataImplem& ebiin)
271  {;}
272 
274  {;}
275 
276  void
277  coarsenFaceCentroid(RealVect& a_centroidCoar,
278  const Vector<RealVect>& a_centroidsFine,
279  const Vector<Real>& a_areaFracFine,
280  const Vector<FaceIndex>& a_facesFine,
281  const FaceIndex& a_faceCoar);
282  void
283  coarsenAreaFrac(Real& a_areaFracCoar,
284  const Vector<Real>& a_areaFracFine);
285 
286  void
287  coarsenVolFracAndCentroid(Real& a_volFracCoar,
288  RealVect& a_volCentroidCoar,
289  const Vector<Real>& a_volFracFine,
290  const Vector<RealVect>& a_volCentroidFine,
291  const Vector<VolIndex>& a_fineVoFs,
292  const VolIndex& a_coarVoF);
293 
294  void
295  coarsenBoundaryAreaAndNormal(Real& a_bndryAreaCoar,
296  RealVect& a_normalCoar,
297  const Vector<Real>& a_bndryAreaFine,
298  const Vector<RealVect>& a_normalFine);
299 
300  RealVect
301  fineToCoarseTransform(const RealVect& a_finePoint,
302  const IntVect& a_coarCell,
303  const IntVect& a_fineCell);
304 
305  void
306  coarsenBndryCentroid(RealVect& a_bndryCentroidCoar,
307  const Vector<RealVect>& a_bndryCentroidFine,
308  const Vector<Real>& a_bndryAreaFine,
309  const Vector<VolIndex>& a_fineVoFs,
310  const VolIndex& a_coarVoF);
311 
312  void fetch(std::list<const VolData*>& fineVols, const Vector<VolIndex>& vofsFine) const;
313 
314  friend class EBIndexSpace;
315  friend class EBISLevel;
316 };
317 
318 ///
319 /**
320  Ref-counted version of EBDataImplem.
321  */
322 class EBData
323 {
324 public:
325 
326  ///
327  EBData();
328 
329  ///
330  ~EBData();
331 
332  ///
333  /**
334  Noop.
335  */
336  void define(const Box& box, int comps);
337 
338  ///
339  /**
340  Noop
341  */
342  EBData(const Box& a_box, int a_comps);
343 
344  ///
345  /**
346  Copy the information from a_source to the over the intersection
347  of the box a_region, the box of the current EBData and
348  the box of a_source. The Interval arguments are ignored.
349  This function is required by LevelData.
350  */
351  void copy(const Box& a_regionFrom,
352  const Interval& a_Cd,
353  const Box& a_regionto,
354  const EBData& a_source,
355  const Interval& a_Cs);
356 
357  /// each data holder is defined over the irregular cells of the graph
358  void
359  defineVoFData(const EBGraph& a_graph, const Box& a_region);
360 
361  /// each data holder is defined over the irregular cells of the graph
362  void
363  defineFaceData(const EBGraph& a_graph, const Box& a_region);
364 
365  ///define the whole thing
366  void
367  define(const EBGraph& a_graph,
368  const Vector<IrregNode>& a_irregData,
369  const Box& a_validBox);
370 
371  ///
372  void
373  coarsenVoFs(const EBData& a_fineEBData,
374  const EBGraph& a_fineGraph,
375  const EBGraph& a_coarGraph,
376  const Box& a_validRegion);
377 
378  void
379  coarsenFaces(const EBData& a_fineEBData,
380  const EBGraph& a_fineGraph,
381  const EBGraph& a_coarGraph,
382  const Box& a_validRegion);
383  ///
384  const Real& volFrac(const VolIndex& a_vof) const;
385 
386  ///
387  const Real& areaFrac(const FaceIndex& a_face1) const;
388 
389  ///
390  const RealVect& centroid(const FaceIndex& facein) const;
391 
392  ///
393  const RealVect& centroid(const VolIndex& a_vof) const;
394 
395  ///
396  const RealVect& bndryCentroid(const VolIndex& a_vof) const;
397  const RealVect& bndryCentroid(const VolIndex& a_vof, int face) const;
398 
399  ///
400  const Real& bndryArea(const VolIndex& a_vof) const;
401  const Real& bndryArea(const VolIndex& a_vof, int face) const;
402 
403  ///
404  const RealVect& normal(const VolIndex& a_vof) const;
405  const RealVect& normal(const VolIndex& a_vof, int face) const;
406 
407  /// used by multi-fluid code
408  int facePhase(const VolIndex& a_vof, int face) const ;
409 
410  /// used by multi-fluid code
411  const VolIndex& faceIndex(const VolIndex& a_vof, int face) const ;
412 
413  /// used by multi-fluid code
414  void setFacePhase(const VolIndex& a_vof, int face, int phase);
415 
416  /// used by multi-fluid code
417  void setFaceIndex(const VolIndex& a_vof, int face, int index);
418  ///
419  int numFacePhase(const VolIndex& a_vof) const ;
420 
421  void clearMultiBoundaries();
422  void setBoundaryPhase(int phase);
423  ///
424  EBData(const EBData& a_ebiin);
425 
426  ///
427  /**
428  This is a pointer comparison.
429  */
430  bool operator==(const EBData& a_ebiin);
431 
432  ///
433  EBData& operator=(const EBData& a_ebiin);
434 
435  ///
436  /**
437  This stuff required by LevelData in parallel:
438  */
439  int size(const Box& R, const Interval& comps) const;
440 
441  ///
442  void linearOut(void* buf, const Box& R, const Interval& comps) const;
443 
444  ///
445  void linearIn(void* buf, const Box& R, const Interval& comps);
446 
447  ///
448  void addFullIrregularVoFs(const IntVectSet& a_vofsToChange,
449  const EBGraph& a_newGhostGraph,
450  const BaseIVFAB<VolData>& a_grownData,
451  const EBGraph& a_oldGhostGraph);
452 
453  ///multifluid angels dancing on the heads of pins.
454  void addEmptyIrregularVoFs(const IntVectSet& a_vofsToChange,
455  const EBGraph& a_newGraph);
456 
457  ///
458  void
459  computeNormalsAndBoundaryAreas(const EBGraph& a_graph,
460  const Box& a_validRegion);
461 
463  {
464  return m_implem->getVolData();
465  }
466 
468  {
469  return m_implem->getVolData();
470  }
471 
472  ///
473  static int preAllocatable()
474  {
475  return 2; // dyanmic allocatable.
476  }
477 private:
478 
479  ///
481 
482  friend class EBIndexSpace;
483  friend class EBISLevel;
484 };
485 
486 /*******************************/
487 inline const Real& EBData::volFrac(const VolIndex& a_vof) const
488 {
489  return m_implem->volFrac(a_vof);
490 }
491 /*******************************/
492 inline const Real& EBData::bndryArea(const VolIndex& a_vof, int face) const
493 {
494  return m_implem->bndryArea(a_vof, face);
495 }
496 inline const Real& EBData::bndryArea(const VolIndex& a_vof) const
497 {
498  return m_implem->bndryArea(a_vof);
499 }
500 /*******************************/
501 inline const RealVect& EBData::normal(const VolIndex& a_vof, int face) const
502 {
503  return m_implem->normal(a_vof, face);
504 }
505 inline const RealVect& EBData::normal(const VolIndex& a_vof) const
506 {
507  return m_implem->normal(a_vof);
508 }
509 /*******************************/
510 inline const RealVect& EBData::centroid(const VolIndex& a_vof) const
511 {
512  return m_implem->centroid(a_vof);
513 }
514 /*******************************/
515 inline const RealVect& EBData::bndryCentroid(const VolIndex& a_vof, int face) const
516 {
517  return m_implem->bndryCentroid(a_vof, face);
518 }
519 inline const RealVect& EBData::bndryCentroid(const VolIndex& a_vof) const
520 {
521  return m_implem->bndryCentroid(a_vof);
522 }
523 /*******************************/
524 inline const RealVect& EBData::centroid(const FaceIndex& a_face) const
525 {
526  return m_implem->centroid(a_face);
527 }
528 /*******************************/
529 inline const Real& EBData::areaFrac(const FaceIndex& a_face) const
530 {
531  return m_implem->areaFrac(a_face);
532 }
533 /*******************************/
534 
535 #include "NamespaceFooter.H"
536 #endif
Definition: EBData.H:63
static bool s_verboseDebug
Definition: EBData.H:257
An irregular domain on an integer lattice.
Definition: IntVectSet.H:44
const RealVect & centroid(const FaceIndex &facein) const
Definition: EBData.H:524
Definition: EBIndexSpace.H:50
Definition: EBData.H:89
static bool s_verbose
Definition: EBData.H:256
Definition: FaceIndex.H:28
RealVect m_normal
Definition: EBData.H:54
Definition: EBISLevel.H:84
BaseIVFAB< VolData > & getVolData()
Definition: EBData.H:232
const Real & bndryArea(const VolIndex &a_vof) const
Definition: EBData.H:496
static int preAllocatable()
Definition: EBData.H:227
Geometric description within a box.
Definition: EBGraph.H:427
bool m_isFaceDataDefined
Definition: EBData.H:265
const int SpaceDim
Definition: SPACE.H:38
Vector< BoundaryData > m_phaseFaces
Definition: EBData.H:70
Definition: EBData.H:322
Definition: EBInterface.H:45
EBDataImplem(const EBDataImplem &ebiin)
Definition: EBData.H:273
const Real & volFrac(const VolIndex &a_vof) const
Definition: EBData.H:487
int linearSize(const T &inputT)
Definition: SPMDI.H:21
BoundaryData(const Real &bndryArea, const RealVect &normal, const RealVect &bndryCentroid, int phase, const VolIndex &index)
Definition: EBData.H:42
Structure for passing component ranges in code.
Definition: Interval.H:23
const RealVect & bndryCentroid(const VolIndex &a_vof) const
Definition: EBData.H:519
Real m_volFrac
Definition: EBData.H:67
const Real & areaFrac(const FaceIndex &a_face1) const
Definition: EBData.H:529
double Real
Definition: REAL.H:33
BoundaryData m_averageFace
Definition: EBData.H:69
RealVect m_bndryCentroid
Definition: EBData.H:55
void linearIn(T &a_outputT, const void *const inBuf)
Definition: SPMDI.H:27
RealVect m_volCentroid
Definition: EBData.H:68
Definition: EBData.H:108
int m_bndryPhase
Definition: EBData.H:56
static int preAllocatable()
Definition: EBData.H:473
BaseIVFAB< VolData > m_volData
Definition: EBData.H:259
void operator=(const EBDataImplem &ebiin)
Definition: EBData.H:270
void linearOut(void *const a_outBuf, const T &inputT)
Definition: SPMDI.H:33
const RealVect & normal(const VolIndex &a_vof) const
Definition: EBData.H:505
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
BaseIVFAB< VolData > & getVolData()
Definition: EBData.H:462
const BaseIVFAB< VolData > & getVolData() const
Definition: EBData.H:467
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
RefCountedPtr< EBDataImplem > m_implem
Definition: EBData.H:480
Volume of Fluid Index.
Definition: VolIndex.H:31
bool m_isVoFDataDefined
Definition: EBData.H:268
Real m_areaFrac
Definition: EBData.H:92
std::ostream & operator<<(std::ostream &a_os, const VolData &a_iv)
RealVect m_faceCentroid
Definition: EBData.H:93
Real m_bndryArea
Definition: EBData.H:53
const BaseIVFAB< VolData > & getVolData() const
Definition: EBData.H:236
VolIndex m_volIndex
Definition: EBData.H:57
Definition: EBData.H:37