00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011
00012
00013 #ifndef _EBISLEVEL_H_
00014 #define _EBISLEVEL_H_
00015
00016 #include <map>
00017
00018 #include "REAL.H"
00019 #include "IntVect.H"
00020 #include "IntVectSet.H"
00021 #include "IntVectSet.H"
00022 #include "DisjointBoxLayout.H"
00023 #include "LevelData.H"
00024 #include "CH_HDF5.H"
00025
00026 #include "VolIndex.H"
00027 #include "FaceIndex.H"
00028 #include "EBGraph.H"
00029 #include "EBData.H"
00030 #include "EBISBox.H"
00031 #include "EBISLayout.H"
00032 #include "EBIndexSpace.H"
00033 #include "GeometryService.H"
00034
00035 #include "NamespaceHeader.H"
00036
00037 typedef std::map<DisjointBoxLayout, EBISLayout> dmap;
00038
00039 class EBIndexSpace;
00040
00041
00042 class Chombo_EBIS
00043 {
00044 private:
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 static EBIndexSpace* s_instance;
00055
00056 Chombo_EBIS()
00057 {;}
00058
00059 ~Chombo_EBIS()
00060 {;}
00061
00062
00063 static bool s_aliased;
00064 public:
00065
00066
00067
00068
00069
00070
00071
00072
00073 static EBIndexSpace* instance();
00074
00075
00076 static void alias(const EBIndexSpace* a_input);
00077 };
00078
00079
00080
00081
00082
00083
00084 class EBISLevel
00085 {
00086 public:
00087 static int s_ebislGhost;
00088 void dumpDebug(const string& a_string);
00089
00090 void coarsenVoFs(EBISLevel& a_fineEBIS);
00091
00092 void fixFineToCoarse(EBISLevel& a_fineEBIS);
00093
00094 void coarsenFaces(EBISLevel& a_fineEBIS);
00095
00096 long long numVoFsOnProc() const;
00097
00098 Real totalVolFracOnProc() const;
00099
00100 void levelStitch(EBISLevel& a_otherPhase,
00101 const EBISLevel* a_fineThisPtr,
00102 const EBISLevel* a_fineOtherPtr);
00103
00104 void reconcileIrreg(EBISLevel & a_otherPhase);
00105
00106 void cellStitch(EBData& a_ebdataCoarA,
00107 EBData& a_ebdataCoarB,
00108 const EBGraph& a_ebgrapCoarA,
00109 const EBGraph& a_ebgrapCoarB,
00110 const EBISBox& a_ebisbxFineA,
00111 const EBISBox& a_ebisbxFineB,
00112 const IntVect& a_iv,
00113 const int& a_aphase,
00114 const int& a_bphase);
00115 EBISLevel();
00116
00117
00118
00119
00120
00121
00122 EBISLevel(const ProblemDomain & a_domain,
00123 const RealVect & a_origin,
00124 const Real & a_dx,
00125 const GeometryService & a_geoserver,
00126 int a_nCellMax,
00127 const bool & a_fixRegularNextToMultiValued = true);
00128
00129
00130
00131
00132
00133
00134
00135
00136 EBISLevel(EBISLevel & a_finerLevel,
00137 const GeometryService & a_geoserver,
00138 int a_nCellMax,
00139 const bool & a_fixRegularNextToMultiValued = true);
00140
00141 void checkGraph() const;
00142 #ifdef CH_USE_HDF5
00143
00144 EBISLevel(HDF5Handle& handle);
00145
00146
00147 EBISLevel(HDF5Handle& a_handle,
00148 const int& a_levelNumber);
00149
00150
00151 void write(HDF5Handle& a_handle) const;
00152
00153
00154 void write(HDF5Handle& a_handle,
00155 const int& a_levelNumber) const;
00156 #endif
00157
00158
00159
00160
00161
00162
00163
00164
00165 void sanityCheck(const EBIndexSpace* const a_ebisPtr = Chombo_EBIS::instance());
00166
00167
00168 void fillEBISLayout(EBISLayout& a_ebis,
00169 const DisjointBoxLayout& a_grids,
00170 const int& a_nghost) const;
00171
00172 ~EBISLevel();
00173
00174 const ProblemDomain& getDomain() const;
00175
00176 const DisjointBoxLayout& getGrids() const;
00177
00178 DisjointBoxLayout getIrregGrids(const ProblemDomain& a_domain) const;
00179
00180 DisjointBoxLayout getFlowGrids(const ProblemDomain& a_domain) const;
00181
00182 DisjointBoxLayout getCoveredGrids(const ProblemDomain& a_domain) const;
00183
00184 IntVectSet irregCells() const;
00185
00186 const Real& getDX() const;
00187
00188 const RealVect& getOrigin() const;
00189
00190
00191 void fixRegularNextToMultiValued();
00192
00193 void clearMultiBoundaries();
00194 void setBoundaryPhase(int phase);
00195
00196 void getGraphSummary(long long & a_irrVoFs,
00197 long long & a_arcs,
00198 long long & a_multiVoFs,
00199 long long & a_zeroVoFs,
00200 long long & a_zeroVoFsArcs);
00201
00202 void printGraphSummary(char const * a_prefix);
00203
00204 int m_phase;
00205
00206 static bool s_recursive;
00207
00208 private:
00209
00210
00211 int m_level;
00212
00213
00214 DisjointBoxLayout m_grids;
00215
00216
00217 ProblemDomain m_domain;
00218
00219
00220 RealVect m_origin;
00221
00222
00223 Real m_dx;
00224
00225
00226 LevelData<EBGraph> m_graph;
00227
00228
00229 LevelData<EBData> m_data;
00230
00231
00232 bool m_hasMoments;
00233
00234 Real m_tolerance;
00235
00236
00237 mutable dmap m_cache;
00238 mutable int m_cacheMisses, m_cacheHits, m_cacheStale;
00239
00240 void dumpCache() const;
00241
00242 static Real s_tolerance;
00243 static bool s_verbose;
00244
00245
00246 static void
00247 defineGraphFromGeo(LevelData<EBGraph> & a_graph,
00248 LayoutData<Vector<IrregNode> > & a_allNodes,
00249 const GeometryService & a_geoserver,
00250 const DisjointBoxLayout & a_grids,
00251 const ProblemDomain & a_domain,
00252 const RealVect & a_origin,
00253 const Real & a_dx,
00254 bool a_hasMoments);
00255
00256
00257 static void makeBoxes(Vector<Box>& a_boxes,
00258 Vector<unsigned long long>& a_loads,
00259 const Box& a_region,
00260 const ProblemDomain& a_domain,
00261 const GeometryService& a_geoserver,
00262 const RealVect& a_origin,
00263 const Real& a_dx,
00264 bool a_hasMoments,
00265 const int a_ncellmax);
00266
00267 static
00268 void makeLoads(Vector<unsigned long long>& a_loads,
00269 Vector<Box>& a_boxes,
00270 const Box& a_region,
00271 const ProblemDomain& a_domain,
00272 const GeometryService& a_geoserver,
00273 const RealVect& a_origin,
00274 const Real& a_dx,
00275 bool a_hasMoments,
00276 const int a_ncellmax);
00277
00278 static void makeBoxes(std::list<Box>& a_boxes,
00279 const Box& a_region,
00280 const ProblemDomain& a_domain,
00281 const GeometryService& a_geoserver,
00282 const RealVect& a_origin,
00283 const Real& a_dx,
00284 bool a_hasMoments,
00285 const int a_ncellmax);
00286
00287
00288 void operator=(const EBISLevel& ebiin)
00289 {
00290 MayDay::Error("EBISLevel::operator= not allowed");
00291 }
00292
00293 EBISLevel(const EBISLevel& ebiin)
00294 {
00295 MayDay::Error("EBISLevel::copy constructor not allowed");
00296 }
00297
00298 bool match(const Real& a_a,
00299 const Real& a_b) const;
00300
00301 bool match(const RealVect& a_a,
00302 const RealVect& a_b) const;
00303
00304 void refreshCache() const;
00305
00306 friend class EBIndexSpace;
00307 };
00308
00309 inline bool EBISLevel::match(const Real& a_a,
00310 const Real& a_b) const
00311 {
00312 return (a_a < (a_b + m_tolerance)) && (a_a > (a_b - m_tolerance));
00313 }
00314
00315 inline bool EBISLevel::match(const RealVect& a_a,
00316 const RealVect& a_b) const
00317 {
00318 return D_TERM6( (a_a[0] < (a_b[0] + m_tolerance)) &&
00319 (a_a[0] > (a_b[0] - m_tolerance)),
00320 &&
00321 (a_a[1] < (a_b[1] + m_tolerance)) &&
00322 (a_a[1] > (a_b[1] - m_tolerance)),
00323 &&
00324 (a_a[2] < (a_b[2] + m_tolerance)) &&
00325 (a_a[2] > (a_b[2] - m_tolerance)),
00326 &&
00327 (a_a[3] < (a_b[3] + m_tolerance)) &&
00328 (a_a[3] > (a_b[3] - m_tolerance)),
00329 &&
00330 (a_a[4] < (a_b[4] + m_tolerance)) &&
00331 (a_a[4] > (a_b[4] - m_tolerance)),
00332 &&
00333 (a_a[5] < (a_b[5] + m_tolerance)) &&
00334 (a_a[5] > (a_b[5] - m_tolerance)));
00335 }
00336
00337 #include "NamespaceFooter.H"
00338
00339 #endif