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 _LEVELGODUNOV_H_ 00012 #define _LEVELGODUNOV_H_ 00013 00014 #include "FArrayBox.H" 00015 #include "FluxBox.H" 00016 #include "DisjointBoxLayout.H" 00017 #include "LevelData.H" 00018 #include "PiecewiseLinearFillPatch.H" 00019 #include "LevelFluxRegister.H" 00020 #include "ProblemDomain.H" 00021 #include "Copier.H" 00022 00023 #include "PatchGodunov.H" 00024 #include "NamespaceHeader.H" 00025 00026 /// Level Godunov - really a hyperbolic level integrator 00027 /** 00028 */ 00029 class LevelGodunov 00030 { 00031 public: 00032 /// Default constructor 00033 /** 00034 Object requires define() to be called before all other functions. 00035 */ 00036 LevelGodunov(); 00037 00038 /// Destructor 00039 /** 00040 Destroys all objects created by define(). Passed in data references 00041 of define() are left alone. 00042 */ 00043 ~LevelGodunov(); 00044 00045 /// Actual constructor. 00046 /** 00047 Inside the routine, we cast away const-ness on the data members 00048 for the assignment. The arguments passed in are maintained const 00049 (coding standards). 00050 */ 00051 void define(/// box layout at this level 00052 const DisjointBoxLayout& a_thisDisjointBoxLayout, 00053 /// box layout at next coarser level (or empty if this is coarsest level) 00054 const DisjointBoxLayout& a_coarserDisjointBoxLayout, 00055 /// problem domain at this level 00056 const ProblemDomain& a_domain, 00057 /// refinement ratio between this level and next coarser level 00058 const int& a_refineCoarse, 00059 /// grid spacing at this level 00060 const Real& a_dx, 00061 /// pointer to GodunovPhysics class 00062 const GodunovPhysics* const a_godunovFactory, 00063 /// order of the normal predictor: 1 for PLM, 2 for PPM 00064 const int& a_normalPredOrder, 00065 /// whether to use 4th-order slopes 00066 const bool& a_useFourthOrderSlopes, 00067 /// whether to apply slope limiting to primitive variables 00068 const bool& a_usePrimLimiting, 00069 /// whether to apply slope limiting to characteristic variables 00070 const bool& a_useCharLimiting, 00071 /// whether to apply slope flattening 00072 const bool& a_useFlattening, 00073 /// whether to apply artificial viscosity 00074 const bool& a_useArtificialViscosity, 00075 /// artificial viscosity coefficient 00076 const Real& a_artificialViscosity, 00077 /// whether there is a coarser level 00078 const bool& a_hasCoarser, 00079 /// whether there is a finer level 00080 const bool& a_hasFiner); 00081 00082 /// Take one timestep for this grid level. 00083 Real step(/// conserved variables at this level, defined on a_thisDisjointBoxLayout in define() 00084 LevelData<FArrayBox>& a_U, 00085 /// flux, for passing face-centered data in and out of the function 00086 LevelData<FArrayBox> a_flux[CH_SPACEDIM], 00087 /// flux register with next finer level 00088 LevelFluxRegister& a_finerFluxRegister, 00089 /// flux register with next coarser level 00090 LevelFluxRegister& a_coarserFluxRegister, 00091 /// source term, or if no source term then this is null constructed and not defined 00092 const LevelData<FArrayBox>& a_S, 00093 /// conserved variables at coarser level at time of last coarser-level update, or empty if no coarser level; may be empty if interpolation not required 00094 const LevelData<FArrayBox>& a_UCoarseOld, 00095 /// time of last update at coarser level 00096 const Real& a_TCoarseOld, 00097 /// conserved variables at coarser level at time of next coarser-level update, or empty if no coarser level; may be empty if interpolation not required 00098 const LevelData<FArrayBox>& a_UCoarseNew, 00099 /// time of next update at coarser level 00100 const Real& a_TCoarseNew, 00101 /// current time 00102 const Real& a_time, 00103 /// time step 00104 const Real& a_dt); 00105 00106 /// Compute the time-centered values of the primitive variables on cell faces. 00107 /** 00108 This API is used in cases where some operation over the whole 00109 level must be performed on the face-centered variables prior to 00110 the final difference update. Examples include incompressible 00111 flow and MHD, in which it is necessary to compute the projection 00112 of a face-centered vector field on its divergence-free part. To 00113 complete the differencing, it is necessary to call the member 00114 function computeUpdate(). 00115 */ 00116 void computeWHalf(/// primitive variables extrapolated to cell faces and a half time step 00117 LayoutData<FluxBox>& a_WHalf, 00118 /// conserved variables on current grids 00119 LevelData<FArrayBox>& a_U, 00120 /// source term on current grid 00121 const LevelData<FArrayBox>& a_S, 00122 /// conserved variables at coarser level at time of last coarser-level update, or empty if no coarser level; may be empty if interpolation not required 00123 const LevelData<FArrayBox>& a_UCoarseOld, 00124 /// time of last update at coarser level 00125 const Real& a_TCoarseOld, 00126 /// conserved variables at coarser level at time of next coarser-level update, or empty if no coarser level; may be empty if interpolation not required 00127 const LevelData<FArrayBox>& a_UCoarseNew, 00128 /// time of next update at coarser level 00129 const Real& a_TCoarseNew, 00130 /// current time 00131 const Real& a_time, 00132 /// time step 00133 const Real& a_dt); 00134 00135 /// Compute the increment in the conserved variables from face variables. 00136 /** 00137 Compute dU = dt*dU/dt, the change in the conserved variables over 00138 the time step. Function returns the maximum stable time step. 00139 */ 00140 Real computeUpdate(/// change in conserved variables over the time step 00141 LevelData<FArrayBox>& a_dU, 00142 /// flux register with next finer level 00143 LevelFluxRegister& a_finerFluxRegister, 00144 /// flux register with next coarser level 00145 LevelFluxRegister& a_coarserFluxRegister, 00146 /// conserved variables at beginning of time step 00147 const LevelData<FArrayBox>& a_U, 00148 /// primitive variables extrapolated to cell faces and a half time step 00149 const LayoutData<FluxBox>& a_WHalf, 00150 /// current time 00151 const Real& a_time, 00152 /// time step 00153 const Real& a_dt); 00154 00155 /// Return maximum wave speed 00156 /** 00157 */ 00158 Real getMaxWaveSpeed(const LevelData<FArrayBox>& a_U); 00159 00160 /// Get the GodunovPhysics pointer from the PatchGodunov member 00161 /** 00162 Returns the pointer to the GodunovPhysics object that is 00163 used in the PatchGodunov class. 00164 */ 00165 GodunovPhysics* getGodunovPhysicsPtr(); 00166 00167 const GodunovPhysics* getGodunovPhysicsPtrConst() const ; 00168 00169 /// Set whether to use high-order limiter. 00170 void highOrderLimiter(bool a_highOrderLimiter); 00171 00172 protected: 00173 // Box layout for this level 00174 DisjointBoxLayout m_grids; 00175 00176 // Patch integrator 00177 LayoutData<PatchGodunov> m_patchGodunov; 00178 00179 ///just for global calls 00180 PatchGodunov m_patchGodunovNoBox; 00181 // Number of ghost cells need locally for this level 00182 int m_numGhost; 00183 00184 // Exchange copier 00185 Copier m_exchangeCopier; 00186 00187 // Temporary storage space for conserved variables 00188 LevelData<FArrayBox> m_U; 00189 00190 // Interpolator for filling in ghost cells from the next coarser level 00191 PiecewiseLinearFillPatch m_patcher; 00192 00193 // Grid spacing 00194 Real m_dx; 00195 00196 // Problem domain - index space for this level 00197 ProblemDomain m_domain; 00198 00199 // Refinement ratio between this level and the next coarser 00200 int m_refineCoarse; 00201 00202 // Number of conserved variables 00203 int m_numCons; 00204 00205 // Number of conservative fluxes and other face centered quantities 00206 int m_numFluxes; 00207 00208 // Flags for the existence of coarser and finer levels, respectively 00209 bool m_hasCoarser; 00210 bool m_hasFiner; 00211 00212 // Order of the normal predictor (1 -> PLM, 2-> PPM) 00213 int m_normalPredOrder; 00214 00215 // Use 4th order slope computations (otherwise, use 2nd order) 00216 bool m_useFourthOrderSlopes; 00217 00218 // Do slope limiting in the primitive or characteristic variables, respect. 00219 bool m_usePrimLimiting; 00220 bool m_useCharLimiting; 00221 00222 // Do slope flattening - MUST BE USING 4th order slopes 00223 bool m_useFlattening; 00224 00225 // Apply artificial viscosity of a set value 00226 bool m_useArtificialViscosity; 00227 Real m_artificialViscosity; 00228 00229 // Has this object been defined 00230 bool m_isDefined; 00231 00232 00233 private: 00234 00235 // Disallowed for all the usual reasons 00236 void operator=(const LevelGodunov&); 00237 LevelGodunov(const LevelGodunov&); 00238 }; 00239 00240 #include "NamespaceFooter.H" 00241 #endif