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 _AMR_LEVEL_WAVE_EQUATION_H_ 00012 #define _AMR_LEVEL_WAVE_EQUATION_H_ 00013 00014 #include "FArrayBox.H" 00015 #include "LevelData.H" 00016 #include "AMRLevel.H" 00017 #include "CoarseAverage.H" 00018 #include "FineInterp.H" 00019 #include "LevelFluxRegister.H" 00020 #include "PatchGodunovF_F.H" 00021 00022 #include "LevelWaveOperator.H" 00023 #include "Box.H" 00024 #include "IntVectSet.H" 00025 #include "Vector.H" 00026 #include "DisjointBoxLayout.H" 00027 #include "PhysIBC.H" 00028 #include "UsingNamespace.H" 00029 00031 00033 class AMRLevelWaveEquation : public AMRLevel 00034 { 00035 friend class AMRLevelWaveEqnFactory ; 00036 public: 00038 00040 AMRLevelWaveEquation(); 00041 00043 00045 virtual ~AMRLevelWaveEquation(); 00046 00048 00050 virtual void define(AMRLevel* a_coarserLevelPtr, 00051 const ProblemDomain& a_problemDomain, 00052 int a_level, 00053 int a_refRatio); 00054 00056 00058 virtual Real advance(); 00059 00061 00063 virtual void postTimeStep(); 00064 00066 00068 virtual void tagCells(IntVectSet& a_tags) ; 00069 00071 00073 virtual void tagCellsInit(IntVectSet& a_tags) ; 00074 00076 00078 virtual void regrid(const Vector<Box>& a_newGrids); 00079 00081 00083 virtual void initialGrid(const Vector<Box>& a_newGrids); 00084 00086 00088 virtual void initialData(); 00089 00091 00093 virtual void postInitialize(); 00094 00095 #ifdef CH_USE_HDF5 00097 00099 virtual void writeCheckpointHeader(HDF5Handle& a_handle) const; 00100 00102 00104 virtual void writeCheckpointLevel(HDF5Handle& a_handle) const; 00105 00107 00109 virtual void readCheckpointHeader(HDF5Handle& a_handle); 00110 00112 00114 virtual void readCheckpointLevel(HDF5Handle& a_handle); 00115 00117 00119 virtual void writePlotHeader(HDF5Handle& a_handle) const; 00120 00122 00124 virtual void writePlotLevel(HDF5Handle& a_handle) const; 00125 #endif 00126 00128 00130 virtual Real computeDt(); 00131 00133 00135 virtual Real computeInitialDt(); 00136 00138 00140 Real computeEnergy(); 00141 00143 00145 virtual void CFL(Real a_cfl); 00146 00148 00150 virtual void domainLength(Real a_domainLength); 00151 00153 00155 virtual void refinementThreshold(Real a_refineThresh); 00156 00158 00160 void tagBufferSize(int a_tagBufferSize); 00161 00162 void IBC(PhysIBC* a_ibc) {m_physIBCPtr = a_ibc;}; 00163 00165 00167 LevelData<FArrayBox> * phi(){ return &m_phiNew ; } ; 00168 LevelData<FArrayBox> * pi() { return &m_piNew ; } ; 00169 00170 protected: 00171 // Create a load-balanced DisjointBoxLayout from a collection of Boxes 00172 DisjointBoxLayout loadBalance(const Vector<Box>& a_grids); 00173 00174 // Setup menagerie of data structures 00175 void levelSetup(); 00176 00177 // Get the next coarser level 00178 AMRLevelWaveEquation* getCoarserLevel() const; 00179 00180 // Get the next finer level 00181 AMRLevelWaveEquation* getFinerLevel() const; 00182 00183 00184 private: 00185 // Disallowed for all the usual reasons 00186 void operator=(const AMRLevelWaveEquation& a_input) 00187 { 00188 MayDay::Error("invalid operator"); 00189 } 00190 00191 // Disallowed for all the usual reasons 00192 AMRLevelWaveEquation(const AMRLevelWaveEquation& a_input) 00193 { 00194 MayDay::Error("invalid operator"); 00195 } 00196 00197 protected: 00198 00199 // member variables 00200 00201 00202 // lower corner of problem domain in physical space 00203 Real m_r0 ; 00204 00205 00206 // Fields phi, pi = d(phi)/dt at old and new time 00207 LevelData<FArrayBox> m_phiOld,m_phiNew,m_piOld,m_piNew; 00208 00209 // CFL number 00210 Real m_cfl; 00211 00212 // Grid spacing 00213 Real m_dx; 00214 00215 // Interpolation from fine to coarse level 00216 FineInterp m_fineInterp; 00217 00218 // Averaging from coarse to fine level 00219 CoarseAverage m_coarseAverage; 00220 00221 // New time step 00222 Real m_dtNew; 00223 00224 // Number of field variables (phi) = number of conserved states (pi). 00225 int m_numStates; 00226 00227 // Names of conserved states 00228 Vector<std::string> m_stateNames; 00229 00230 // Number of ghost cells (in each direction) 00231 int m_numGhost; 00232 00233 // Physical dimension of the longest side of the domain 00234 Real m_domainLength; 00235 00236 // Level integrator 00237 LevelWaveOperator m_levelWaveOperator; 00238 00239 // Flux register 00240 LevelFluxRegister m_fluxRegister; 00241 00242 // Refinement threshold for gradient 00243 Real m_refineThresh; 00244 00245 // Tag buffer size 00246 int m_tagBufferSize; 00247 00248 // Flag coarser and finer levels 00249 bool m_hasCoarser; 00250 bool m_hasFiner; 00251 00252 DisjointBoxLayout m_grids; 00253 00254 // Initial / boundary condition interface class. 00255 00256 PhysIBC* m_physIBCPtr; 00257 00258 void initializeODE(LevelData<FArrayBox>& a_piOld,LevelData<FArrayBox>& a_pi); 00259 void updateODE(LevelData<FArrayBox>& a_LOfPhi,LevelData<FArrayBox>& a_pi, 00260 Real a_dt); 00261 00262 }; 00263 00264 #endif