Chombo + EB  3.2
EBISLevel.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, DTG
12 
13 #ifndef _EBISLEVEL_H_
14 #define _EBISLEVEL_H_
15 
16 #include <map>
17 
18 #include "REAL.H"
19 #include "IntVect.H"
20 #include "IntVectSet.H"
21 #include "IntVectSet.H"
22 #include "DisjointBoxLayout.H"
23 #include "LevelData.H"
24 #include "CH_HDF5.H"
25 
26 #include "VolIndex.H"
27 #include "FaceIndex.H"
28 #include "EBGraph.H"
29 #include "EBData.H"
30 #include "EBISBox.H"
31 #include "EBISLayout.H"
32 #include "EBIndexSpace.H"
33 #include "GeometryService.H"
34 
35 #include "NamespaceHeader.H"
36 
37 typedef std::map<DisjointBoxLayout, EBISLayout> dmap;
38 
39 class EBIndexSpace;
40 
41 ///singleton version of EBIndexSpace.
43 {
44 private:
45  ///
46  /**
47  This is NULL until the first time
48  instance() is called.
49  On the first time it is called it
50  is set to new EBIndexSpace();
51  After that it points to the same
52  thing.
53  */
55 
57  {;}
58 
60  {;}
61 
62  ///if you want to sneak an existing EBIS into the singleton.
63  static bool s_aliased;
64 public:
65  ///
66  /**
67  Return a pointer to the singleton
68  EBIndexSpace. Until this is called
69  once, the singleton is null. See
70  Design patterns for why this is done
71  this way.
72  */
73  static EBIndexSpace* instance();
74 
75  ///
76  static void alias(const EBIndexSpace* a_input);
77 };
78 
79 ///
80 /**
81  EBISLevel represents the geometric information
82  of the domain at a particular level of refinement.
83 */
84 class EBISLevel
85 {
86 public:
87  static int s_ebislGhost;
88  void dumpDebug(const string& a_string);
89 
90  void coarsenVoFs(EBISLevel& a_fineEBIS);
91 
92  void fixFineToCoarse(EBISLevel& a_fineEBIS);
93 
94  void coarsenFaces(EBISLevel& a_fineEBIS);
95 
96  long long numVoFsOnProc() const;
97 
98  Real totalVolFracOnProc() const;
99 
100  void levelStitch(EBISLevel& a_otherPhase,
101  const EBISLevel* a_fineThisPtr,
102  const EBISLevel* a_fineOtherPtr); // MF Addition bvs
103 
104  void reconcileIrreg(EBISLevel & a_otherPhase);
105 
106  void cellStitch(EBData& a_ebdataCoarA,
107  EBData& a_ebdataCoarB,
108  const EBGraph& a_ebgrapCoarA,
109  const EBGraph& a_ebgrapCoarB,
110  const EBISBox& a_ebisbxFineA,
111  const EBISBox& a_ebisbxFineB,
112  const IntVect& a_iv,
113  const int& a_aphase,
114  const int& a_bphase);
115  EBISLevel();
116 
117  ///
118  /**
119  Defines the level. Calls the geoserver
120  to fill the layout with geometric information.
121  */
122  EBISLevel(const ProblemDomain & a_domain,
123  const RealVect & a_origin,
124  const Real & a_dx,
125  const GeometryService & a_geoserver,
126  int a_nCellMax,
127  const bool & a_fixRegularNextToMultiValued = true);
128 
129  ///
130  /**
131  Defines the level from a finer level
132  (factor of two refinement ratio).
133  Fills in all the coarse-fine information
134  in both levels.
135  */
136  EBISLevel(EBISLevel & a_finerLevel,
137  const GeometryService & a_geoserver,
138  int a_nCellMax,
139  const bool & a_fixRegularNextToMultiValued = true);
140 
141  void checkGraph() const;
142 #ifdef CH_USE_HDF5
143  /// read from file from top level only file
144  EBISLevel(HDF5Handle& handle);
145 
146  ///// this is the one used by the writeAlllevels crowd
147  EBISLevel(HDF5Handle& a_handle,
148  const int& a_levelNumber);
149 
150  //writes out top level only
151  void write(HDF5Handle& a_handle) const;
152 
153  ///writes the given level for writeAllLevels
154  void write(HDF5Handle& a_handle,
155  const int& a_levelNumber) const;
156 #endif
157 
158  ///
159  /**
160  Checks to see the vofs are in the correct cells.
161  Checks to see that the faces are over the correct cells.
162  Checks that volume fractions, area fractions are positive.
163  Bail out with MayDay::Error if anything fails.
164  */
165  void sanityCheck(const EBIndexSpace* const a_ebisPtr = Chombo_EBIS::instance());
166 
167  ///
168  void fillEBISLayout(EBISLayout& a_ebis,
169  const DisjointBoxLayout& a_grids,
170  const int& a_nghost) const;
171 
172  ~EBISLevel();
173 
174  const ProblemDomain& getDomain() const;
175 
176  const DisjointBoxLayout& getGrids() const;
177 
178  DisjointBoxLayout getIrregGrids(const ProblemDomain& a_domain) const;
179 
180  DisjointBoxLayout getFlowGrids(const ProblemDomain& a_domain) const;
181 
182  DisjointBoxLayout getCoveredGrids(const ProblemDomain& a_domain) const;
183 
184  IntVectSet irregCells() const;
185 
186  const Real& getDX() const;
187 
188  const RealVect& getOrigin() const;
189 
190  ///
191  void fixRegularNextToMultiValued();
192 
193  void clearMultiBoundaries();
194  void setBoundaryPhase(int phase);
195 
196  void getGraphSummary(long long & a_irrVoFs,
197  long long & a_arcs,
198  long long & a_multiVoFs,
199  long long & a_zeroVoFs,
200  long long & a_zeroVoFsArcs);
201 
202  void printGraphSummary(char const * a_prefix);
203 
204  int m_phase;
205 
206  static bool s_recursive;
207 
208 private:
209 
210  ///
211  int m_level;
212 
213  ///
215 
216  ///
218 
219  ///
221 
222  ///
224 
225  ///
227 
228  ///
230 
231  ///whether this has higher order moment info
233 
234  Real m_tolerance; // used in Multifluid face matching algorithm.
235 
236  //mutable std::map<int, dmap> m_cache;
237  mutable dmap m_cache;
238  mutable int m_cacheMisses, m_cacheHits, m_cacheStale;
239 
240  void dumpCache() const;
241 
243  static bool s_verbose;
244 
245 
246  static void
247  defineGraphFromGeo(LevelData<EBGraph> & a_graph,
248  LayoutData<Vector<IrregNode> > & a_allNodes,
249  const GeometryService & a_geoserver,
250  const DisjointBoxLayout & a_grids,
251  const ProblemDomain & a_domain,
252  const RealVect & a_origin,
253  const Real & a_dx,
254  bool a_hasMoments);
255 
256  //make grids for this level.
257  static void makeBoxes(Vector<Box>& a_boxes,
259  const Box& a_region,
260  const ProblemDomain& a_domain,
261  const GeometryService& a_geoserver,
262  const RealVect& a_origin,
263  const Real& a_dx,
264  bool a_hasMoments,
265  const int a_ncellmax);
266 
267  static
268  void makeLoads(Vector<unsigned long long>& a_loads,
269  Vector<Box>& a_boxes,
270  const Box& a_region,
271  const ProblemDomain& a_domain,
272  const GeometryService& a_geoserver,
273  const RealVect& a_origin,
274  const Real& a_dx,
275  bool a_hasMoments,
276  const int a_ncellmax);
277 
278  static void makeBoxes(std::list<Box>& a_boxes,
279  const Box& a_region,
280  const ProblemDomain& a_domain,
281  const GeometryService& a_geoserver,
282  const RealVect& a_origin,
283  const Real& a_dx,
284  bool a_hasMoments,
285  const int a_ncellmax);
286 
287  //these are disallowed
288  void operator=(const EBISLevel& ebiin)
289  {
290  MayDay::Error("EBISLevel::operator= not allowed");
291  }
292 
293  EBISLevel(const EBISLevel& ebiin)
294  {
295  MayDay::Error("EBISLevel::copy constructor not allowed");
296  }
297 
298  bool match(const Real& a_a,
299  const Real& a_b) const;
300 
301  bool match(const RealVect& a_a,
302  const RealVect& a_b) const;
303 
304  void refreshCache() const;
305 
306  friend class EBIndexSpace;
307 };
308 
309 inline bool EBISLevel::match(const Real& a_a,
310  const Real& a_b) const
311 {
312  return (a_a < (a_b + m_tolerance)) && (a_a > (a_b - m_tolerance));
313 }
314 
315 inline bool EBISLevel::match(const RealVect& a_a,
316  const RealVect& a_b) const
317 {
318  return D_TERM6( (a_a[0] < (a_b[0] + m_tolerance)) &&
319  (a_a[0] > (a_b[0] - m_tolerance)),
320  &&
321  (a_a[1] < (a_b[1] + m_tolerance)) &&
322  (a_a[1] > (a_b[1] - m_tolerance)),
323  &&
324  (a_a[2] < (a_b[2] + m_tolerance)) &&
325  (a_a[2] > (a_b[2] - m_tolerance)),
326  &&
327  (a_a[3] < (a_b[3] + m_tolerance)) &&
328  (a_a[3] > (a_b[3] - m_tolerance)),
329  &&
330  (a_a[4] < (a_b[4] + m_tolerance)) &&
331  (a_a[4] > (a_b[4] - m_tolerance)),
332  &&
333  (a_a[5] < (a_b[5] + m_tolerance)) &&
334  (a_a[5] > (a_b[5] - m_tolerance)));
335 }
336 
337 #include "NamespaceFooter.H"
338 
339 #endif
#define D_TERM6(a, b, c, d, e, f)
Definition: CHArray.H:40
An irregular domain on an integer lattice.
Definition: IntVectSet.H:44
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
Definition: EBIndexSpace.H:50
Chombo_EBIS()
Definition: EBISLevel.H:56
dmap m_cache
Definition: EBISLevel.H:237
one dimensional dynamic array
Definition: Vector.H:53
std::map< DisjointBoxLayout, EBISLayout > dmap
Definition: EBISLevel.H:37
Data that maintains a one-to-one mapping of T to the boxes in a BoxLayout.
Definition: BoxLayout.H:26
Definition: EBISBox.H:46
DisjointBoxLayout m_grids
Definition: EBISLevel.H:214
~Chombo_EBIS()
Definition: EBISLevel.H:59
Definition: EBISLevel.H:84
RealVect m_origin
Definition: EBISLevel.H:220
singleton version of EBIndexSpace.
Definition: EBISLevel.H:42
int m_cacheStale
Definition: EBISLevel.H:238
Geometric description within a box.
Definition: EBGraph.H:427
Definition: EBData.H:503
LevelData< EBGraph > m_graph
Definition: EBISLevel.H:226
static void alias(const EBIndexSpace *a_input)
EBISLevel(const EBISLevel &ebiin)
Definition: EBISLevel.H:293
static EBIndexSpace * instance()
static bool s_aliased
if you want to sneak an existing EBIS into the singleton.
Definition: EBISLevel.H:63
static bool s_recursive
Definition: EBISLevel.H:206
LevelData< EBData > m_data
Definition: EBISLevel.H:229
double Real
Definition: REAL.H:33
int m_level
Definition: EBISLevel.H:211
Definition: GeometryService.H:37
ProblemDomain m_domain
Definition: EBISLevel.H:217
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
bool m_hasMoments
whether this has higher order moment info
Definition: EBISLevel.H:232
static void Error(const char *const a_msg=m_nullString, int m_exitCode=CH_DEFAULT_ERROR_CODE)
Print out message to cerr and exit with the specified exit code.
int write(HDF5Handle &a_handle, const BoxLayout &a_layout, const std::string &name="boxes")
writes BoxLayout to HDF5 file.
static EBIndexSpace * s_instance
Definition: EBISLevel.H:54
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
Real m_dx
Definition: EBISLevel.H:223
static Real s_tolerance
Definition: EBISLevel.H:242
Real m_tolerance
Definition: EBISLevel.H:234
Handle to a particular group in an HDF file.
Definition: CH_HDF5.H:294
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Definition: EBISLayout.H:39
static int s_ebislGhost
Definition: EBISLevel.H:87
bool match(const Real &a_a, const Real &a_b) const
Definition: EBISLevel.H:309
void operator=(const EBISLevel &ebiin)
Definition: EBISLevel.H:288
static bool s_verbose
Definition: EBISLevel.H:243
int m_phase
Definition: EBISLevel.H:204