00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011
00012
00013 #ifndef _EBINDEXSPACE_H_
00014 #define _EBINDEXSPACE_H_
00015
00016 #include "REAL.H"
00017 #include "IntVect.H"
00018 #include "IntVectSet.H"
00019 #include "DisjointBoxLayout.H"
00020 #include "LevelData.H"
00021 #include "CH_HDF5.H"
00022
00023 #include "VolIndex.H"
00024 #include "FaceIndex.H"
00025 #include "EBISBox.H"
00026 #include "EBISLayout.H"
00027 #include "GeometryService.H"
00028 #include "EBISLevel.H"
00029
00030 #include "NamespaceHeader.H"
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 class EBIndexSpace
00051 {
00052 public:
00053
00054 EBIndexSpace();
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 void
00065 define(const ProblemDomain & a_domain,
00066 const RealVect & a_origin,
00067 const Real & a_dx,
00068 const GeometryService & a_geoserver,
00069 int a_nCellMax = -1,
00070 int a_maxCoarsenings = -1);
00071
00072 #ifdef CH_USE_HDF5
00073
00074 void
00075 define(HDF5Handle & a_handle, ProblemDomain a_finestLevel);
00076
00077
00078 void
00079 define(HDF5Handle & a_handle,
00080 int a_maxCoarsenings = -1);
00081 #endif
00082
00083 void
00084 define(EBISLevel * a_level0,
00085 int a_nCellMax = -1,
00086 int a_maxCoarsenings = -1);
00087
00088 void
00089 define(const ProblemDomain & a_entireDomain,
00090 const RealVect & a_origin,
00091 const Real & a_dx,
00092 const Vector<RefCountedPtr<EBIndexSpace> > & a_patches,
00093 const Vector<IntVect> & a_offsets,
00094 int a_maxCoarsenings = -1);
00095
00096 EBISLevel* buildFirstLevel(const ProblemDomain& a_domain,
00097 const RealVect& a_origin,
00098 const Real& a_dx,
00099 const GeometryService& a_geoserver,
00100 int a_nCellMax,
00101 int a_maxCoarsenings,
00102 bool a_fixRegularNextToMultiValued = true);
00103
00104 EBISLevel* buildNextLevel(const GeometryService & a_geoserver,
00105 int a_nCellMax,
00106 bool a_fixRegularNextToMultiValued = true);
00107
00108
00109 ~EBIndexSpace();
00110
00111
00112
00113
00114
00115
00116
00117
00118 bool setDistributedData()
00119 {
00120 bool was = m_distributedData;
00121 m_distributedData = true;
00122 return was;
00123 }
00124
00125
00126 int numLevels() const;
00127
00128
00129
00130
00131
00132
00133 long long numVoFs(const ProblemDomain& a_domain) const;
00134
00135
00136
00137
00138
00139
00140 Real totalVolFrac(const ProblemDomain& a_domain) const;
00141
00142
00143
00144
00145
00146
00147
00148 int getLevel(const ProblemDomain& a_domain) const;
00149
00150 RealVect getOrigin() const
00151 {
00152 return m_ebisLevel[0]->getOrigin();
00153 }
00154
00155
00156
00157
00158
00159 const ProblemDomain& getBox(int level) const
00160 {
00161 return m_domainLevel[level];
00162 }
00163
00164
00165 void fillEBISLayout(EBISLayout& a_ebis,
00166 const DisjointBoxLayout& a_grids,
00167 const ProblemDomain& a_domain,
00168 const int& a_nghost) const;
00169
00170
00171
00172
00173
00174 bool isDefined() const;
00175
00176
00177 void clear();
00178
00179 int getNCellMax() const;
00180
00181
00182
00183
00184
00185 friend class Chombo_EBIS;
00186
00187 #ifdef CH_USE_HDF5
00188
00189
00190
00191
00192
00193 void
00194 write(HDF5Handle& a_handle,
00195 ProblemDomain a_outputLevel = ProblemDomain()) const;
00196
00197 void
00198 writeInfo(HDF5Handle& handle) const ;
00199
00200
00201
00202
00203
00204
00205
00206 void writeAllLevels(HDF5Handle& a_handle) const;
00207
00208
00209
00210
00211
00212
00213 void readInAllLevels(HDF5Handle & a_handle, ProblemDomain a_finestLevel);
00214
00215 #endif
00216
00217 DisjointBoxLayout getIrregGrids(int level) const
00218 {
00219 return m_ebisLevel[level]->getIrregGrids(m_domainLevel[level]);
00220 }
00221
00222 DisjointBoxLayout getIrregGrids(const ProblemDomain& a_domain) const
00223 {
00224 return m_ebisLevel[getLevel(a_domain)]->getIrregGrids(a_domain);
00225 }
00226
00227 DisjointBoxLayout getFlowGrids(int level) const
00228 {
00229 return m_ebisLevel[level]->getFlowGrids(m_domainLevel[level]);
00230 }
00231
00232
00233 DisjointBoxLayout getGrids(const ProblemDomain& a_domain) const
00234 {
00235 return m_ebisLevel[getLevel(a_domain)]->getGrids();
00236 }
00237
00238 DisjointBoxLayout getFlowGrids(const ProblemDomain& a_domain) const
00239 {
00240 return m_ebisLevel[getLevel(a_domain)]->getFlowGrids(a_domain);
00241 }
00242
00243 DisjointBoxLayout getCoveredGrids(int level) const
00244 {
00245 return m_ebisLevel[level]->getCoveredGrids(m_domainLevel[level]);
00246 }
00247
00248 DisjointBoxLayout getCoveredGrids(const ProblemDomain& a_domain) const
00249 {
00250 return m_ebisLevel[getLevel(a_domain)]->getCoveredGrids(a_domain);
00251 }
00252
00253 DisjointBoxLayout levelGrids(int level) const
00254 {
00255 return m_ebisLevel[level]->m_grids;
00256 }
00257
00258 Real dx(int level) const
00259 {
00260 return m_ebisLevel[level]->m_dx;
00261 }
00262
00263 IntVectSet irregCells(int depth=0) const
00264 {
00265 return m_ebisLevel[depth]->irregCells();
00266 }
00267
00268 void setCellMax(int max)
00269 {
00270 m_nCellMax = max;
00271 }
00272
00273 void resetLevels(int nLevel);
00274
00275 Vector<RefCountedPtr<EBIndexSpace> > connectedComponents();
00276 Vector<RefCountedPtr<EBIndexSpace> > connectedComponentsNew();
00277
00278 RefCountedPtr<EBIndexSpace> biggestConnectedComponent(int & a_numComponents);
00279 RefCountedPtr<EBIndexSpace> biggestConnectedComponentNew(int & a_numComponents);
00280
00281 static bool s_MFSingleBox;
00282
00283 static bool s_useMemoryLoadBalance;
00284
00285 private:
00286 Vector<RefCountedPtr<EBIndexSpace> > findConnectedComponents(int & a_numComponents,
00287 const bool & a_onlyBiggest);
00288 Vector<RefCountedPtr<EBIndexSpace> > findConnectedComponentsNew(int & a_numComponents,
00289 const bool & a_onlyBiggest);
00290
00291 bool setAllConnectedVoFs(Real& a_totalVolFrac,
00292 EBCellFAB& a_curEBCellFAB,
00293 const EBGraph& a_curEBGraph,
00294 const EBISBox& a_curEBISBox,
00295 const VolIndex& a_curVoF,
00296 const VolIndex& a_lastVoF,
00297 const unsigned int& a_curNum);
00298 bool setAllConnectedVoFsNew(Real& a_totalVolFrac,
00299 EBCellFAB& a_curEBCellFAB,
00300 const Box& a_curBox,
00301 const EBGraph& a_curEBGraph,
00302 const EBISBox& a_curEBISBox,
00303 const VolIndex& a_curVoF,
00304 const VolIndex& a_lastVoF,
00305 const unsigned int& a_curNum);
00306
00307 void resetAllConnectedVoFs(EBCellFAB& a_curEBCellFAB,
00308 const EBGraph& a_curEBGraph,
00309 const EBISBox& a_curEBISBox,
00310 const VolIndex& a_curVoF,
00311 const VolIndex& a_lastVoF);
00312 void resetAllConnectedVoFsNew(EBCellFAB& a_curEBCellFAB,
00313 const Box& a_curBox,
00314 const EBGraph& a_curEBGraph,
00315 const EBISBox& a_curEBISBox,
00316 const VolIndex& a_curVoF,
00317 const VolIndex& a_lastVoF);
00318
00319
00320
00321
00322 int m_nCellMax;
00323 bool m_isDefined;
00324
00325 bool m_distributedData;
00326
00327 Vector<EBISLevel*> m_ebisLevel;
00328 Vector<ProblemDomain> m_domainLevel;
00329
00330 int m_nlevels;
00331
00332 static Real s_tolerance;
00333 static bool s_verbose;
00334
00335
00336 void operator=(const EBIndexSpace& ebiin)
00337 {
00338 MayDay::Error("no assignment of EBIndexSpace allowed");
00339 }
00340
00341 EBIndexSpace(const EBIndexSpace& ebiin)
00342 {
00343 MayDay::Error("no copy construction of EBIndexSpace allowed");
00344 }
00345 };
00346
00347 #include "NamespaceFooter.H"
00348
00349 #endif