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

Generated on Wed Oct 19 13:33:47 2005 for Chombo&AMRSelfGravity by doxygen 1.3.2