00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _AMR_H_
00012 #define _AMR_H_
00013
00014 #include <iostream>
00015 #include <string>
00016 #include <ctime>
00017
00018 #include "REAL.H"
00019 #include "Vector.H"
00020 #include "AMRLevel.H"
00021 #include "AMRLevelFactory.H"
00022 #include "BRMeshRefine.H"
00023 #include "ProblemDomain.H"
00024 #include "Box.H"
00025 #include "CH_HDF5.H"
00026 #ifdef CH_USE_TIMER
00027 #include "CH_Timer.H"
00028 #endif
00029 #include "NamespaceHeader.H"
00030
00031
00033
00054 class AMR
00055 {
00056 public:
00058
00062 AMR();
00063
00065
00068 ~AMR();
00069
00071
00091 void define(int a_max_level,
00092 const Vector<int>& a_ref_ratios,
00093 const Box& a_prob_domain,
00094 const AMRLevelFactory* const a_amrLevelFact);
00095
00097
00117 void define(int a_max_level,
00118 const Vector<int>& a_ref_ratios,
00119 const ProblemDomain& a_prob_domain,
00120 const AMRLevelFactory* const a_amrLevelFact);
00121
00123
00127 bool isDefined() const;
00128
00130
00134 bool isSetUp() const;
00135
00136 #ifdef CH_USE_HDF5
00138
00144 void setupForRestart(HDF5Handle& a_handle);
00145 #endif
00146
00148
00154 void setupForNewAMRRun();
00155
00161 void setupForFixedHierarchyRun(const Vector<Vector<Box> >& a_amr_grids,
00162 int a_proper_nest = 1);
00163
00165
00170 void conclude() const;
00171
00173
00177 void run(Real a_max_time, int a_max_step);
00178
00180
00185 void plotPrefix(const std::string& a_plotfile_prefix);
00186
00188
00193 void checkpointPrefix(const std::string& a_checkpointfile_prefix);
00194
00196
00200 void plotInterval(int a_plot_interval);
00201
00203
00207 void checkpointInterval(int a_checkpoint_interval);
00208
00210
00214 void maxGridSize(int a_max_grid_size);
00215
00217
00222 void maxBaseGridSize(int a_max_base_grid_size);
00223
00225
00230 void dtToleranceFactor(Real a_dt_tolerance_factor);
00231
00233
00237 void fillRatio(Real a_fillRat);
00238
00240
00244 void blockFactor(int a_blockFactor);
00245
00247
00251 void gridBufferSize(int a_grid_buffer_size);
00252
00254
00257 int maxGridSize() const;
00258
00260
00263 int maxBaseGridSize() const;
00264
00266
00277 void verbosity (int a_verbosity);
00278
00280
00284 void regridIntervals(const Vector<int>& a_regridIntervals);
00285
00287
00296 int verbosity () const;
00297
00299
00300 void maxDtGrow(Real a_dtGrowFactor);
00301
00303
00308 void timeEps(Real a_timeEps);
00309
00311
00312 Real maxDtGrow() const;
00313
00315
00318 Real timeEps() const;
00319
00321
00322 void fixedDt(Real a_dt);
00323
00325
00326 Real fixedDt() const;
00327
00329
00332 Vector<AMRLevel*> getAMRLevels();
00333
00335
00341 void initialTime(Real a_initialTime);
00342
00344
00347 Real getCurrentTime() const;
00348
00349 #ifdef CH_USE_TIMER
00351
00354 Chombo::Timer * timer(Chombo::Timer *a_timer = NULL );
00355 #endif
00356
00358
00361 void useSubcyclingInTime(bool a_useSubcycling);
00362 protected:
00363 bool m_useSubcycling;
00364
00365
00366 int timeStep(int a_level, int a_stepsLeft, bool a_coarseTimeBoundary);
00367
00368
00369 void clearMemory();
00370
00371
00372 void regrid(int a_base_level);
00373
00374
00375
00376 void initialGrid();
00377
00378 void writePlotFile() const;
00379
00380 void writeCheckpointFile() const;
00381
00382
00383
00384 void assignDt();
00385
00386
00387 bool needToRegrid(int a_level, int a_numStepsLeft) const;
00388
00389 void makeBaseLevelMesh (Vector<Box>& a_grids) const;
00390
00391 void setDefaultValues();
00392
00393 int m_blockFactor;
00394 Real m_fillRatio;
00395 int m_max_level;
00396 int m_finest_level_old;
00397 int m_finest_level;
00398 int m_checkpoint_interval;
00399 int m_plot_interval;
00400 int m_max_grid_size;
00401 int m_max_base_grid_size;
00402 Real m_dt_tolerance_factor;
00403 Real m_fixedDt;
00404
00405 bool m_isDefined;
00406 bool m_isSetUp;
00407 Vector<AMRLevel*> m_amrlevels;
00408 Vector<int> m_ref_ratios;
00409 Vector<int> m_reduction_factor;
00410 Vector<int> m_regrid_intervals;
00411
00412 Real m_dt_base;
00413
00414 Vector<Real> m_dt_new;
00415
00416 Vector<Real> m_dt_cur;
00417 Real m_maxDtGrow;
00418 Real m_time_eps;
00419
00420 BRMeshRefine m_mesh_refine;
00421 bool m_use_meshrefine;
00422
00423 Vector<Vector<Box> > m_amr_grids;
00424
00425 int m_cur_step;
00426 int m_restart_step;
00427 int m_lastcheck_step;
00428
00429 Real m_cur_time;
00430 Vector<int> m_steps_since_regrid;
00431 Vector<long long> m_cell_updates;
00432
00433 std::string m_plotfile_prefix;
00434 std::string m_checkpointfile_prefix;
00435
00436 int m_verbosity;
00437 #ifdef CH_USE_TIMER
00438 Chombo::Timer *m_timer;
00439 #endif
00440 };
00441
00442 #include "NamespaceFooter.H"
00443 #endif