Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

AMR.H

Go to the documentation of this file.
00001 /*   _______              __
00002     / ___/ /  ___  __ _  / /  ___
00003    / /__/ _ \/ _ \/  ' \/ _ \/ _ \
00004    \___/_//_/\___/_/_/_/_.__/\___/
00005 */
00006 //
00007 // This software is copyright (C) by the Lawrence Berkeley
00008 // National Laboratory.  Permission is granted to reproduce
00009 // this software for non-commercial purposes provided that
00010 // this notice is left intact.
00011 //
00012 // It is acknowledged that the U.S. Government has rights to
00013 // this software under Contract DE-AC03-765F00098 between
00014 // the U.S.  Department of Energy and the University of
00015 // California.
00016 //
00017 // This software is provided as a professional and academic
00018 // contribution for joint exchange. Thus it is experimental,
00019 // is provided ``as is'', with no warranties of any kind
00020 // whatsoever, no support, no promise of updates, or printed
00021 // documentation. By using this software, you acknowledge
00022 // that the Lawrence Berkeley National Laboratory and
00023 // Regents of the University of California shall have no
00024 // liability with respect to the infringement of other
00025 // copyrights by any part of this software.
00026 //
00027 
00028 #ifndef _AMR_H_
00029 #define _AMR_H_
00030 
00031 #include <iostream>
00032 #include <string>
00033 #include <ctime>
00034 
00035 #include "REAL.H"
00036 #include "Vector.H"
00037 #include "AMRLevel.H"
00038 #include "AMRLevelFactory.H"
00039 #include "BRMeshRefine.H"
00040 #include "ProblemDomain.H"
00041 #include "Box.H"
00042 #include "CH_HDF5.H"
00043 
00045 
00066 class AMR
00067 {
00068 public:
00070 
00074   AMR();
00075 
00077 
00080   ~AMR();
00081 
00083 
00103   void define(int                          a_max_level,
00104               const Vector<int>&           a_ref_ratios,
00105               const Box&                   a_prob_domain,
00106               const AMRLevelFactory* const a_amrLevelFact);
00107 
00109 
00129   void define(int                          a_max_level,
00130               const Vector<int>&           a_ref_ratios,
00131               const ProblemDomain&         a_prob_domain,
00132               const AMRLevelFactory* const a_amrLevelFact);
00133 
00135 
00139   bool isDefined() const;
00140 
00142 
00146   bool isSetUp() const;
00147 
00148 #ifdef HDF5
00149 
00150 
00156   void setupForRestart(HDF5Handle& a_handle);
00157 #endif
00158 
00160 
00166   void setupForNewAMRRun();
00167 
00173   void setupForFixedHierarchyRun(const Vector<Vector<Box> >& a_amr_grids,
00174                                  int                         a_proper_nest = 1);
00175 
00177 
00182   void conclude() const;
00183 
00185 
00189   void run(Real a_max_time, int a_max_step);
00190 
00192 
00197   void plotPrefix(const std::string& a_plotfile_prefix);
00198 
00200 
00205   void checkpointPrefix(const std::string& a_checkpointfile_prefix);
00206 
00208 
00212   void plotInterval(int a_plot_interval);
00213 
00215 
00219   void checkpointInterval(int a_checkpoint_interval);
00220 
00222 
00226   void maxGridSize(int a_max_grid_size);
00227 
00229 
00234   void maxBaseGridSize(int a_max_base_grid_size);
00235 
00237 
00242   void dtToleranceFactor(Real a_dt_tolerance_factor);
00243 
00245 
00249   void fillRatio(Real a_fillRat);
00250 
00252 
00256   void blockFactor(int a_blockFactor);
00257 
00259 
00263   void gridBufferSize(int a_grid_buffer_size);
00264 
00266 
00269   int maxGridSize() const;
00270 
00272 
00275   int maxBaseGridSize() const;
00276 
00278 
00289   void verbosity (int a_verbosity);
00290 
00292 
00296   void regridIntervals(const Vector<int>& a_regridIntervals);
00297 
00299 
00308   int verbosity () const;
00309 
00311 
00312   void maxDtGrow(Real a_dtGrowFactor);
00313 
00315 
00320   void timeEps(Real a_timeEps);
00321 
00323 
00324   Real maxDtGrow() const;
00325 
00327 
00330   Real timeEps() const;
00331 
00333 
00334   void fixedDt(Real a_dt);
00335 
00337 
00338   Real fixedDt() const;
00339 
00341 
00344   Vector<AMRLevel*> getAMRLevels();
00345 
00347 
00350   Real getCurrentTime() const;
00351 
00352 protected:
00353   // advance by dt on this level and all finer levels and return the
00354   // number of steps left - given the number of steps left on entry.
00355   int timeStep(int a_level, int a_stepsLeft, bool a_coarseTimeBoundary);
00356 
00357   //intenal use only
00358   void clearMemory();
00359 
00360   // make new grids.
00361   void regrid(int a_base_level);
00362 
00363   // make initial grids.
00364   // not an accurate name, since there are no grids to re.
00365   void initialGrid();
00366 
00367   void writePlotFile() const;
00368 
00369   void writeCheckpointFile() const;
00370 
00371   // computes maximum stable time step given the maximum stable time
00372   // step on the individual levels.
00373   void assignDt();
00374 
00375   // whether regridding should be done now.
00376   bool needToRegrid(int a_level, int a_numStepsLeft) const;
00377 
00378   void makeBaseLevelMesh (Vector<Box>& a_grids) const;
00379 
00380   void setDefaultValues();
00381 
00382 protected:
00383   int  m_blockFactor;
00384   Real m_fillRatio;
00385   int  m_max_level;
00386   int  m_finest_level_old;
00387   int  m_finest_level;
00388   int  m_checkpoint_interval;
00389   int  m_plot_interval;
00390   int  m_max_grid_size;
00391   int  m_max_base_grid_size;
00392   Real m_dt_tolerance_factor;
00393   Real m_fixedDt;
00394 
00395   bool              m_isDefined;
00396   bool              m_isSetUp;
00397   Vector<AMRLevel*> m_amrlevels;
00398   Vector<int>       m_ref_ratios;
00399   Vector<int>       m_reduction_factor;
00400   Vector<int>       m_regrid_intervals;
00401 
00402   Real         m_dt_base;
00403   // New (maximum) dt
00404   Vector<Real> m_dt_new;
00405   // Current dt
00406   Vector<Real> m_dt_cur;
00407   Real         m_maxDtGrow;
00408   Real         m_time_eps;
00409 
00410 
00411   BRMeshRefine m_mesh_refine;
00412   bool         m_use_meshrefine;
00413 
00414   Vector<Vector<Box> > m_amr_grids;
00415 
00416   int m_cur_step;
00417   int m_restart_step;
00418   int m_lastcheck_step;
00419 
00420   Real         m_cur_time;
00421   Vector<int>  m_steps_since_regrid;
00422   Vector<long> m_cell_updates;
00423 
00424   std::string m_plotfile_prefix;
00425   std::string m_checkpointfile_prefix;
00426 
00427   int m_verbosity;
00428 };
00429 #endif

Generated on Wed Jun 2 13:53:31 2004 for Chombo&INSwithParticles by doxygen 1.3.2