Chombo + EB + MF  3.2
PolytropicPhysics.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _POLYTROPICPHYSICS_H_
12 #define _POLYTROPICPHYSICS_H_
13 
14 #include <string>
15 using std::string;
16 
17 #include "Box.H"
18 #include "IntVectSet.H"
19 #include "Vector.H"
20 #include "CH_HDF5.H"
21 
22 #include "GodunovPhysics.H"
23 
24 #include "NamespaceHeader.H"
25 
26 ///
27 /**
28  The base class PolytropicPhysics provides the physics-dependent components
29  for a higher-order method for a single patch: characteristic
30  analysis, Riemann solver, quasilinear update, conservative update,
31  and transformations between conserved, primitive, and flux variables.
32  This class is essentially pure; i.e., all of its member functions
33  are; and the ones that have default implementations are ones
34  that are optionally defined; i.e., the default definition is to send
35  an error message. Physics-dependent versions of this class that are
36  required in real applications are derived from this class by inheritance.
37 */
39 {
40 public:
41  /// Constructor
42  /**
43  */
44  PolytropicPhysics(const Real& a_smallPressure);
45 
46  /// Destructor
47  /**
48  */
50 
51  /// Compute the maximum wave speed
52  /**
53  */
54  Real getMaxWaveSpeed(const FArrayBox& a_U,
55  const Box& a_box);
56 
57  /// Compute the speed of sound
58  /**
59  */
60  void soundSpeed(FArrayBox& a_speed,
61  const FArrayBox& a_U,
62  const Box& a_box);
63 
64  /// Object factory for this class
65  /**
66  */
67  virtual GodunovPhysics* new_godunovPhysics() const;
68 
69  /// Number of conserved variables
70  /**
71  Return the number of conserved variables.
72  */
73  int numConserved();
74 
75  /// Names of the conserved variables
76  /**
77  Return the names of the conserved variables. A default implementation is
78  provided that puts in generic names (i.e., "variable#" which "#" ranges
79  for 0 to numConserved()-1.
80  */
82 
83  /// Number of flux variables
84  /**
85  Return the number of flux variables. This can be greater than the number
86  of conserved variables if addition fluxes/face-centered quantities are
87  computed.
88  */
89  int numFluxes();
90 
91  /// Component index within the primitive variables of the density.
92  /**
93  Return the component index within the primitive variables for the
94  density. Used for fourth-order accurate artificial viscosity.
95  */
96  int densityIndex();
97 
98  /// Compute a flux from primitive variable values on a face
99  /**
100  */
101  void getFlux(FArrayBox& a_flux,
102  const FArrayBox& a_whalf,
103  const int& a_dir,
104  const Box& a_box);
105 
106  /// Number of primitive variables
107  /**
108  Return the number of primitive variables. This may be greater than the
109  number of conserved variables if derived/redundant quantities are also
110  stored for convenience.
111  */
112  int numPrimitives();
113 
114  /// Transform a_dW from primitive to characteristic variables
115  /**
116  On input, a_dW contains the increments of the primitive variables. On
117  output, it contains the increments in the characteristic variables.
118 
119  IMPORTANT NOTE: It is assumed that the characteristic analysis puts the
120  smallest eigenvalue first, the largest eigenvalue last, and orders the
121  characteristic variables accordingly.
122  */
123  void charAnalysis(FArrayBox& a_dW,
124  const FArrayBox& a_W,
125  const int& a_dir,
126  const Box& a_box);
127 
128  /// Transform a_dW from characteristic to primitive variables
129  /**
130  On input, a_dW contains the increments of the characteristic variables.
131  On output, it contains the increments in the primitive variables.
132 
133  IMPORTANT NOTE: It is assumed that the characteristic analysis puts the
134  smallest eigenvalue first, the largest eigenvalue last, and orders the
135  characteristic variables accordingly.
136  */
137  void charSynthesis(FArrayBox& a_dW,
138  const FArrayBox& a_W,
139  const int& a_dir,
140  const Box& a_box);
141 
142  /// Compute the characteristic values (eigenvalues)
143  /**
144  Compute the characteristic values (eigenvalues)
145 
146  IMPORTANT NOTE: It is assumed that the characteristic analysis puts the
147  smallest eigenvalue first, the largest eigenvalue last, and orders the
148  characteristic variables accordingly.
149  */
150  void charValues(FArrayBox& a_lambda,
151  const FArrayBox& a_W,
152  const int& a_dir,
153  const Box& a_box);
154 
155  /// Add to (increment) the source terms given the current state
156  /**
157  On input, a_S contains the current source terms. On output, a_S has
158  had any additional source terms (based on the current state, a_W)
159  added to it. This should all be done on the region defined by a_box.
160  */
161  void incrementSource(FArrayBox& a_S,
162  const FArrayBox& a_W,
163  const Box& a_box);
164 
165  /// Compute the solution to the Riemann problem.
166  /**
167  Given input left and right states in a direction, a_dir, compute a
168  Riemann problem and generate fluxes at the faces within a_box.
169  */
170  void riemann(FArrayBox& a_WStar,
171  const FArrayBox& a_WLeft,
172  const FArrayBox& a_WRight,
173  const FArrayBox& a_W,
174  const Real& a_time,
175  const int& a_dir,
176  const Box& a_box);
177 
178  /// Post-normal predictor calculation.
179  /**
180  Add increment to normal predictor, e.g. to account for source terms due to
181  spatially-varying coefficients, to bound primitive variable ranges.
182  */
183  virtual void postNormalPred(FArrayBox& a_dWMinus,
184  FArrayBox& a_dWPlus,
185  const FArrayBox& a_W,
186  const Real& a_dt,
187  const Real& a_dx,
188  const int& a_dir,
189  const Box& a_box);
190 
191  /// Compute the quasilinear update A*dW/dx.
192  /**
193  */
194  void quasilinearUpdate(FArrayBox& a_dWdx,
195  const FArrayBox& a_WHalf,
196  const FArrayBox& a_W,
197  const Real& a_scale,
198  const int& a_dir,
199  const Box& a_box);
200 
201  /// Compute primitive variables from conserved variables.
202  /**
203  */
204  void consToPrim(FArrayBox& a_W,
205  const FArrayBox& a_U,
206  const Box& a_box);
207 
208  /// Interval within the primitive variables corresponding to the velocities
209  /**
210  Return the interval of component indices within the primitive variable
211  of the velocities. Used for slope flattening (slope computation) and
212  computing the divergence of the velocity (artificial viscosity).
213  */
214  virtual Interval velocityInterval();
215 
216  /// Interval within the flux variables corresponding to vector flux
217  virtual Interval vectorFluxInterval();
218 
219  /// Component index within the primitive variables of the pressure
220  /**
221  Return the component index withn the primitive variables for the
222  pressure. Used for slope flattening (slope computation).
223  */
224  virtual int pressureIndex();
225 
226  /// Used to limit the absolute value of a "pressure" difference (away from zero)
227  /**
228  Return a value that is used by slope flattening to limit (away from
229  zero) the absolute value of a slope in the pressureIndex() component
230  (slope computation).
231  */
232  virtual Real smallPressure();
233 
234  /// Component index within the primitive variables of the bulk modulus
235  /**
236  Return the component index withn the primitive variables for the
237  bulk modulus. Used for slope flattening (slope computation) used
238  as a normalization to measure shock strength.
239  */
240  virtual int bulkModulusIndex();
241 
242 #ifdef CH_USE_HDF5
243  virtual void expressions(HDF5HeaderData& a_holder) const;
244 #endif
245 
246 protected:
247  // Used to limit the absolute value of a "pressure" difference (away from zero)
249 
250 
251 private:
252 
253  // Disallowed for all the usual reasons
254  void operator=(const PolytropicPhysics&);
256 };
257 
258 #include "NamespaceFooter.H"
259 
260 #endif
Vector< string > stateNames()
Names of the conserved variables.
void riemann(FArrayBox &a_WStar, const FArrayBox &a_WLeft, const FArrayBox &a_WRight, const FArrayBox &a_W, const Real &a_time, const int &a_dir, const Box &a_box)
Compute the solution to the Riemann problem.
virtual Real smallPressure()
Used to limit the absolute value of a "pressure" difference (away from zero)
void quasilinearUpdate(FArrayBox &a_dWdx, const FArrayBox &a_WHalf, const FArrayBox &a_W, const Real &a_scale, const int &a_dir, const Box &a_box)
Compute the quasilinear update A*dW/dx.
virtual void expressions(HDF5HeaderData &a_holder) const
data to be added to HDF5 files.
Definition: CH_HDF5.H:519
void charValues(FArrayBox &a_lambda, const FArrayBox &a_W, const int &a_dir, const Box &a_box)
Compute the characteristic values (eigenvalues)
Definition: PolytropicPhysics.H:38
~PolytropicPhysics()
Destructor.
int densityIndex()
Component index within the primitive variables of the density.
void operator=(const PolytropicPhysics &)
virtual int pressureIndex()
Component index within the primitive variables of the pressure.
Structure for passing component ranges in code.
Definition: Interval.H:23
int numFluxes()
Number of flux variables.
int numPrimitives()
Number of primitive variables.
void charAnalysis(FArrayBox &a_dW, const FArrayBox &a_W, const int &a_dir, const Box &a_box)
Transform a_dW from primitive to characteristic variables.
double Real
Definition: REAL.H:33
virtual Interval vectorFluxInterval()
Interval within the flux variables corresponding to vector flux.
virtual int bulkModulusIndex()
Component index within the primitive variables of the bulk modulus.
void incrementSource(FArrayBox &a_S, const FArrayBox &a_W, const Box &a_box)
Add to (increment) the source terms given the current state.
Definition: GodunovPhysics.H:40
virtual void postNormalPred(FArrayBox &a_dWMinus, FArrayBox &a_dWPlus, const FArrayBox &a_W, const Real &a_dt, const Real &a_dx, const int &a_dir, const Box &a_box)
Post-normal predictor calculation.
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
virtual GodunovPhysics * new_godunovPhysics() const
Object factory for this class.
Real m_smallPressure
Definition: PolytropicPhysics.H:248
int numConserved()
Number of conserved variables.
Definition: FArrayBox.H:45
PolytropicPhysics(const Real &a_smallPressure)
Constructor.
void consToPrim(FArrayBox &a_W, const FArrayBox &a_U, const Box &a_box)
Compute primitive variables from conserved variables.
void soundSpeed(FArrayBox &a_speed, const FArrayBox &a_U, const Box &a_box)
Compute the speed of sound.
void charSynthesis(FArrayBox &a_dW, const FArrayBox &a_W, const int &a_dir, const Box &a_box)
Transform a_dW from characteristic to primitive variables.
virtual Interval velocityInterval()
Interval within the primitive variables corresponding to the velocities.
void getFlux(FArrayBox &a_flux, const FArrayBox &a_whalf, const int &a_dir, const Box &a_box)
Compute a flux from primitive variable values on a face.
Real getMaxWaveSpeed(const FArrayBox &a_U, const Box &a_box)
Compute the maximum wave speed.