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 _ADVECTPHYSICS_H_ 00012 #define _ADVECTPHYSICS_H_ 00013 00014 #include "GodunovPhysics.H" 00015 #include "FluxBox.H" 00016 00017 #include "NamespaceHeader.H" 00018 00019 /// A class derived from GodunovPhysics for simple advection-diffusion problems 00020 /** 00021 */ 00022 class AdvectPhysics : public GodunovPhysics 00023 { 00024 public: 00025 /// Constructor 00026 /** 00027 */ 00028 AdvectPhysics(); 00029 00030 /// Destructor 00031 /** 00032 */ 00033 ~AdvectPhysics(); 00034 00035 /// Factory method - this object is its own factory 00036 /** 00037 Return a pointer to new AdvectPhysics object with the same definition 00038 as this object. 00039 */ 00040 virtual GodunovPhysics* new_godunovPhysics() const; 00041 00042 /// Compute the maximum wave speed 00043 /** 00044 */ 00045 virtual Real getMaxWaveSpeed(const FArrayBox& a_U, 00046 const Box& a_box); 00047 00048 /// COMPUTE fluxes from primitive values on a face ( advVel*wHalf) 00049 /** Fluxes are computed as advVel*wHalf 00050 */ 00051 virtual void getFlux(FArrayBox& a_flux, 00052 const FArrayBox& a_WHalf, 00053 const int& a_dir, 00054 const Box& a_box); 00055 00056 /// Transform a_dW from primitive to characteristic variables 00057 /** 00058 On input, a_dW contains the increments of the primitive variables. On 00059 output, it contains the increments in the characteristic variables. 00060 00061 IMPORTANT NOTE: It is assumed that the characteristic analysis puts the 00062 smallest eigenvalue first, the largest eigenvalue last, and orders the 00063 characteristic variables accordingly. 00064 */ 00065 virtual void charAnalysis(FArrayBox& a_dW, 00066 const FArrayBox& a_W, 00067 const int& a_dir, 00068 const Box& a_box) 00069 { 00070 00071 // This is the identity mapping for advection - do nothing 00072 } 00073 00074 /// Transform a_dW from characteristic to primitive variables 00075 /** 00076 On input, a_dW contains the increments of the characteristic variables. 00077 On output, it contains the increments in the primitive variables. 00078 00079 IMPORTANT NOTE: It is assumed that the characteristic analysis puts the 00080 smallest eigenvalue first, the largest eigenvalue last, and orders the 00081 characteristic variables accordingly. 00082 */ 00083 virtual void charSynthesis(FArrayBox& a_dW, 00084 const FArrayBox& a_W, 00085 const int& a_dir, 00086 const Box& a_box) 00087 { 00088 00089 // This is the identity mapping for advection - do nothing 00090 } 00091 00092 /// Compute the characteristic values (eigenvalues) 00093 /** 00094 Compute the characteristic values (eigenvalues). 00095 00096 IMPORTANT NOTE: It is assumed that the characteristic analysis puts the 00097 smallest eigenvalue first, the largest eigenvalue last, and orders the 00098 characteristic variables accordingly. 00099 */ 00100 virtual void charValues(FArrayBox& a_lambda, 00101 const FArrayBox& a_W, 00102 const int& a_dir, 00103 const Box& a_box); 00104 00105 /// Add to (increment) the source terms given the current state 00106 /** 00107 On input, a_S contains the current source terms. On output, a_S has 00108 had any additional source terms (based on the current state, a_W) 00109 added to it. This should all be done on the region defined by a_box. 00110 */ 00111 virtual void incrementSource(FArrayBox& a_S, 00112 const FArrayBox& a_W, 00113 const Box& a_box) 00114 { 00115 00116 // The source term does not explicitly depend on the current primitive state 00117 } 00118 00119 /// Compute the solution to the Riemann problem. 00120 /** 00121 Given input left and right states in a direction, a_dir, compute a 00122 Riemann problem and generate fluxes at the faces within a_box. 00123 */ 00124 virtual void riemann(FArrayBox& a_WGdnv, 00125 const FArrayBox& a_WLeft, 00126 const FArrayBox& a_WRight, 00127 const FArrayBox& a_W, 00128 const Real& a_time, 00129 const int& a_dir, 00130 const Box& a_box); 00131 00132 /// Post-normal predictor calculation. 00133 /** 00134 Add increment to normal predictor, e.g. to account for source terms due to 00135 spatially-varying coefficients, to bound primitive variable ranges. 00136 */ 00137 virtual void postNormalPred(FArrayBox& a_dWMinus, 00138 FArrayBox& a_dWPlus, 00139 const FArrayBox& a_W, 00140 const Real& a_dt, 00141 const Real& a_dx, 00142 const int& a_dir, 00143 const Box& a_box); 00144 00145 /// Compute the quasilinear update A*dW/dx. 00146 /** 00147 */ 00148 virtual void quasilinearUpdate(FArrayBox& a_AdWdx, 00149 const FArrayBox& a_WHalf, 00150 const FArrayBox& a_W, 00151 const Real& a_scale, 00152 const int& a_dir, 00153 const Box& a_box); 00154 00155 /// Compute primitive variables from conserved variables. 00156 /** 00157 */ 00158 virtual void consToPrim(FArrayBox& a_W, 00159 const FArrayBox& a_U, 00160 const Box& a_box); 00161 00162 /// Set cell-centered and face centered advection velocity 00163 void setVelocities(FArrayBox* a_celVelPtr, 00164 FluxBox* a_advVelPtr) 00165 { 00166 m_isVelSet = true; 00167 m_advVelPtr = a_advVelPtr; 00168 m_cellVelPtr = a_celVelPtr; 00169 } 00170 00171 /** 00172 \name Access functions 00173 */ 00174 /**@{*/ 00175 00176 /// Number of conserved variables 00177 /** 00178 Return the number of conserved variables. 00179 */ 00180 virtual int numConserved() 00181 { 00182 return 1; 00183 } 00184 00185 /// Names of the conserved variables 00186 /** 00187 Return the names of the conserved variables. 00188 */ 00189 virtual Vector<string> stateNames() 00190 { 00191 Vector<string> retval(1, string("scalar")); 00192 00193 return retval; 00194 } 00195 00196 /// Number of flux variables 00197 /** 00198 Return the number of flux variables. This can be greater than the 00199 number of conserved variables if addition fluxes/face-centered 00200 quantities are computed. 00201 */ 00202 virtual int numFluxes() 00203 { 00204 return 1; 00205 } 00206 00207 /// Is the object completely defined 00208 /** 00209 Return true if the object is completely defined. 00210 */ 00211 virtual bool isDefined() const 00212 { 00213 return m_isDefined; 00214 } 00215 00216 /// Number of primitve variables 00217 /** 00218 Return the number of primitive variables. This may be greater than the 00219 number of conserved variables if derived/redundant quantities are also 00220 stored for convenience. 00221 */ 00222 virtual int numPrimitives() 00223 { 00224 return 1; 00225 } 00226 00227 /// Interval within the primitive variables corresponding to the velocities 00228 /** 00229 Return the interval of component indices within the primitive variable 00230 of the velocities. Used for slope flattening (slope computation) and 00231 computing the divergence of the velocity (artificial viscosity). 00232 */ 00233 virtual Interval velocityInterval() 00234 { 00235 MayDay::Error("AdvectPhysics::velocityInterval - not defined"); 00236 00237 Interval retval(-1,-1); 00238 return retval; 00239 } 00240 00241 /// Component index within the primitive variables of the pressure 00242 /** 00243 Return the component index withn the primitive variables for the 00244 pressure. Used for slope flattening (slope computation). 00245 // Component index within the primitive variables of the pressure 00246 // since this doesn't apply to this set of equations, return a bogus value 00247 */ 00248 virtual int pressureIndex() 00249 { 00250 MayDay::Error("AdvectPhysics::pressureIndex - not defined"); 00251 00252 return -1; 00253 } 00254 00255 /// Used to limit the absolute value of a "pressure" difference 00256 /** 00257 Return a value that is used by slope flattening to limit (away from 00258 zero) the absolute value of a slope in the pressureIndex() component 00259 (slope computation). 00260 // Used to limit the absolute value of a "pressure" difference 00261 // since this doesn't apply to this set of equations, return a bogus value 00262 */ 00263 virtual Real smallPressure() 00264 { 00265 MayDay::Error("AdvectPhysics::smallPressure - not defined"); 00266 00267 return -1.0; 00268 } 00269 00270 /// Component index within the primitive variables of the bulk modulus 00271 /** 00272 Return the component index withn the primitive variables for the 00273 bulk modulus. Used for slope flattening (slope computation) used 00274 as a normalization to measure shock strength. 00275 */ 00276 virtual int bulkModulusIndex() 00277 { 00278 MayDay::Error("AdvectPhysics::bulkModulusIndex - not defined"); 00279 00280 return -1; 00281 } 00282 00283 /// Component index within the primitive variables of the density 00284 /** 00285 Return the component index withn the primitive variables for the 00286 density. Not defined for AdvectPhysics. 00287 */ 00288 virtual int densityIndex() 00289 { 00290 MayDay::Error("AdvectPhysics::bulkModulusIndex - not defined"); 00291 00292 return -1; 00293 } 00294 00295 /**@}*/ 00296 00297 protected: 00298 bool m_isVelSet; 00299 /// face-centered advection velocity 00300 FluxBox* m_advVelPtr; 00301 00302 /// cell-centered advection velocity (centered at old time) 00303 FArrayBox* m_cellVelPtr; 00304 00305 }; 00306 00307 #include "NamespaceFooter.H" 00308 #endif