Chombo + EB  3.0
AdvectPhysics.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 _ADVECTPHYSICS_H_
12 #define _ADVECTPHYSICS_H_
13 
14 #include "GodunovPhysics.H"
15 #include "FluxBox.H"
16 
17 #include "NamespaceHeader.H"
18 
19 /// A class derived from GodunovPhysics for simple advection-diffusion problems
20 /**
21  */
23 {
24 public:
25  /// Constructor
26  /**
27  */
28  AdvectPhysics();
29 
30  /// Destructor
31  /**
32  */
34 
35  /// Factory method - this object is its own factory
36  /**
37  Return a pointer to new AdvectPhysics object with the same definition
38  as this object.
39  */
40  virtual GodunovPhysics* new_godunovPhysics() const;
41 
42  /// Compute the maximum wave speed
43  /**
44  */
45  virtual Real getMaxWaveSpeed(const FArrayBox& a_U,
46  const Box& a_box);
47 
48  /// COMPUTE fluxes from primitive values on a face ( advVel*wHalf)
49  /** Fluxes are computed as advVel*wHalf
50  */
51  virtual void getFlux(FArrayBox& a_flux,
52  const FArrayBox& a_WHalf,
53  const int& a_dir,
54  const Box& a_box);
55 
56  /// Transform a_dW from primitive to characteristic variables
57  /**
58  On input, a_dW contains the increments of the primitive variables. On
59  output, it contains the increments in the characteristic variables.
60 
61  IMPORTANT NOTE: It is assumed that the characteristic analysis puts the
62  smallest eigenvalue first, the largest eigenvalue last, and orders the
63  characteristic variables accordingly.
64  */
65  virtual void charAnalysis(FArrayBox& a_dW,
66  const FArrayBox& a_W,
67  const int& a_dir,
68  const Box& a_box)
69  {
70 
71  // This is the identity mapping for advection - do nothing
72  }
73 
74  /// Transform a_dW from characteristic to primitive variables
75  /**
76  On input, a_dW contains the increments of the characteristic variables.
77  On output, it contains the increments in the primitive variables.
78 
79  IMPORTANT NOTE: It is assumed that the characteristic analysis puts the
80  smallest eigenvalue first, the largest eigenvalue last, and orders the
81  characteristic variables accordingly.
82  */
83  virtual void charSynthesis(FArrayBox& a_dW,
84  const FArrayBox& a_W,
85  const int& a_dir,
86  const Box& a_box)
87  {
88 
89  // This is the identity mapping for advection - do nothing
90  }
91 
92  /// Compute the characteristic values (eigenvalues)
93  /**
94  Compute the characteristic values (eigenvalues).
95 
96  IMPORTANT NOTE: It is assumed that the characteristic analysis puts the
97  smallest eigenvalue first, the largest eigenvalue last, and orders the
98  characteristic variables accordingly.
99  */
100  virtual void charValues(FArrayBox& a_lambda,
101  const FArrayBox& a_W,
102  const int& a_dir,
103  const Box& a_box);
104 
105  /// Add to (increment) the source terms given the current state
106  /**
107  On input, a_S contains the current source terms. On output, a_S has
108  had any additional source terms (based on the current state, a_W)
109  added to it. This should all be done on the region defined by a_box.
110  */
111  virtual void incrementSource(FArrayBox& a_S,
112  const FArrayBox& a_W,
113  const Box& a_box)
114  {
115 
116  // The source term does not explicitly depend on the current primitive state
117  }
118 
119  /// Compute the solution to the Riemann problem.
120  /**
121  Given input left and right states in a direction, a_dir, compute a
122  Riemann problem and generate fluxes at the faces within a_box.
123  */
124  virtual void riemann(FArrayBox& a_WGdnv,
125  const FArrayBox& a_WLeft,
126  const FArrayBox& a_WRight,
127  const FArrayBox& a_W,
128  const Real& a_time,
129  const int& a_dir,
130  const Box& a_box);
131 
132  /// Post-normal predictor calculation.
133  /**
134  Add increment to normal predictor, e.g. to account for source terms due to
135  spatially-varying coefficients, to bound primitive variable ranges.
136  */
137  virtual void postNormalPred(FArrayBox& a_dWMinus,
138  FArrayBox& a_dWPlus,
139  const FArrayBox& a_W,
140  const Real& a_dt,
141  const Real& a_dx,
142  const int& a_dir,
143  const Box& a_box);
144 
145  /// Compute the quasilinear update A*dW/dx.
146  /**
147  */
148  virtual void quasilinearUpdate(FArrayBox& a_AdWdx,
149  const FArrayBox& a_WHalf,
150  const FArrayBox& a_W,
151  const Real& a_scale,
152  const int& a_dir,
153  const Box& a_box);
154 
155  /// Compute primitive variables from conserved variables.
156  /**
157  */
158  virtual void consToPrim(FArrayBox& a_W,
159  const FArrayBox& a_U,
160  const Box& a_box);
161 
162  /// Set cell-centered and face centered advection velocity
163  void setVelocities(FArrayBox* a_celVelPtr,
164  FluxBox* a_advVelPtr)
165  {
166  m_isVelSet = true;
167  m_advVelPtr = a_advVelPtr;
168  m_cellVelPtr = a_celVelPtr;
169  }
170 
171  /**
172  \name Access functions
173  */
174  /**@{*/
175 
176  /// Number of conserved variables
177  /**
178  Return the number of conserved variables.
179  */
180  virtual int numConserved()
181  {
182  return 1;
183  }
184 
185  /// Names of the conserved variables
186  /**
187  Return the names of the conserved variables.
188  */
190  {
191  Vector<string> retval(1, string("scalar"));
192 
193  return retval;
194  }
195 
196  /// Number of flux variables
197  /**
198  Return the number of flux variables. This can be greater than the
199  number of conserved variables if addition fluxes/face-centered
200  quantities are computed.
201  */
202  virtual int numFluxes()
203  {
204  return 1;
205  }
206 
207  /// Is the object completely defined
208  /**
209  Return true if the object is completely defined.
210  */
211  virtual bool isDefined() const
212  {
213  return m_isDefined;
214  }
215 
216  /// Number of primitve variables
217  /**
218  Return the number of primitive variables. This may be greater than the
219  number of conserved variables if derived/redundant quantities are also
220  stored for convenience.
221  */
222  virtual int numPrimitives()
223  {
224  return 1;
225  }
226 
227  /// Interval within the primitive variables corresponding to the velocities
228  /**
229  Return the interval of component indices within the primitive variable
230  of the velocities. Used for slope flattening (slope computation) and
231  computing the divergence of the velocity (artificial viscosity).
232  */
234  {
235  MayDay::Error("AdvectPhysics::velocityInterval - not defined");
236 
237  Interval retval(-1,-1);
238  return retval;
239  }
240 
241  /// Component index within the primitive variables of the pressure
242  /**
243  Return the component index withn the primitive variables for the
244  pressure. Used for slope flattening (slope computation).
245  // Component index within the primitive variables of the pressure
246  // since this doesn't apply to this set of equations, return a bogus value
247  */
248  virtual int pressureIndex()
249  {
250  MayDay::Error("AdvectPhysics::pressureIndex - not defined");
251 
252  return -1;
253  }
254 
255  /// Used to limit the absolute value of a "pressure" difference
256  /**
257  Return a value that is used by slope flattening to limit (away from
258  zero) the absolute value of a slope in the pressureIndex() component
259  (slope computation).
260  // Used to limit the absolute value of a "pressure" difference
261  // since this doesn't apply to this set of equations, return a bogus value
262  */
263  virtual Real smallPressure()
264  {
265  MayDay::Error("AdvectPhysics::smallPressure - not defined");
266 
267  return -1.0;
268  }
269 
270  /// Component index within the primitive variables of the bulk modulus
271  /**
272  Return the component index withn the primitive variables for the
273  bulk modulus. Used for slope flattening (slope computation) used
274  as a normalization to measure shock strength.
275  */
276  virtual int bulkModulusIndex()
277  {
278  MayDay::Error("AdvectPhysics::bulkModulusIndex - not defined");
279 
280  return -1;
281  }
282 
283  /// Component index within the primitive variables of the density
284  /**
285  Return the component index withn the primitive variables for the
286  density. Not defined for AdvectPhysics.
287  */
288  virtual int densityIndex()
289  {
290  MayDay::Error("AdvectPhysics::bulkModulusIndex - not defined");
291 
292  return -1;
293  }
294 
295  /**@}*/
296 
297 protected:
299  /// face-centered advection velocity
301 
302  /// cell-centered advection velocity (centered at old time)
304 
305 };
306 
307 #include "NamespaceFooter.H"
308 #endif
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.
virtual Real smallPressure()
Used to limit the absolute value of a "pressure" difference.
Definition: AdvectPhysics.H:263
virtual 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.
Definition: AdvectPhysics.H:83
void setVelocities(FArrayBox *a_celVelPtr, FluxBox *a_advVelPtr)
Set cell-centered and face centered advection velocity.
Definition: AdvectPhysics.H:163
virtual void consToPrim(FArrayBox &a_W, const FArrayBox &a_U, const Box &a_box)
Compute primitive variables from conserved variables.
AdvectPhysics()
Constructor.
virtual int numFluxes()
Number of flux variables.
Definition: AdvectPhysics.H:202
virtual int bulkModulusIndex()
Component index within the primitive variables of the bulk modulus.
Definition: AdvectPhysics.H:276
FArrayBox * m_cellVelPtr
cell-centered advection velocity (centered at old time)
Definition: AdvectPhysics.H:303
virtual Interval velocityInterval()
Interval within the primitive variables corresponding to the velocities.
Definition: AdvectPhysics.H:233
A FArrayBox-like container for face-centered fluxes.
Definition: FluxBox.H:22
virtual GodunovPhysics * new_godunovPhysics() const
Factory method - this object is its own factory.
Structure for passing component ranges in code.
Definition: Interval.H:23
virtual Vector< string > stateNames()
Names of the conserved variables.
Definition: AdvectPhysics.H:189
virtual void riemann(FArrayBox &a_WGdnv, 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.
double Real
Definition: REAL.H:33
virtual int densityIndex()
Component index within the primitive variables of the density.
Definition: AdvectPhysics.H:288
virtual void getFlux(FArrayBox &a_flux, const FArrayBox &a_WHalf, const int &a_dir, const Box &a_box)
COMPUTE fluxes from primitive values on a face ( advVel*wHalf)
bool m_isVelSet
Definition: AdvectPhysics.H:298
virtual void charValues(FArrayBox &a_lambda, const FArrayBox &a_W, const int &a_dir, const Box &a_box)
Compute the characteristic values (eigenvalues)
virtual bool isDefined() const
Is the object completely defined.
Definition: AdvectPhysics.H:211
virtual void quasilinearUpdate(FArrayBox &a_AdWdx, 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.
static void Error(const char *const a_msg=m_nullString, int m_exitCode=CH_DEFAULT_ERROR_CODE)
Print out message to cerr and exit with the specified exit code.
Definition: GodunovPhysics.H:40
virtual void incrementSource(FArrayBox &a_S, const FArrayBox &a_W, const Box &a_box)
Add to (increment) the source terms given the current state.
Definition: AdvectPhysics.H:111
A class derived from GodunovPhysics for simple advection-diffusion problems.
Definition: AdvectPhysics.H:22
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
virtual Real getMaxWaveSpeed(const FArrayBox &a_U, const Box &a_box)
Compute the maximum wave speed.
virtual 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.
Definition: AdvectPhysics.H:65
bool m_isDefined
Definition: GodunovPhysics.H:336
FluxBox * m_advVelPtr
face-centered advection velocity
Definition: AdvectPhysics.H:300
Definition: FArrayBox.H:44
virtual int numPrimitives()
Number of primitve variables.
Definition: AdvectPhysics.H:222
virtual int numConserved()
Number of conserved variables.
Definition: AdvectPhysics.H:180
virtual int pressureIndex()
Component index within the primitive variables of the pressure.
Definition: AdvectPhysics.H:248
~AdvectPhysics()
Destructor.