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