00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _AMR_H_
00029 #define _AMR_H_
00030
00031 #include <iostream>
00032 #include <string>
00033
00034 #include "REAL.H"
00035 #include "Vector.H"
00036 #include "AMRLevel.H"
00037 #include "AMRLevelFactory.H"
00038 #include "BRMeshRefine.H"
00039 #include "ProblemDomain.H"
00040 #include "Box.H"
00041 #include "HDF5.H"
00042
00043 #include <time.h>
00044
00046
00063 class AMR
00064 {
00065 public:
00067
00069
00073 AMR();
00074
00076
00079 ~AMR();
00080
00082
00105 void define(int a_max_level,
00106 const Vector<int>& a_ref_ratios,
00107 const Box& a_prob_domain,
00108 const AMRLevelFactory* const a_amrLevelFact);
00109
00110
00112
00135 void define(int a_max_level,
00136 const Vector<int>& a_ref_ratios,
00137 const ProblemDomain& a_prob_domain,
00138 const AMRLevelFactory* const a_amrLevelFact);
00139
00140
00142
00143
00145
00149 bool isDefined() const;
00150
00152
00156 bool isSetUp() const;
00157
00158 #ifdef HDF5
00159
00160
00166 void
00167 setupForRestart(HDF5Handle& a_handle);
00168 #endif
00169
00171
00177 void
00178 setupForNewAMRRun();
00179
00185 void
00186 setupForFixedHierarchyRun(const Vector<Vector<Box> >& a_amr_grids,
00187 int a_proper_nest = 1);
00188
00190
00195 void
00196 conclude() const;
00197
00199
00203 void
00204 run(Real a_max_time, int a_max_step);
00205
00207
00209
00214 void
00215 plotPrefix(const std::string& a_plotfile_prefix);
00216
00218
00223 void
00224 checkpointPrefix(const std::string& a_checkpointfile_prefix);
00225
00227
00231 void
00232 plotInterval(int a_plot_interval);
00233
00235
00239 void
00240 checkpointInterval(int a_checkpoint_interval);
00241
00243
00247 void
00248 maxGridSize(int a_max_grid_size);
00249
00251
00256 void
00257 dtToleranceFactor(Real a_dt_tolerance_factor);
00258
00260
00264 void
00265 fillRatio(Real a_fillRat);
00266
00268
00272 void
00273 blockFactor(int a_blockFactor);
00274
00276
00280 void
00281 gridBufferSize(int a_grid_buffer_size);
00282
00283 int
00284 maxGridSize() const;
00285
00287
00299 void
00300 verbosity (int a_verbosity);
00301
00303
00307 void
00308 regridIntervals(const Vector<int>& a_regridIntervals);
00309
00311
00320 int
00321 verbosity () const;
00322
00324
00325 void
00326 maxDtGrow(Real a_dtGrowFactor);
00327
00329
00330 Real
00331 maxDtGrow() const;
00332
00334
00335 void
00336 fixedDt(Real a_dt);
00337
00339
00340 Real
00341 fixedDt() const;
00342
00343 Vector<AMRLevel*> getAMRLevels();
00344
00345 Real getCurrentTime() const;
00346 protected:
00347
00348
00349 int
00350 timeStep(int a_level, int a_stepsLeft, bool timeBoundary);
00351
00352
00353 void
00354 clearMemory();
00355
00356 void
00357 regrid(int a_base_level);
00358
00359
00360
00361 void
00362 initialGrid();
00363
00364 void
00365 writePlotFile() const;
00366
00367 void
00368 writeCheckpointFile() const;
00369
00370
00371
00372 void
00373 assignDt();
00374
00375
00376 bool
00377 needToRegrid(int a_level, int a_numStepsLeft) const;
00378
00379 void
00380 makeBaseLevelMesh (Vector<Box>& a_grids) const;
00381
00382 void setDefaultValues();
00383
00384 protected:
00385 int m_blockFactor;
00386 Real m_fillRatio;
00387 int m_max_level;
00388 int m_finest_level_old;
00389 int m_finest_level;
00390 int m_checkpoint_interval;
00391 int m_plot_interval;
00392 int m_max_grid_size;
00393 Real m_dt_tolerance_factor;
00394 Real m_fixedDt;
00395
00396 bool m_isDefined;
00397 bool m_isSetUp;
00398 Vector<AMRLevel*> m_amrlevels;
00399 Vector<int> m_ref_ratios;
00400 Vector<int> m_reduction_factor;
00401 Vector<int> m_regrid_intervals;
00402 Real m_dt_base;
00403
00404 Vector<Real> m_dt_new;
00405
00406 Vector<Real> m_dt_cur;
00407 Real m_maxDtGrow;
00408
00409 BRMeshRefine m_mesh_refine;
00410 bool m_use_meshrefine;
00411
00412 Vector<Vector<Box> > m_amr_grids;
00413
00414 int m_cur_step;
00415 int m_restart_step;
00416 int m_lastcheck_step;
00417
00418 Real m_cur_time;
00419 Vector<int> m_steps_since_regrid;
00420 Vector<long> m_cell_updates;
00421
00422 std::string m_plotfile_prefix;
00423 std::string m_checkpointfile_prefix;
00424
00425 int m_verbosity;
00426 };
00427 #endif