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_LEVEL_SELFGRAVITY_H_
00029 #define _AMR_LEVEL_SELFGRAVITY_H_
00030
00031 #include "Box.H"
00032 #include "Vector.H"
00033 #include "IntVectSet.H"
00034 #include "DisjointBoxLayout.H"
00035
00036 #include "FArrayBox.H"
00037 #include "AMRLevel.H"
00038 #include "LevelData.H"
00039 #include "LevelGodunov.H"
00040
00041 #include "CoarseAverage.H"
00042 #include "FineInterp.H"
00043 #include "LevelFluxRegister.H"
00044 #include "RefCellTagger.H"
00045 #include "PiecewiseLinearFillPatchFace.H"
00046
00047 #include "LevelSolver.H"
00048 #include "PoissonOp.H"
00049 #include "Gradient.H"
00050 #include "SelfGravityPhysics.H"
00051
00052 #include "CodeUnits.H"
00053
00054 #include "CH_HDF5.H"
00055 #include "CONSTANTS_C.H"
00056
00058 class AMRLevelSelfGravity : public AMRLevel
00059 {
00060 public:
00062 AMRLevelSelfGravity();
00063
00065 virtual ~AMRLevelSelfGravity();
00066
00068 virtual void define(AMRLevel* a_coarserLevelPtr,
00069 const Box& a_problemDomain,
00070 int a_level,
00071 int a_refRatio);
00072
00074 virtual void define(AMRLevel* a_coarserLevelPtr,
00075 const ProblemDomain& a_problemDomain,
00076 int a_level,
00077 int a_refRatio);
00078
00080 void defineParams(const Real& a_cfl,
00081 const Real& a_domainLength,
00082 const int& a_verbosity,
00083 const int& a_tagBufferSize,
00084 const int& a_maxInitRefLevel,
00085 const Real& a_initialDtMultiplier,
00086 const GodunovPhysics* const a_godunovPhysics,
00087 const int& a_normalPredOrder,
00088 const bool& a_useFourthOrderSlopes,
00089 const bool& a_usePrimLimiting,
00090 const bool& a_useCharLimiting,
00091 const bool& a_useFlattening,
00092 const bool& a_useArtificialViscosity,
00093 const Real& a_artificialViscosity,
00094 const RefCellTagger* const a_refCellTagger,
00095 const LevelOp* const a_poissonOp,
00096 const bool& a_useDeltaPhiCorr,
00097 const StencilType& a_stencil,
00098 const CodeUnits& a_codeUnits);
00099
00101 virtual Real advance();
00102
00104 virtual void postTimeStep();
00105
00107 virtual void tagCells(IntVectSet& a_tags) ;
00108
00110 virtual void tagCellsInit(IntVectSet& a_tags) ;
00111
00113 virtual void regrid(const Vector<Box>& a_newGrids);
00114
00116 virtual void postRegrid(int a_base_level);
00117
00119 virtual void initialGrid(const Vector<Box>& a_newGrids);
00120
00122 virtual void initialData();
00123
00125 virtual void postInitialize();
00126
00128
00129
00130 #ifdef CH_USE_HDF5
00131
00132 virtual void writeCheckpointHeader(HDF5Handle& a_handle) const;
00133
00135 virtual void writeCheckpointLevel(HDF5Handle& a_handle) const;
00136
00138 virtual void readCheckpointHeader(HDF5Handle& a_handle);
00139
00141 virtual void readCheckpointLevel(HDF5Handle& a_handle);
00142
00144 virtual void writePlotHeader(HDF5Handle& a_handle) const;
00145
00147 virtual void writePlotLevel(HDF5Handle& a_handle) const;
00148
00149 #endif
00150
00152 virtual Real computeDt();
00153
00155 virtual Real computeInitialDt();
00156
00158 const LevelData<FArrayBox>& getStateNew() const;
00159
00161 const LevelData<FArrayBox>& getStateOld() const;
00162
00164 virtual LevelData<FArrayBox>* getPoissonRhs(const Real& a_time);
00165
00167 virtual LevelData<FArrayBox>* getPhi(const Real& a_time);
00168
00170 virtual void gravity(const int a_baseLevel, const bool a_srceCorr = true);
00171
00173 virtual void computeForce();
00174
00176 virtual void postElliptic(const int a_baseLevel);
00177
00179 virtual void secondOrderCorrection();
00180
00182 virtual void isThisFinestLev(const bool a_isThisFinestLev);
00183
00185 virtual bool isThisFinestLev() const;
00186
00188 bool allDefined() const;
00189
00190 protected:
00191
00192 DisjointBoxLayout loadBalance(const Vector<Box>& a_grids);
00193
00194
00195 void levelSetup();
00196
00197
00198 AMRLevelSelfGravity* getCoarserLevel() const;
00199
00200
00201 AMRLevelSelfGravity* getFinerLevel() const;
00202
00203
00204 void makePoissonRhs(LevelData<FArrayBox>& a_rhs,
00205 const LevelData<FArrayBox>& a_U,
00206 const Real& a_time);
00207
00208
00209 void computeForce(LevelData<ForceBox>& a_force,
00210 LevelData<FArrayBox>& a_phi,
00211 const Real& a_time);
00212
00213
00214 void setupSourceTerm(LevelData<FArrayBox>& a_source,
00215 const LevelData<FArrayBox>& a_U,
00216 const LevelData<ForceBox>& a_force,
00217 const Real& a_time,
00218 const Real& a_dt);
00219
00220 protected:
00221
00222 LevelData<FArrayBox> m_UOld,m_UNew;
00223
00224
00225 LevelData<FArrayBox> m_phiOld,m_phiNew,m_deltaPhi;
00226
00227
00228 LevelData<ForceBox> m_forceOld, m_forceNew;
00229
00230
00231 LevelData<FArrayBox> m_rhs;
00232 LevelData<FArrayBox> m_rhsCrseNew, m_rhsCrseOld;
00233
00234
00235 Real m_rhsOffset;
00236
00237
00238 Real m_cfl;
00239
00240
00241 Real m_dx;
00242
00243
00244 Real m_dtNew, m_dtOld;
00245
00246
00247 int m_numStates;
00248
00249
00250 Vector<string> m_stateNames;
00251
00252
00253 Vector<string> m_plotNames;
00254
00255
00256 int m_numGhost;
00257
00258
00259 int m_numRhsGhost;
00260
00261
00262 int m_numPhiGhost;
00263
00264
00265 int m_numForceGhost;
00266
00267
00268
00269
00270 int m_nLevForceComp;
00271
00272
00273 Real m_domainLength;
00274
00275
00276 CodeUnits m_units;
00277
00278
00279 bool m_useDeltaPhiCorr;
00280
00281
00282 FineInterp m_fineInterp;
00283
00284
00285 CoarseAverage m_coarseAverage;
00286
00287
00288 FineInterp m_fineInterpPhi;
00289
00290
00291 CoarseAverage m_coarseAveragePhi;
00292
00293
00294 PiecewiseLinearFillPatch m_patcher;
00295
00296
00297 QuadCFInterp m_quadCFInterp;
00298
00299
00300 PiecewiseLinearFillPatch m_forcePatcher;
00301
00302
00303 LevelGodunov m_levelGodunov;
00304
00305
00306 LevelSolver m_levelSolver;
00307
00308
00309 LevelFluxRegister m_fluxRegister;
00310
00311
00312 Gradient* m_gradient;
00313
00314
00315 SelfGravityPhysics* m_gdnvPhysics;
00316
00317
00318 LevelOp* m_poissonOp;
00319
00320
00321 RefCellTagger* m_refCellTagger;
00322
00323
00324 int m_maxInitRefLevel;
00325
00326
00327 int m_tagBufferSize;
00328
00329
00330 bool m_hasCoarser;
00331 bool m_hasFiner;
00332
00333
00334 bool m_isThisFinestLev;
00335
00336
00337 int m_normalPredOrder;
00338
00339
00340 bool m_useFourthOrderSlopes;
00341
00342
00343 bool m_usePrimLimiting;
00344 bool m_useCharLimiting;
00345
00346
00347 bool m_useFlattening;
00348
00349
00350 bool m_useArtificialViscosity;
00351 Real m_artificialViscosity;
00352
00353
00354 DisjointBoxLayout m_grids;
00355
00356
00357 bool m_paramsDefined;
00358
00359 private:
00360
00361 void operator=(const AMRLevelSelfGravity& a_input)
00362 {
00363 MayDay::Error("invalid operator");
00364 }
00365
00366
00367 AMRLevelSelfGravity(const AMRLevelSelfGravity& a_input)
00368 {
00369 MayDay::Error("invalid operator");
00370 }
00371 };
00372
00373 #endif