00001 #ifdef CH_LANG_CC 00002 /* 00003 * _______ __ 00004 * / ___/ / ___ __ _ / / ___ 00005 * / /__/ _ \/ _ \/ V \/ _ \/ _ \ 00006 * \___/_//_/\___/_/_/_/_.__/\___/ 00007 * Please refer to Copyright.txt, in Chombo's root directory. 00008 */ 00009 #endif 00010 00011 #ifndef _AMRLEVEL_H_ 00012 #define _AMRLEVEL_H_ 00013 00014 #include "Vector.H" 00015 #include "REAL.H" 00016 #include "Box.H" 00017 #include "ProblemDomain.H" 00018 #include "DataIterator.H" 00019 #include "Vector.H" 00020 #include "IntVectSet.H" 00021 #include "CH_HDF5.H" 00022 #include "NamespaceHeader.H" 00023 00024 //class HDF5Handle; 00025 //class IntVectSet; 00026 //template <class TTYPE> class Vector; 00027 00028 /// Abstract base class for time-dependent data at a level of refinement. 00029 /** 00030 This is an abstract base class for data at the same level of 00031 refinement within a hierarchy of levels. The concrete class 00032 derived from AMRLevel is called a physics class. The domain 00033 of a level is a disjoint union of rectangles in a logically 00034 rectangular index space. Data is defined within this domain. 00035 There is also a problem domain, which may be larger, within which 00036 data can, in theory, be interpolated from some coarser level. 00037 00038 AMRLevel is intimately entangled with the AMR class. 00039 The AMR contains a collection of AMRLevel objects which 00040 represent a hierarchy of levels of refinement. The class AMR 00041 is responsible for calling the correct member functions of 00042 AMRLevel. The user is responsible for implementing the physics 00043 class, and might never call any AMRLevel functions described 00044 here. 00045 */ 00046 00047 class AMRLevel 00048 { 00049 public: 00050 /// 00051 /** 00052 Default constructor. 00053 */ 00054 AMRLevel(); 00055 00056 /// 00057 /** 00058 Destructor. 00059 */ 00060 virtual 00061 ~AMRLevel(); 00062 00063 /// 00064 /** 00065 Defines this AMRLevel. 00066 00067 <ul> 00068 <li>a_coarser_level_ptr (not modified): pointer to next coarser level 00069 object. 00070 <li>a_problem_domain (not modified): problem domain of this level. 00071 <li>a_level (not modified): index of this level. The base level is 00072 zero. 00073 <li>a_ref_ratio (not modified): the refinement ratio between this level 00074 and the next finer level. 00075 </ul> 00076 */ 00077 virtual 00078 void define(AMRLevel* a_coarser_level_ptr, 00079 const Box& a_problem_domain, 00080 int a_level, 00081 int a_ref_ratio); 00082 00083 /// 00084 /** 00085 Defines this AMRLevel. 00086 00087 <ul> 00088 <li>a_coarser_level_ptr (not modified): pointer to next coarser level 00089 object. 00090 <li>a_problem_domain (not modified): problem domain of this level. 00091 <li>a_level (not modified): index of this level. The base level is 00092 zero. 00093 <li>a_ref_ratio (not modified): the refinement ratio between this level 00094 and the next finer level. 00095 </ul> 00096 */ 00097 virtual 00098 void define(AMRLevel* a_coarser_level_ptr, 00099 const ProblemDomain& a_problem_domain, 00100 int a_level, 00101 int a_ref_ratio); 00102 00103 /// 00104 /** 00105 Advances this level by one time step. Returns an estimate of the 00106 new time step. 00107 00108 This is a pure virtual function and MUST be defined in the derived 00109 class. 00110 00111 */ 00112 virtual 00113 Real advance() = 0; 00114 00115 /// 00116 /** 00117 Things to do after advancing this level by one time step. 00118 00119 This is a pure virtual function and MUST be defined in the derived 00120 class. 00121 00122 */ 00123 virtual 00124 void postTimeStep() = 0; 00125 00126 /// 00127 /** 00128 Creates tagged cells for dynamic mesh refinement. 00129 00130 This is a pure virtual function and MUST be defined in the derived 00131 class. 00132 00133 */ 00134 virtual 00135 void tagCells(IntVectSet& a_tags) = 0; 00136 00137 /// 00138 /** 00139 Creates tagged cells for mesh refinement at initialization. 00140 00141 This is a pure virtual function and MUST be defined in the derived 00142 class. 00143 00144 */ 00145 virtual 00146 void tagCellsInit(IntVectSet& a_tags) = 0; 00147 00148 /// 00149 /** 00150 Performs any pre-regridding operations which are necessary. 00151 00152 This is not a pure virtual function to preserve compatibility 00153 with earlier versions of AMRLevel. The AMRLevel::preRegrid() 00154 instantiation is a no-op. 00155 */ 00156 virtual 00157 void preRegrid(int a_base_level, const Vector<Vector<Box> >& a_new_grids); 00158 00159 /// 00160 /** 00161 Redefines this level to have the specified domain a_new_grids. 00162 00163 This is a pure virtual function and MUST be defined in the derived 00164 class. 00165 00166 */ 00167 virtual 00168 void regrid(const Vector<Box>& a_new_grids) = 0; 00169 00170 /// 00171 /** 00172 Performs any post-regridding operations which are necessary. 00173 00174 This is not a pure virtual function to preserve compatibility 00175 with earlier versions of AMRLevel. The AMRLevel::postRegrid() 00176 instantiation is a no-op. 00177 */ 00178 virtual 00179 void postRegrid(int a_base_level); 00180 00181 /// 00182 /** 00183 Initializes this level to have the specified domain a_new_grids. 00184 00185 This is a pure virtual function and MUST be defined in the derived 00186 class. 00187 00188 */ 00189 virtual 00190 void initialGrid(const Vector<Box>& a_new_grids) = 0; 00191 00192 /// 00193 /** 00194 Performs operations required after the grid has been defined but 00195 before data initialization. This will also be called after 00196 readCheckpointLevel during a restart procedure with argument 00197 a_restart set to true. 00198 00199 Levels are accessed from finest to coarsest. The 00200 AMRLevel::postInitialGrid() instantiation is a no-op. 00201 00202 */ 00203 virtual 00204 void postInitialGrid(const bool a_restart); 00205 00206 /// 00207 /** 00208 Initializes data. 00209 00210 This is a pure virtual function and MUST be defined in the derived 00211 class. 00212 00213 */ 00214 virtual 00215 void initialData() = 0; 00216 00217 /// 00218 /** 00219 Things to do after initialization. 00220 00221 This is a pure virtual function and MUST be defined in the derived 00222 class. 00223 00224 */ 00225 virtual 00226 void postInitialize() = 0; 00227 00228 //! Override this method to have an AMRLevel subclass perform some 00229 //! operation upon the conclusion of a simulation. This is called 00230 //! when AMR::conclude() is called. The final step is passed to the 00231 //! method. 00232 //! \param a_step The last step in the simulation. 00233 virtual void conclude(int a_step) const; 00234 00235 /** 00236 \name I/O functions 00237 */ 00238 /**@{*/ 00239 00240 #ifdef CH_USE_HDF5 00241 /// 00242 /** 00243 Writes checkpoint header. 00244 00245 This is a pure virtual function and MUST be defined in the derived 00246 class. 00247 00248 */ 00249 virtual 00250 void writeCheckpointHeader (HDF5Handle& a_handle) const = 0; 00251 00252 /// 00253 /** 00254 Write checkpoint data for this level. 00255 00256 This is a pure virtual function and MUST be defined in the derived 00257 class. 00258 00259 */ 00260 virtual 00261 void writeCheckpointLevel (HDF5Handle& a_handle) const = 0; 00262 00263 /// 00264 /** 00265 Reads checkpoint header. 00266 00267 This is a pure virtual function and MUST be defined in the derived 00268 class. 00269 00270 */ 00271 virtual 00272 void readCheckpointHeader (HDF5Handle& a_handle) = 0; 00273 00274 /// 00275 /** 00276 Reads checkpoint data for this level. 00277 00278 This is a pure virtual function and MUST be defined in the derived 00279 class. 00280 00281 */ 00282 virtual 00283 void readCheckpointLevel (HDF5Handle& a_handle) = 0; 00284 00285 /// 00286 /** 00287 Writes plot header. 00288 00289 This is a pure virtual function and MUST be defined in the derived 00290 class. 00291 00292 */ 00293 virtual 00294 void writePlotHeader (HDF5Handle& a_handle) const = 0; 00295 00296 /// 00297 /** 00298 Write plot file for this level. 00299 00300 This is a pure virtual function and MUST be defined in the derived 00301 class. 00302 00303 */ 00304 virtual 00305 void writePlotLevel (HDF5Handle& a_handle) const = 0; 00306 #endif 00307 00308 //! This allows one to write a plot file in a non-HDF5 format. It is called only at 00309 //! refinement level 0, so AMR data will have to be handled by the implementer. 00310 //! \param a_prefix A prefix for the custom plot file name. 00311 //! \param a_step The current time step. 00312 virtual void writeCustomPlotFile(const std::string& a_prefix, 00313 int a_step) const; 00314 00315 /**@}*/ 00316 00317 /** 00318 \name Parameter-setting functions 00319 */ 00320 /**@{*/ 00321 00322 /// 00323 /** 00324 Sets the pointer-to-finer-level member to a_finer_level_ptr. 00325 */ 00326 virtual 00327 void finerLevelPtr(AMRLevel* a_finer_level_ptr); 00328 00329 /// 00330 /** 00331 Sets the time step to a_dt. 00332 */ 00333 virtual 00334 void dt(Real a_dt); 00335 00336 /// 00337 /** 00338 Sets the time to a_time. 00339 00340 */ 00341 virtual 00342 void time(Real a_time); 00343 00344 /// 00345 /** 00346 Sets the initial dt multiplier to a_initial_dt_multiplier. 00347 */ 00348 virtual 00349 void initialDtMultiplier(Real a_initial_dt_multiplier); 00350 00351 /**@}*/ 00352 00353 /** 00354 \name Access functions 00355 */ 00356 /**@{*/ 00357 00358 /// 00359 /** 00360 Returns the current value of the time step. 00361 00362 */ 00363 virtual 00364 Real dt() const; 00365 00366 /// 00367 /** 00368 Returns the current value of the time on this level. 00369 */ 00370 virtual 00371 Real time() const; 00372 00373 /// 00374 /** 00375 Returns the initial dt multiplier. 00376 */ 00377 virtual 00378 Real initialDtMultiplier() const; 00379 00380 /// 00381 /** 00382 Returns the problem domain of this level. 00383 00384 */ 00385 virtual 00386 const ProblemDomain& problemDomain() const; 00387 00388 /// 00389 /** 00390 Returns the domain of this level. 00391 00392 */ 00393 virtual 00394 Vector<Box> boxes() const; 00395 00396 /// 00397 /** 00398 Returns true if any AMRLevel::define function has been called, 00399 false otherwise. 00400 */ 00401 bool isDefined() const; 00402 00403 /// 00404 /** 00405 Returns true if a coarser level exists, is defined, and has a grid. 00406 */ 00407 bool hasCoarserLevel() const; 00408 00409 /// 00410 /** 00411 Returns true if a finer level exists, is defined, and has a grid. 00412 */ 00413 bool hasFinerLevel() const; 00414 00415 /// 00416 /** 00417 Returns the index of this level 00418 */ 00419 virtual 00420 int level() const; 00421 00422 /// 00423 /** 00424 Returns the refinement ratio between this level and the next finer level. 00425 00426 */ 00427 virtual 00428 int refRatio() const; 00429 00430 /// 00431 /** 00432 Returns maximum stable time step for this level. 00433 00434 This is a pure virtual function and MUST be defined in the derived 00435 class. 00436 00437 */ 00438 virtual 00439 Real computeDt() = 0; 00440 00441 /// 00442 /** 00443 Returns maximum stable time step for this level with initial data. 00444 00445 This is a pure virtual function and MUST be defined in the derived 00446 class. 00447 00448 */ 00449 virtual 00450 Real computeInitialDt() = 0; 00451 00452 //! Retrieve an array of all of the AMRLevel objects in the entire hierarchy. 00453 Vector<AMRLevel*> getAMRLevelHierarchy(); 00454 00455 /**@}*/ 00456 00457 /// 00458 /** 00459 Returns current verbosity level. Minimum verbosity is 0, for 00460 which nothing is printed. 00461 00462 */ 00463 static 00464 int verbosity(); 00465 00466 /// 00467 /** 00468 Sets verbosity level to a_verbosity. Minimum verbosity is 0, for 00469 which nothing is printed. 00470 */ 00471 static 00472 void verbosity(int a_verbosity); 00473 00474 protected: 00475 00476 // verbosity level 00477 static int s_verbosity; 00478 00479 // the problem domain 00480 ProblemDomain m_problem_domain; 00481 00482 // 00483 Vector<Box> m_level_grids; 00484 00485 // the level 00486 int m_level; 00487 00488 // refinement ratio between this level and the next finer 00489 int m_ref_ratio; 00490 00491 // initial time step multipier 00492 Real m_initial_dt_multiplier; 00493 00494 // time step 00495 Real m_dt; 00496 00497 // time 00498 Real m_time; 00499 00500 // pointer to next coarser level 00501 AMRLevel* m_coarser_level_ptr; 00502 00503 // pointer to next finer level 00504 AMRLevel* m_finer_level_ptr; 00505 00506 bool m_isDefined; 00507 }; 00508 00509 #include "NamespaceFooter.H" 00510 #endif
1.5.5