Chombo + EB  3.2
EBIndexSpace.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 _EBINDEXSPACE_H_
14 #define _EBINDEXSPACE_H_
15 
16 #include "REAL.H"
17 #include "IntVect.H"
18 #include "IntVectSet.H"
19 #include "DisjointBoxLayout.H"
20 #include "LevelData.H"
21 #include "CH_HDF5.H"
22 
23 #include "VolIndex.H"
24 #include "FaceIndex.H"
25 #include "EBISBox.H"
26 #include "EBISLayout.H"
27 #include "GeometryService.H"
28 #include "EBISLevel.H"
29 
30 #include "NamespaceHeader.H"
31 
32 ///
33 /**
34  EBIndexSpace represents the geometric information
35  of the domain. It should be generated through
36  the Chombo_EBIS class. This follows the singleton
37  pattern.
38 
39  Construction of the EBIndexSpace can follow one of methods
40  1. From a previously written out HDF5 file. This is a representation of
41  the EBIndexSpace at the finest level. When this is read back into a running
42  application the EBIndexSpace at the coarser levels is regenerated on
43  construction
44  2. As a GeometryService. The base class for Geometry objects.
45  3. As a Workshop object that reads the finest level EB boxes from the
46  EBIndexSpace itself and fills in the data structure as it accepts it.
47  4. As a Worshop object that has an already defined data decomposition
48 
49 */
51 {
52 public:
53 
54  EBIndexSpace();
55 
56  ///
57  /**
58  If a_ncellMax is set, that is the max width of
59  an internal grid. Otherwise use defaults
60  of (16 in 3D, 64 in 2d)
61 
62  This
63  */
64  void
65  define(const ProblemDomain & a_domain,
66  const RealVect & a_origin,
67  const Real & a_dx,
68  const GeometryService & a_geoserver,
69  int a_nCellMax = -1,
70  int a_maxCoarsenings = -1);
71 
72 #ifdef CH_USE_HDF5
73  /// reads in all levels from finest level down
74  void
75  define(HDF5Handle & a_handle, ProblemDomain a_finestLevel);
76 
77  /// defines from one level and then does coarsening
78  void
79  define(HDF5Handle & a_handle,
80  int a_maxCoarsenings = -1);
81 #endif
82 
83  void
84  define(EBISLevel * a_level0,
85  int a_nCellMax = -1,
86  int a_maxCoarsenings = -1);
87 
88  void
89  define(const ProblemDomain & a_entireDomain,
90  const RealVect & a_origin,
91  const Real & a_dx,
92  const Vector<RefCountedPtr<EBIndexSpace> > & a_patches,
93  const Vector<IntVect> & a_offsets,
94  int a_maxCoarsenings = -1);
95 
96  EBISLevel* buildFirstLevel(const ProblemDomain& a_domain,
97  const RealVect& a_origin,
98  const Real& a_dx,
99  const GeometryService& a_geoserver,
100  int a_nCellMax,
101  int a_maxCoarsenings,
102  bool a_fixRegularNextToMultiValued = true);
103 
104  EBISLevel* buildNextLevel(const GeometryService & a_geoserver,
105  int a_nCellMax,
106  bool a_fixRegularNextToMultiValued = true);
107 
108  ///
109  ~EBIndexSpace();
110 
111  ///
112  /**
113  Set a flag that indicates the data defining the EB is distributed.
114  This will signal EBISLevel to hand grid generation off to the
115  GeometryService. Function returns previous value of m_distributedData.
116  Call this before define() if this functionality is desired.
117  */
119  {
120  bool was = m_distributedData;
121  m_distributedData = true;
122  return was;
123  }
124 
125  ///
126  int numLevels() const;
127 
128  ///
129  /**
130  Get the number of vofs over the entire domain.
131  This is blocking as a broadcast and gather are required.
132  */
133  long long numVoFs(const ProblemDomain& a_domain) const;
134 
135  ///
136  /**
137  Get the total of the volume fractions over the entire domain.
138  This is blocking as a broadcast and gather are required.
139  */
140  Real totalVolFrac(const ProblemDomain& a_domain) const;
141 
142  ///
143  /**
144  return level index of domain.
145  return -1 if a_domain does not
146  correspond to any refinement of EBIS.
147  */
148  int getLevel(const ProblemDomain& a_domain) const;
149 
151  {
152  return m_ebisLevel[0]->getOrigin();
153  }
154 
155  ///
156  /**
157  returns the problem domain box at a level of refinement
158  */
159  const ProblemDomain& getBox(int level) const
160  {
161  return m_domainLevel[level];
162  }
163 
164  ///
165  void fillEBISLayout(EBISLayout& a_ebis,
166  const DisjointBoxLayout& a_grids,
167  const ProblemDomain& a_domain,
168  const int& a_nghost) const;
169 
170  ///
171  /**
172  Return true if the define function has been called.
173  */
174  bool isDefined() const;
175 
176  ///
177  void clear();
178 
179  int getNCellMax() const;
180  ///
181  /**
182  This makes Chombo_EBIS be the only function
183  that can call the private constructor.
184  */
185  friend class Chombo_EBIS;
186 
187 #ifdef CH_USE_HDF5
188  ///
189  /**
190  Writes out finest level as a default. Writes at the level you are domain
191  you want if a_outputLevel is defined.
192  */
193  void
194  write(HDF5Handle& a_handle,
195  ProblemDomain a_outputLevel = ProblemDomain()) const;
196 
197  void
198  writeInfo(HDF5Handle& handle) const ;
199 
200  ///
201  /**
202  Outputs ALL levels of the EBIS.
203  this is the one to use if you want to do all definition through
204  the file (no coarsening).
205  */
206  void writeAllLevels(HDF5Handle& a_handle) const;
207 
208  ///
209  /**
210  Define entirely from the input file. a_finestLevel can be a coarsening
211  of the finest level in the file. No coarsening algorithm is done.
212  */
213  void readInAllLevels(HDF5Handle & a_handle, ProblemDomain a_finestLevel);
214 
215 #endif
216 
218  {
219  return m_ebisLevel[level]->getIrregGrids(m_domainLevel[level]);
220  }
221 
223  {
224  return m_ebisLevel[getLevel(a_domain)]->getIrregGrids(a_domain);
225  }
226 
228  {
229  return m_ebisLevel[level]->getFlowGrids(m_domainLevel[level]);
230  }
231 
232  ///
233  DisjointBoxLayout getGrids(const ProblemDomain& a_domain) const
234  {
235  return m_ebisLevel[getLevel(a_domain)]->getGrids();
236  }
237 
239  {
240  return m_ebisLevel[getLevel(a_domain)]->getFlowGrids(a_domain);
241  }
242 
244  {
245  return m_ebisLevel[level]->getCoveredGrids(m_domainLevel[level]);
246  }
247 
249  {
250  return m_ebisLevel[getLevel(a_domain)]->getCoveredGrids(a_domain);
251  }
252 
253  DisjointBoxLayout levelGrids(int level) const
254  {
255  return m_ebisLevel[level]->m_grids;
256  }
257 
258  Real dx(int level) const
259  {
260  return m_ebisLevel[level]->m_dx;
261  }
262 
263  IntVectSet irregCells(int depth=0) const
264  {
265  return m_ebisLevel[depth]->irregCells();
266  }
267 
268  void setCellMax(int max)
269  {
270  m_nCellMax = max;
271  }
272 
273  void resetLevels(int nLevel);
274 
277 
280 
281  static bool s_MFSingleBox;
282 
284 
285 private:
287  const bool & a_onlyBiggest);
289  const bool & a_onlyBiggest);
290 
291  bool setAllConnectedVoFs(Real& a_totalVolFrac,
292  EBCellFAB& a_curEBCellFAB,
293  const EBGraph& a_curEBGraph,
294  const EBISBox& a_curEBISBox,
295  const VolIndex& a_curVoF,
296  const VolIndex& a_lastVoF,
297  const unsigned int& a_curNum);
298  bool setAllConnectedVoFsNew(Real& a_totalVolFrac,
299  EBCellFAB& a_curEBCellFAB,
300  const Box& a_curBox,
301  const EBGraph& a_curEBGraph,
302  const EBISBox& a_curEBISBox,
303  const VolIndex& a_curVoF,
304  const VolIndex& a_lastVoF,
305  const unsigned int& a_curNum);
306 
307  void resetAllConnectedVoFs(EBCellFAB& a_curEBCellFAB,
308  const EBGraph& a_curEBGraph,
309  const EBISBox& a_curEBISBox,
310  const VolIndex& a_curVoF,
311  const VolIndex& a_lastVoF);
312  void resetAllConnectedVoFsNew(EBCellFAB& a_curEBCellFAB,
313  const Box& a_curBox,
314  const EBGraph& a_curEBGraph,
315  const EBISBox& a_curEBISBox,
316  const VolIndex& a_curVoF,
317  const VolIndex& a_lastVoF);
318 
319  //this is private to force the singleton thing.
320  //EBIndexSpace();
321 
324 
326 
329 
331 
333  static bool s_verbose;
334 
335  //disallowed for performance reasons
336  void operator=(const EBIndexSpace& ebiin)
337  {
338  MayDay::Error("no assignment of EBIndexSpace allowed");
339  }
340 
342  {
343  MayDay::Error("no copy construction of EBIndexSpace allowed");
344  }
345 };
346 
347 #include "NamespaceFooter.H"
348 
349 #endif
int m_nlevels
Definition: EBIndexSpace.H:330
void resetAllConnectedVoFs(EBCellFAB &a_curEBCellFAB, const EBGraph &a_curEBGraph, const EBISBox &a_curEBISBox, const VolIndex &a_curVoF, const VolIndex &a_lastVoF)
int numLevels() const
Real totalVolFrac(const ProblemDomain &a_domain) const
Vector< RefCountedPtr< EBIndexSpace > > findConnectedComponentsNew(int &a_numComponents, const bool &a_onlyBiggest)
static bool s_verbose
Definition: EBIndexSpace.H:333
long long numVoFs(const ProblemDomain &a_domain) const
Vector< EBISLevel * > m_ebisLevel
Definition: EBIndexSpace.H:327
A reference-counting handle class.
Definition: RefCountedPtr.H:173
Vector< RefCountedPtr< EBIndexSpace > > connectedComponents()
An irregular domain on an integer lattice.
Definition: IntVectSet.H:44
EBISLevel * buildNextLevel(const GeometryService &a_geoserver, int a_nCellMax, bool a_fixRegularNextToMultiValued=true)
void resetLevels(int nLevel)
void fillEBISLayout(EBISLayout &a_ebis, const DisjointBoxLayout &a_grids, const ProblemDomain &a_domain, const int &a_nghost) const
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
Definition: EBIndexSpace.H:50
static Real s_tolerance
Definition: EBIndexSpace.H:332
one dimensional dynamic array
Definition: Vector.H:53
DisjointBoxLayout getFlowGrids(int level) const
Definition: EBIndexSpace.H:227
EBISLevel * buildFirstLevel(const ProblemDomain &a_domain, const RealVect &a_origin, const Real &a_dx, const GeometryService &a_geoserver, int a_nCellMax, int a_maxCoarsenings, bool a_fixRegularNextToMultiValued=true)
int m_nCellMax
Definition: EBIndexSpace.H:322
Definition: EBISBox.H:46
Definition: EBISLevel.H:84
bool m_isDefined
Definition: EBIndexSpace.H:323
bool isDefined() const
bool setDistributedData()
Definition: EBIndexSpace.H:118
singleton version of EBIndexSpace.
Definition: EBISLevel.H:42
RefCountedPtr< EBIndexSpace > biggestConnectedComponent(int &a_numComponents)
Vector< ProblemDomain > m_domainLevel
Definition: EBIndexSpace.H:328
Geometric description within a box.
Definition: EBGraph.H:427
void readInAllLevels(HDF5Handle &a_handle, ProblemDomain a_finestLevel)
Vector< RefCountedPtr< EBIndexSpace > > connectedComponentsNew()
DisjointBoxLayout getGrids(const ProblemDomain &a_domain) const
Definition: EBIndexSpace.H:233
void operator=(const EBIndexSpace &ebiin)
Definition: EBIndexSpace.H:336
static bool s_useMemoryLoadBalance
Definition: EBIndexSpace.H:283
Definition: EBCellFAB.H:29
DisjointBoxLayout getCoveredGrids(int level) const
Definition: EBIndexSpace.H:243
double Real
Definition: REAL.H:33
Definition: GeometryService.H:37
IndexTM< T, N > max(const IndexTM< T, N > &a_p1, const IndexTM< T, N > &a_p2)
Definition: IndexTMI.H:401
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
bool setAllConnectedVoFs(Real &a_totalVolFrac, EBCellFAB &a_curEBCellFAB, const EBGraph &a_curEBGraph, const EBISBox &a_curEBISBox, const VolIndex &a_curVoF, const VolIndex &a_lastVoF, const unsigned int &a_curNum)
EBIndexSpace(const EBIndexSpace &ebiin)
Definition: EBIndexSpace.H:341
void define(const ProblemDomain &a_domain, const RealVect &a_origin, const Real &a_dx, const GeometryService &a_geoserver, int a_nCellMax=-1, int a_maxCoarsenings=-1)
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.
bool m_distributedData
Definition: EBIndexSpace.H:325
DisjointBoxLayout levelGrids(int level) const
Definition: EBIndexSpace.H:253
RefCountedPtr< EBIndexSpace > biggestConnectedComponentNew(int &a_numComponents)
Real dx(int level) const
Definition: EBIndexSpace.H:258
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
void write(HDF5Handle &a_handle, ProblemDomain a_outputLevel=ProblemDomain()) const
void setCellMax(int max)
Definition: EBIndexSpace.H:268
DisjointBoxLayout getIrregGrids(int level) const
Definition: EBIndexSpace.H:217
Handle to a particular group in an HDF file.
Definition: CH_HDF5.H:292
DisjointBoxLayout getFlowGrids(const ProblemDomain &a_domain) const
Definition: EBIndexSpace.H:238
IntVectSet irregCells(int depth=0) const
Definition: EBIndexSpace.H:263
Volume of Fluid Index.
Definition: VolIndex.H:31
void resetAllConnectedVoFsNew(EBCellFAB &a_curEBCellFAB, const Box &a_curBox, const EBGraph &a_curEBGraph, const EBISBox &a_curEBISBox, const VolIndex &a_curVoF, const VolIndex &a_lastVoF)
DisjointBoxLayout getCoveredGrids(const ProblemDomain &a_domain) const
Definition: EBIndexSpace.H:248
int getLevel(const ProblemDomain &a_domain) const
Definition: EBISLayout.H:39
Vector< RefCountedPtr< EBIndexSpace > > findConnectedComponents(int &a_numComponents, const bool &a_onlyBiggest)
const ProblemDomain & getBox(int level) const
Definition: EBIndexSpace.H:159
void writeInfo(HDF5Handle &handle) const
static bool s_MFSingleBox
Definition: EBIndexSpace.H:281
bool setAllConnectedVoFsNew(Real &a_totalVolFrac, EBCellFAB &a_curEBCellFAB, const Box &a_curBox, const EBGraph &a_curEBGraph, const EBISBox &a_curEBISBox, const VolIndex &a_curVoF, const VolIndex &a_lastVoF, const unsigned int &a_curNum)
DisjointBoxLayout getIrregGrids(const ProblemDomain &a_domain) const
Definition: EBIndexSpace.H:222
int getNCellMax() const
void writeAllLevels(HDF5Handle &a_handle) const
RealVect getOrigin() const
Definition: EBIndexSpace.H:150