Chombo + EB + MF  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  Real m_tolerance; // used in Multifluid face matching algorithm.
232 
233  //mutable std::map<int, dmap> m_cache;
234  mutable dmap m_cache;
235  mutable int m_cacheMisses, m_cacheHits, m_cacheStale;
236 
237  void dumpCache() const;
238 
240  static bool s_verbose;
241 
242 
243  static void
244  defineGraphFromGeo(LevelData<EBGraph> & a_graph,
245  LayoutData<Vector<IrregNode> > & a_allNodes,
246  const GeometryService & a_geoserver,
247  const DisjointBoxLayout & a_grids,
248  const ProblemDomain & a_domain,
249  const RealVect & a_origin,
250  const Real & a_dx);
251 
252  //make grids for this level.
253  static void makeBoxes(Vector<Box>& a_boxes,
255  const Box& a_region,
256  const ProblemDomain& a_domain,
257  const GeometryService& a_geoserver,
258  const RealVect& a_origin,
259  const Real& a_dx,
260  const int a_ncellmax);
261 
262  static
263  void makeLoads(Vector<unsigned long long>& a_loads,
264  Vector<Box>& a_boxes,
265  const Box& a_region,
266  const ProblemDomain& a_domain,
267  const GeometryService& a_geoserver,
268  const RealVect& a_origin,
269  const Real& a_dx,
270  const int a_ncellmax);
271 
272  static void makeBoxes(std::list<Box>& a_boxes,
273  const Box& a_region,
274  const ProblemDomain& a_domain,
275  const GeometryService& a_geoserver,
276  const RealVect& a_origin,
277  const Real& a_dx,
278  const int a_ncellmax);
279 
280  //these are disallowed
281  void operator=(const EBISLevel& ebiin)
282  {
283  MayDay::Error("EBISLevel::operator= not allowed");
284  }
285 
286  EBISLevel(const EBISLevel& ebiin)
287  {
288  MayDay::Error("EBISLevel::copy constructor not allowed");
289  }
290 
291  bool match(const Real& a_a,
292  const Real& a_b) const;
293 
294  bool match(const RealVect& a_a,
295  const RealVect& a_b) const;
296 
297  void refreshCache() const;
298 
299  friend class EBIndexSpace;
300 };
301 
302 inline bool EBISLevel::match(const Real& a_a,
303  const Real& a_b) const
304 {
305  return (a_a < (a_b + m_tolerance)) && (a_a > (a_b - m_tolerance));
306 }
307 
308 inline bool EBISLevel::match(const RealVect& a_a,
309  const RealVect& a_b) const
310 {
311  return D_TERM6( (a_a[0] < (a_b[0] + m_tolerance)) &&
312  (a_a[0] > (a_b[0] - m_tolerance)),
313  &&
314  (a_a[1] < (a_b[1] + m_tolerance)) &&
315  (a_a[1] > (a_b[1] - m_tolerance)),
316  &&
317  (a_a[2] < (a_b[2] + m_tolerance)) &&
318  (a_a[2] > (a_b[2] - m_tolerance)),
319  &&
320  (a_a[3] < (a_b[3] + m_tolerance)) &&
321  (a_a[3] > (a_b[3] - m_tolerance)),
322  &&
323  (a_a[4] < (a_b[4] + m_tolerance)) &&
324  (a_a[4] > (a_b[4] - m_tolerance)),
325  &&
326  (a_a[5] < (a_b[5] + m_tolerance)) &&
327  (a_a[5] > (a_b[5] - m_tolerance)));
328 }
329 
330 #include "NamespaceFooter.H"
331 
332 #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:234
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:235
Geometric description within a box.
Definition: EBGraph.H:427
Definition: EBData.H:322
LevelData< EBGraph > m_graph
Definition: EBISLevel.H:226
static void alias(const EBIndexSpace *a_input)
EBISLevel(const EBISLevel &ebiin)
Definition: EBISLevel.H:286
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
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:469
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:239
Real m_tolerance
Definition: EBISLevel.H:231
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:302
void operator=(const EBISLevel &ebiin)
Definition: EBISLevel.H:281
static bool s_verbose
Definition: EBISLevel.H:240
int m_phase
Definition: EBISLevel.H:204