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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #ifndef _AMR_H_
00053 #define _AMR_H_
00054
00055 #include <iostream>
00056 #include <string>
00057 #include <ctime>
00058
00059 #include "REAL.H"
00060 #include "Vector.H"
00061 #include "AMRLevel.H"
00062 #include "AMRLevelFactory.H"
00063 #include "BRMeshRefine.H"
00064 #include "ProblemDomain.H"
00065 #include "Box.H"
00066 #include "CH_HDF5.H"
00067
00069
00090 class AMR
00091 {
00092 public:
00094
00098 AMR();
00099
00101
00104 ~AMR();
00105
00107
00127 void define(int a_max_level,
00128 const Vector<int>& a_ref_ratios,
00129 const Box& a_prob_domain,
00130 const AMRLevelFactory* const a_amrLevelFact);
00131
00133
00153 void define(int a_max_level,
00154 const Vector<int>& a_ref_ratios,
00155 const ProblemDomain& a_prob_domain,
00156 const AMRLevelFactory* const a_amrLevelFact);
00157
00159
00163 bool isDefined() const;
00164
00166
00170 bool isSetUp() const;
00171
00172 #ifdef HDF5
00173
00174
00180 void setupForRestart(HDF5Handle& a_handle);
00181 #endif
00182
00184
00190 void setupForNewAMRRun();
00191
00197 void setupForFixedHierarchyRun(const Vector<Vector<Box> >& a_amr_grids,
00198 int a_proper_nest = 1);
00199
00201
00206 void conclude() const;
00207
00209
00213 void run(Real a_max_time, int a_max_step);
00214
00216
00221 void plotPrefix(const std::string& a_plotfile_prefix);
00222
00224
00229 void checkpointPrefix(const std::string& a_checkpointfile_prefix);
00230
00232
00236 void plotInterval(int a_plot_interval);
00237
00239
00243 void checkpointInterval(int a_checkpoint_interval);
00244
00246
00250 void maxGridSize(int a_max_grid_size);
00251
00253
00258 void maxBaseGridSize(int a_max_base_grid_size);
00259
00261
00266 void dtToleranceFactor(Real a_dt_tolerance_factor);
00267
00269
00273 void fillRatio(Real a_fillRat);
00274
00276
00280 void blockFactor(int a_blockFactor);
00281
00283
00287 void gridBufferSize(int a_grid_buffer_size);
00288
00290
00293 int maxGridSize() const;
00294
00296
00299 int maxBaseGridSize() const;
00300
00302
00313 void verbosity (int a_verbosity);
00314
00316
00320 void regridIntervals(const Vector<int>& a_regridIntervals);
00321
00323
00332 int verbosity () const;
00333
00335
00336 void maxDtGrow(Real a_dtGrowFactor);
00337
00339
00344 void timeEps(Real a_timeEps);
00345
00347
00348 Real maxDtGrow() const;
00349
00351
00354 Real timeEps() const;
00355
00357
00358 void fixedDt(Real a_dt);
00359
00361
00362 Real fixedDt() const;
00363
00365
00368 Vector<AMRLevel*> getAMRLevels();
00369
00371
00374 Real getCurrentTime() const;
00375
00376
00377 protected:
00378
00379
00380 int timeStep(int a_level, int a_stepsLeft, bool a_coarseTimeBoundary);
00381
00382
00383 void clearMemory();
00384
00385
00386 void regrid(int a_base_level);
00387
00388
00389
00390 void initialGrid();
00391
00392 void writePlotFile() const;
00393
00394 void writeCheckpointFile() const;
00395
00396
00397
00398 void assignDt();
00399
00400
00401 bool needToRegrid(int a_level, int a_numStepsLeft) const;
00402
00403 void makeBaseLevelMesh (Vector<Box>& a_grids) const;
00404
00405 void setDefaultValues();
00406
00407 int m_blockFactor;
00408 Real m_fillRatio;
00409 int m_max_level;
00410 int m_finest_level_old;
00411 int m_finest_level;
00412 int m_checkpoint_interval;
00413 int m_plot_interval;
00414 int m_max_grid_size;
00415 int m_max_base_grid_size;
00416 Real m_dt_tolerance_factor;
00417 Real m_fixedDt;
00418
00419 bool m_isDefined;
00420 bool m_isSetUp;
00421 Vector<AMRLevel*> m_amrlevels;
00422 Vector<int> m_ref_ratios;
00423 Vector<int> m_reduction_factor;
00424 Vector<int> m_regrid_intervals;
00425
00426 Real m_dt_base;
00427
00428 Vector<Real> m_dt_new;
00429
00430 Vector<Real> m_dt_cur;
00431 Real m_maxDtGrow;
00432 Real m_time_eps;
00433
00434 BRMeshRefine m_mesh_refine;
00435 bool m_use_meshrefine;
00436
00437 Vector<Vector<Box> > m_amr_grids;
00438
00439 int m_cur_step;
00440 int m_restart_step;
00441 int m_lastcheck_step;
00442
00443 Real m_cur_time;
00444 Vector<int> m_steps_since_regrid;
00445 Vector<long> m_cell_updates;
00446
00447 std::string m_plotfile_prefix;
00448 std::string m_checkpointfile_prefix;
00449
00450 int m_verbosity;
00451 };
00452
00453 #endif