Chombo + EB  3.0
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 };
316 
317 ///
318 /**
319  Ref-counted version of EBDataImplem.
320  */
321 class EBData
322 {
323 public:
324 
325  ///
326  EBData();
327 
328  ///
329  ~EBData();
330 
331  ///
332  /**
333  Noop.
334  */
335  void define(const Box& box, int comps);
336 
337  ///
338  /**
339  Noop
340  */
341  EBData(const Box& a_box, int a_comps);
342 
343  ///
344  /**
345  Copy the information from a_source to the over the intersection
346  of the box a_region, the box of the current EBData and
347  the box of a_source. The Interval arguments are ignored.
348  This function is required by LevelData.
349  */
350  void copy(const Box& a_regionFrom,
351  const Interval& a_Cd,
352  const Box& a_regionto,
353  const EBData& a_source,
354  const Interval& a_Cs);
355 
356  /// each data holder is defined over the irregular cells of the graph
357  void
358  defineVoFData(const EBGraph& a_graph, const Box& a_region);
359 
360  /// each data holder is defined over the irregular cells of the graph
361  void
362  defineFaceData(const EBGraph& a_graph, const Box& a_region);
363 
364  ///define the whole thing
365  void
366  define(const EBGraph& a_graph,
367  const Vector<IrregNode>& a_irregData,
368  const Box& a_validBox);
369 
370  ///
371  void
372  coarsenVoFs(const EBData& a_fineEBData,
373  const EBGraph& a_fineGraph,
374  const EBGraph& a_coarGraph,
375  const Box& a_validRegion);
376 
377  void
378  coarsenFaces(const EBData& a_fineEBData,
379  const EBGraph& a_fineGraph,
380  const EBGraph& a_coarGraph,
381  const Box& a_validRegion);
382  ///
383  const Real& volFrac(const VolIndex& a_vof) const;
384 
385  ///
386  const Real& areaFrac(const FaceIndex& a_face1) const;
387 
388  ///
389  const RealVect& centroid(const FaceIndex& facein) const;
390 
391  ///
392  const RealVect& centroid(const VolIndex& a_vof) const;
393 
394  ///
395  const RealVect& bndryCentroid(const VolIndex& a_vof) const;
396  const RealVect& bndryCentroid(const VolIndex& a_vof, int face) const;
397 
398  ///
399  const Real& bndryArea(const VolIndex& a_vof) const;
400  const Real& bndryArea(const VolIndex& a_vof, int face) const;
401 
402  ///
403  const RealVect& normal(const VolIndex& a_vof) const;
404  const RealVect& normal(const VolIndex& a_vof, int face) const;
405 
406  /// used by multi-fluid code
407  int facePhase(const VolIndex& a_vof, int face) const ;
408 
409  /// used by multi-fluid code
410  const VolIndex& faceIndex(const VolIndex& a_vof, int face) const ;
411 
412  /// used by multi-fluid code
413  void setFacePhase(const VolIndex& a_vof, int face, int phase);
414 
415  /// used by multi-fluid code
416  void setFaceIndex(const VolIndex& a_vof, int face, int index);
417  ///
418  int numFacePhase(const VolIndex& a_vof) const ;
419 
420  void clearMultiBoundaries();
421  void setBoundaryPhase(int phase);
422  ///
423  EBData(const EBData& a_ebiin);
424 
425  ///
426  /**
427  This is a pointer comparison.
428  */
429  bool operator==(const EBData& a_ebiin);
430 
431  ///
432  EBData& operator=(const EBData& a_ebiin);
433 
434  ///
435  /**
436  This stuff required by LevelData in parallel:
437  */
438  int size(const Box& R, const Interval& comps) const;
439 
440  ///
441  void linearOut(void* buf, const Box& R, const Interval& comps) const;
442 
443  ///
444  void linearIn(void* buf, const Box& R, const Interval& comps);
445 
446  ///
447  void addFullIrregularVoFs(const IntVectSet& a_vofsToChange,
448  const EBGraph& a_newGhostGraph,
449  const BaseIVFAB<VolData>& a_grownData,
450  const EBGraph& a_oldGhostGraph);
451 
452  ///multifluid angels dancing on the heads of pins.
453  void addEmptyIrregularVoFs(const IntVectSet& a_vofsToChange,
454  const EBGraph& a_newGraph);
455 
456  ///
457  void
458  computeNormalsAndBoundaryAreas(const EBGraph& a_graph,
459  const Box& a_validRegion);
460 
462  {
463  return m_implem->getVolData();
464  }
465 
467  {
468  return m_implem->getVolData();
469  }
470 
471  ///
472  static int preAllocatable()
473  {
474  return 2; // dyanmic allocatable.
475  }
476 private:
477 
478  ///
480 
481  friend class EBIndexSpace;
482 };
483 
484 /*******************************/
485 inline const Real& EBData::volFrac(const VolIndex& a_vof) const
486 {
487  return m_implem->volFrac(a_vof);
488 }
489 /*******************************/
490 inline const Real& EBData::bndryArea(const VolIndex& a_vof, int face) const
491 {
492  return m_implem->bndryArea(a_vof, face);
493 }
494 inline const Real& EBData::bndryArea(const VolIndex& a_vof) const
495 {
496  return m_implem->bndryArea(a_vof);
497 }
498 /*******************************/
499 inline const RealVect& EBData::normal(const VolIndex& a_vof, int face) const
500 {
501  return m_implem->normal(a_vof, face);
502 }
503 inline const RealVect& EBData::normal(const VolIndex& a_vof) const
504 {
505  return m_implem->normal(a_vof);
506 }
507 /*******************************/
508 inline const RealVect& EBData::centroid(const VolIndex& a_vof) const
509 {
510  return m_implem->centroid(a_vof);
511 }
512 /*******************************/
513 inline const RealVect& EBData::bndryCentroid(const VolIndex& a_vof, int face) const
514 {
515  return m_implem->bndryCentroid(a_vof, face);
516 }
517 inline const RealVect& EBData::bndryCentroid(const VolIndex& a_vof) const
518 {
519  return m_implem->bndryCentroid(a_vof);
520 }
521 /*******************************/
522 inline const RealVect& EBData::centroid(const FaceIndex& a_face) const
523 {
524  return m_implem->centroid(a_face);
525 }
526 /*******************************/
527 inline const Real& EBData::areaFrac(const FaceIndex& a_face) const
528 {
529  return m_implem->areaFrac(a_face);
530 }
531 /*******************************/
532 
533 #include "NamespaceFooter.H"
534 #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:522
Definition: EBIndexSpace.H:260
Definition: EBData.H:89
static bool s_verbose
Definition: EBData.H:256
Definition: FaceIndex.H:28
RealVect m_normal
Definition: EBData.H:54
BaseIVFAB< VolData > & getVolData()
Definition: EBData.H:232
const Real & bndryArea(const VolIndex &a_vof) const
Definition: EBData.H:494
static int preAllocatable()
Definition: EBData.H:227
Geometric description within a box.
Definition: EBGraph.H:432
bool m_isFaceDataDefined
Definition: EBData.H:265
const int SpaceDim
Definition: SPACE.H:39
Vector< BoundaryData > m_phaseFaces
Definition: EBData.H:70
Definition: EBData.H:321
Definition: EBInterface.H:45
EBDataImplem(const EBDataImplem &ebiin)
Definition: EBData.H:273
const Real & volFrac(const VolIndex &a_vof) const
Definition: EBData.H:485
int linearSize(const T &inputT)
Definition: SPMDI.H:20
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:517
Real m_volFrac
Definition: EBData.H:67
const Real & areaFrac(const FaceIndex &a_face1) const
Definition: EBData.H:527
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:26
RealVect m_volCentroid
Definition: EBData.H:68
Definition: EBData.H:108
int m_bndryPhase
Definition: EBData.H:56
static int preAllocatable()
Definition: EBData.H:472
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:32
const RealVect & normal(const VolIndex &a_vof) const
Definition: EBData.H:503
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
BaseIVFAB< VolData > & getVolData()
Definition: EBData.H:461
const BaseIVFAB< VolData > & getVolData() const
Definition: EBData.H:466
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
RefCountedPtr< EBDataImplem > m_implem
Definition: EBData.H:479
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