Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

AMRLevelSelfGravity.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_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   //virtual void setCosmology(const Cosmology& a_cosmology);
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   // Create a load-balanced DisjointBoxLayout from a collection of Boxes
00192   DisjointBoxLayout loadBalance(const Vector<Box>& a_grids);
00193 
00194   // Setup menagerie of data structures
00195   void levelSetup();
00196 
00197   // Get the next coarser level
00198   AMRLevelSelfGravity* getCoarserLevel() const;
00199 
00200   // Get the next finer level
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   // Compute force from a potential. 
00209   void computeForce(LevelData<ForceBox>&  a_force,
00210                     LevelData<FArrayBox>& a_phi, 
00211                     const Real&           a_time);
00212 
00213   // compute source term
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   // Conserved state, U, at old and new time
00222   LevelData<FArrayBox> m_UOld,m_UNew;
00223 
00224   // Gravitational potential Phi for projection at old and new time
00225   LevelData<FArrayBox> m_phiOld,m_phiNew,m_deltaPhi;
00226 
00227   //
00228   LevelData<ForceBox> m_forceOld, m_forceNew;
00229 
00230   // grad(Phi)=Rhs = 1.5*rho_gas
00231   LevelData<FArrayBox> m_rhs;
00232   LevelData<FArrayBox> m_rhsCrseNew, m_rhsCrseOld;
00233 
00234   //
00235   Real m_rhsOffset;
00236 
00237   // CFL number
00238   Real m_cfl;
00239 
00240   // Grid spacing
00241   Real m_dx;
00242 
00243   // New and Old time step
00244   Real m_dtNew, m_dtOld;
00245 
00246   // Number of converved states
00247   int m_numStates;
00248 
00249   // Names of conserved states
00250   Vector<string> m_stateNames;
00251 
00252   // Names of plot variables
00253   Vector<string> m_plotNames;
00254 
00255   // Number of ghost cells (in each direction)
00256   int m_numGhost;
00257 
00258   // Number of ghost cells (in each direction) for RHS to Poisson eq.
00259   int m_numRhsGhost;
00260 
00261   // Number of ghost for the potential; always 1 except for 4 pts stencil
00262   int m_numPhiGhost;
00263 
00264   // Number of ghost cells where it's necessary to compute the force
00265   int m_numForceGhost;
00266 
00267   // Number of components to define the levelData of Force. When the
00268   // force is staggered, this is 1 because we use a FluxBox which is a
00269   // Vector<*FAB> of dimension SpaceDim. Otherwise, this is SpaceDim.
00270   int m_nLevForceComp;
00271 
00272   // Physical dimension of the longest side of the domain
00273   Real m_domainLength;
00274 
00275   // code units class
00276   CodeUnits m_units;
00277 
00278   // whether or not the deltaPhi correction should be applied
00279   bool m_useDeltaPhiCorr;
00280 
00281   // Interpolation from coarse to fine level
00282   FineInterp m_fineInterp;
00283 
00284   // Averaging from fine to coarse level
00285   CoarseAverage m_coarseAverage;
00286 
00287   // Interpolation from coarse to fine level
00288   FineInterp m_fineInterpPhi;
00289 
00290   // Averaging from fine to coarse level
00291   CoarseAverage m_coarseAveragePhi;
00292 
00293   // Interpolator for filling in ghost cells from the next coarser level
00294   PiecewiseLinearFillPatch m_patcher;
00295 
00296   // 2nd order interpolant for filling in ghost cells from next coarser level
00297   QuadCFInterp m_quadCFInterp;
00298 
00299   // Interpolator for filling in force ghost cells from the next coarser level
00300   PiecewiseLinearFillPatch     m_forcePatcher;
00301 
00302   // Level integrator for hydro
00303   LevelGodunov m_levelGodunov;
00304 
00305   // Level solver for elliptic problems
00306   LevelSolver m_levelSolver;
00307 
00308   // Flux register
00309   LevelFluxRegister m_fluxRegister;
00310 
00311   // gradient operator
00312   Gradient* m_gradient;
00313 
00314   // Patch integrator
00315   SelfGravityPhysics* m_gdnvPhysics;
00316 
00317   // Poisson operator
00318   LevelOp* m_poissonOp;
00319 
00320   // Class that tags cells for refinement
00321   RefCellTagger* m_refCellTagger;
00322 
00323   // max level of refinement at start
00324   int m_maxInitRefLevel;
00325 
00326   // Tag buffer size
00327   int m_tagBufferSize;
00328 
00329   // Flag coarser and finer levels
00330   bool m_hasCoarser;
00331   bool m_hasFiner;
00332 
00333   // boolean stating whether or not this is the FINEst lev.
00334   bool m_isThisFinestLev;
00335 
00336   // Order of the normal predictor (1 -> PLM, 2-> PPM)
00337   int m_normalPredOrder;
00338 
00339   // Use 4th order slope computations (otherwise, use 2nd order)
00340   bool m_useFourthOrderSlopes;
00341 
00342   // Do slope limiting in the primitive or characteristic variables, respect.
00343   bool m_usePrimLimiting;
00344   bool m_useCharLimiting;
00345 
00346   // Do slope flattening - MUST BE USING 4th order slopes
00347   bool m_useFlattening;
00348 
00349   // Apply artificial viscosity of a set value
00350   bool m_useArtificialViscosity;
00351   Real m_artificialViscosity;
00352 
00353   //
00354   DisjointBoxLayout m_grids;
00355 
00356   // True if all the parameters for this object are defined
00357   bool m_paramsDefined;
00358 
00359 private:
00360   // Disallowed for all the usual reasons
00361   void operator=(const AMRLevelSelfGravity& a_input)
00362   {
00363     MayDay::Error("invalid operator");
00364   }
00365 
00366   // Disallowed for all the usual reasons
00367   AMRLevelSelfGravity(const AMRLevelSelfGravity& a_input)
00368   {
00369     MayDay::Error("invalid operator");
00370   }
00371 };
00372 
00373 #endif

Generated on Wed Oct 5 13:52:08 2005 for Chombo&AMRSelfGravity by  doxygen 1.4.1