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 _POLYTROPICPHYSICS_H_ 00012 #define _POLYTROPICPHYSICS_H_ 00013 00014 #include <string> 00015 using std::string; 00016 00017 #include "Box.H" 00018 #include "IntVectSet.H" 00019 #include "Vector.H" 00020 #include "CH_HDF5.H" 00021 00022 #include "GodunovPhysics.H" 00023 00024 #include "NamespaceHeader.H" 00025 00026 /// 00027 /** 00028 The base class PolytropicPhysics provides the physics-dependent components 00029 for a higher-order method for a single patch: characteristic 00030 analysis, Riemann solver, quasilinear update, conservative update, 00031 and transformations between conserved, primitive, and flux variables. 00032 This class is essentially pure; i.e., all of its member functions 00033 are; and the ones that have default implementations are ones 00034 that are optionally defined; i.e., the default definition is to send 00035 an error message. Physics-dependent versions of this class that are 00036 required in real applications are derived from this class by inheritance. 00037 */ 00038 class PolytropicPhysics: public GodunovPhysics 00039 { 00040 public: 00041 /// Constructor 00042 /** 00043 */ 00044 PolytropicPhysics(const Real& a_smallPressure); 00045 00046 /// Destructor 00047 /** 00048 */ 00049 ~PolytropicPhysics(); 00050 00051 /// Compute the maximum wave speed 00052 /** 00053 */ 00054 Real getMaxWaveSpeed(const FArrayBox& a_U, 00055 const Box& a_box); 00056 00057 /// Compute the speed of sound 00058 /** 00059 */ 00060 void soundSpeed(FArrayBox& a_speed, 00061 const FArrayBox& a_U, 00062 const Box& a_box); 00063 00064 /// Object factory for this class 00065 /** 00066 */ 00067 virtual GodunovPhysics* new_godunovPhysics() const; 00068 00069 /// Number of conserved variables 00070 /** 00071 Return the number of conserved variables. 00072 */ 00073 int numConserved(); 00074 00075 /// Names of the conserved variables 00076 /** 00077 Return the names of the conserved variables. A default implementation is 00078 provided that puts in generic names (i.e., "variable#" which "#" ranges 00079 for 0 to numConserved()-1. 00080 */ 00081 Vector<string> stateNames(); 00082 00083 /// Number of flux variables 00084 /** 00085 Return the number of flux variables. This can be greater than the number 00086 of conserved variables if addition fluxes/face-centered quantities are 00087 computed. 00088 */ 00089 int numFluxes(); 00090 00091 /// Component index within the primitive variables of the density. 00092 /** 00093 Return the component index within the primitive variables for the 00094 density. Used for fourth-order accurate artificial viscosity. 00095 */ 00096 int densityIndex(); 00097 00098 /// Compute a flux from primitive variable values on a face 00099 /** 00100 */ 00101 void getFlux(FArrayBox& a_flux, 00102 const FArrayBox& a_whalf, 00103 const int& a_dir, 00104 const Box& a_box); 00105 00106 /// Number of primitive variables 00107 /** 00108 Return the number of primitive variables. This may be greater than the 00109 number of conserved variables if derived/redundant quantities are also 00110 stored for convenience. 00111 */ 00112 int numPrimitives(); 00113 00114 /// Transform a_dW from primitive to characteristic variables 00115 /** 00116 On input, a_dW contains the increments of the primitive variables. On 00117 output, it contains the increments in the characteristic variables. 00118 00119 IMPORTANT NOTE: It is assumed that the characteristic analysis puts the 00120 smallest eigenvalue first, the largest eigenvalue last, and orders the 00121 characteristic variables accordingly. 00122 */ 00123 void charAnalysis(FArrayBox& a_dW, 00124 const FArrayBox& a_W, 00125 const int& a_dir, 00126 const Box& a_box); 00127 00128 /// Transform a_dW from characteristic to primitive variables 00129 /** 00130 On input, a_dW contains the increments of the characteristic variables. 00131 On output, it contains the increments in the primitive variables. 00132 00133 IMPORTANT NOTE: It is assumed that the characteristic analysis puts the 00134 smallest eigenvalue first, the largest eigenvalue last, and orders the 00135 characteristic variables accordingly. 00136 */ 00137 void charSynthesis(FArrayBox& a_dW, 00138 const FArrayBox& a_W, 00139 const int& a_dir, 00140 const Box& a_box); 00141 00142 /// Compute the characteristic values (eigenvalues) 00143 /** 00144 Compute the characteristic values (eigenvalues) 00145 00146 IMPORTANT NOTE: It is assumed that the characteristic analysis puts the 00147 smallest eigenvalue first, the largest eigenvalue last, and orders the 00148 characteristic variables accordingly. 00149 */ 00150 void charValues(FArrayBox& a_lambda, 00151 const FArrayBox& a_W, 00152 const int& a_dir, 00153 const Box& a_box); 00154 00155 /// Add to (increment) the source terms given the current state 00156 /** 00157 On input, a_S contains the current source terms. On output, a_S has 00158 had any additional source terms (based on the current state, a_W) 00159 added to it. This should all be done on the region defined by a_box. 00160 */ 00161 void incrementSource(FArrayBox& a_S, 00162 const FArrayBox& a_W, 00163 const Box& a_box); 00164 00165 /// Compute the solution to the Riemann problem. 00166 /** 00167 Given input left and right states in a direction, a_dir, compute a 00168 Riemann problem and generate fluxes at the faces within a_box. 00169 */ 00170 void riemann(FArrayBox& a_WStar, 00171 const FArrayBox& a_WLeft, 00172 const FArrayBox& a_WRight, 00173 const FArrayBox& a_W, 00174 const Real& a_time, 00175 const int& a_dir, 00176 const Box& a_box); 00177 00178 /// Post-normal predictor calculation. 00179 /** 00180 Add increment to normal predictor, e.g. to account for source terms due to 00181 spatially-varying coefficients, to bound primitive variable ranges. 00182 */ 00183 virtual void postNormalPred(FArrayBox& a_dWMinus, 00184 FArrayBox& a_dWPlus, 00185 const FArrayBox& a_W, 00186 const Real& a_dt, 00187 const Real& a_dx, 00188 const int& a_dir, 00189 const Box& a_box); 00190 00191 /// Compute the quasilinear update A*dW/dx. 00192 /** 00193 */ 00194 void quasilinearUpdate(FArrayBox& a_dWdx, 00195 const FArrayBox& a_WHalf, 00196 const FArrayBox& a_W, 00197 const Real& a_scale, 00198 const int& a_dir, 00199 const Box& a_box); 00200 00201 /// Compute primitive variables from conserved variables. 00202 /** 00203 */ 00204 void consToPrim(FArrayBox& a_W, 00205 const FArrayBox& a_U, 00206 const Box& a_box); 00207 00208 /// Interval within the primitive variables corresponding to the velocities 00209 /** 00210 Return the interval of component indices within the primitive variable 00211 of the velocities. Used for slope flattening (slope computation) and 00212 computing the divergence of the velocity (artificial viscosity). 00213 */ 00214 virtual Interval velocityInterval(); 00215 00216 /// Interval within the flux variables corresponding to vector flux 00217 virtual Interval vectorFluxInterval(); 00218 00219 /// Component index within the primitive variables of the pressure 00220 /** 00221 Return the component index withn the primitive variables for the 00222 pressure. Used for slope flattening (slope computation). 00223 */ 00224 virtual int pressureIndex(); 00225 00226 /// Used to limit the absolute value of a "pressure" difference (away from zero) 00227 /** 00228 Return a value that is used by slope flattening to limit (away from 00229 zero) the absolute value of a slope in the pressureIndex() component 00230 (slope computation). 00231 */ 00232 virtual Real smallPressure(); 00233 00234 /// Component index within the primitive variables of the bulk modulus 00235 /** 00236 Return the component index withn the primitive variables for the 00237 bulk modulus. Used for slope flattening (slope computation) used 00238 as a normalization to measure shock strength. 00239 */ 00240 virtual int bulkModulusIndex(); 00241 00242 #ifdef CH_USE_HDF5 00243 virtual void expressions(HDF5HeaderData& a_holder) const; 00244 #endif 00245 00246 protected: 00247 // Used to limit the absolute value of a "pressure" difference (away from zero) 00248 Real m_smallPressure; 00249 00250 00251 private: 00252 00253 // Disallowed for all the usual reasons 00254 void operator=(const PolytropicPhysics&); 00255 PolytropicPhysics(const PolytropicPhysics&); 00256 }; 00257 00258 #include "NamespaceFooter.H" 00259 00260 #endif