Chombo + EB + MF  3.2
MOLPhysics.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 _MOLPHYSICS_H_
12 #define _MOLPHYSICS_H_
13 
14 #include <string>
15 using std::string;
16 
17 #include "FArrayBox.H"
18 #include "Vector.H"
19 #include "PhysIBC.H"
20 #include "MOLUtilities.H"
21 
22 #include "NamespaceHeader.H"
23 
24 class HDF5HeaderData;
25 
26 ///
27 /**
28  The base class MOLPhysics provides the physics-dependent components
29  for a higher-order method for a single patch: Riemann solver and
30  transformations between conserved, primitive, and flux variables.
31  This class is essentially pure virtual, i.e. all of its member functions
32  are virtual, and the ones that have default implementations are ones
33  which are optionally defined, i.e. the default definition is to send
34  an error message. Physics-dependent versions of this class that are
35  required in real applications are derived from this class by inheritance.
36 */
38 {
39 public:
40  /// Constructor
41  /**
42  */
43  MOLPhysics();
44 
45  /// Destructor
46  /**
47  */
48  virtual ~MOLPhysics();
49 
50  /// Get the initial and boundary condition object
51  /**
52  */
53  PhysIBC* getPhysIBC() const;
54 
55  /// Set the initial and boundary condition object
56  /**
57  */
58  void setPhysIBC(PhysIBC* a_bc);
59 
60  /// Define the object
61  /**
62  */
63  virtual void define(const ProblemDomain& a_domain,
64  const Real& a_dx);
65 
66  /// Set the current box (default implementation - do nothing)
67  /**
68  */
69  virtual void setCurrentBox(const Box& a_currentBox);
70 
71  /// Returns true if 4th-order artificial viscosity is defined.
72  /**
73  */
74  virtual bool fourthOrderArtificialViscosityIsDefined() const;
75 
76  /// Defines fourth-order artifical viscosity strong shock threshold.
77  /**
78  */
79  virtual void setFourthOrderArtificialViscosityParameter(const Real& M0sq);
80  /// Returns fourth-order artifical viscosity strong shock threshold.
81  /**
82  */
84 
85  /// Compute the maximum wave speed.
86  /**
87  */
88  virtual Real getMaxWaveSpeed(const FArrayBox& a_U,
89  const Box& a_box) = 0;
90 
91  /// Compute the maximum wave speed
92  /**
93  */
94  virtual void soundSpeed(FArrayBox& a_speed,
95  const FArrayBox& a_U,
96  const Box& a_box);
97 
98  /// Object factory for this class
99  /**
100  */
101  virtual MOLPhysics* new_molPhysics() const = 0;
102 
103  /// Copy our values into one of us
104  virtual void copyTo(MOLPhysics* a_mol) const;
105 
106  /// Number of conserved variables
107  /**
108  Return the number of conserved variables.
109  */
110  virtual int numConserved() const = 0;
111 
112  /// Names of the conserved variables
113  /**
114  Return the names of the conserved variables.
115  */
116  virtual Vector<string> stateNames() = 0;
117 
118  /// Number of flux variables
119  /**
120  Return the number of flux variables. This can be greater than the number
121  of conserved variables if addition fluxes/face-centered quantities are
122  computed.
123  */
124  virtual int numFluxes() const = 0;
125 
126  /// Compute the fluxes from primitive variable values on a face
127  /**
128  This has a default implementation which throws an error. The method is
129  here so that the default implementation of "computeUpdate" can use it
130  and the user can supply it. It has an implementation so if the user
131  redefines "computeUpdate" they aren't force to implement "getFlux" -
132  which is only used by the default implementation of "computeUpdate".
133  */
134  virtual void getFlux(FArrayBox& a_flux,
135  const FArrayBox& a_WHalf,
136  const int& a_dir,
137  const Box& a_box);
138 
139  /// Is the object completely defined
140  /**
141  Return true if the object is completely defined.
142  */
143  virtual bool isDefined() const;
144 
145  /// Number of primitive variables
146  /**
147  Return the number of primitive variables. This may be greater than the
148  number of conserved variables if derived/redundant quantities are also
149  stored for convenience.
150  */
151  virtual int numPrimitives() const = 0;
152 
153  /// Compute the solution to the Riemann problem.
154  /**
155  Given input left and right states in a direction, a_dir, compute a
156  Riemann problem and generate fluxes at the faces within a_box.
157  */
158  virtual void riemann(/// face-centered solution to Riemann problem
159  FArrayBox& a_WStar,
160  /// left state, on cells to left of each face
161  const FArrayBox& a_WLeft,
162  /// right state, on cells to right of each face
163  const FArrayBox& a_WRight,
164  /// state on cells, used to set boundary conditions
165  const FArrayBox& a_W,
166  /// current time
167  const Real& a_time,
168  /// direction of faces
169  const int& a_dir,
170  /// face-centered box on which to set a_WStar
171  const Box& a_box) = 0;
172 
173  /// Compute primitive variables from conserved variables.
174  /**
175  */
176  virtual void consToPrim(FArrayBox& a_W,
177  const FArrayBox& a_U,
178  const Box& a_box) = 0;
179 
180  /// Interval within the primitive variables corresponding to the velocities
181  /**
182  Return the interval of component indices within the primitive variable
183  of the velocities. Used for slope flattening (slope computation) and
184  computing the divergence of the velocity (artificial viscosity).
185  */
186  virtual Interval velocityInterval() const = 0;
187 
188  /// Interval within the flux variables corresponding to vector flux
189  virtual Interval vectorFluxInterval() const;
190 
191  /// Component index within the primitive variables of the pressure
192  /**
193  Return the component index withn the primitive variables for the
194  pressure. Used for slope flattening (slope computation).
195  */
196  virtual int pressureIndex() = 0;
197 
198  /// Used to limit the absolute value of a "pressure" difference
199  /**
200  Return a value that is used by slope flattening to limit (away from
201  zero) the absolute value of a slope in the pressureIndex() component
202  (slope computation).
203  */
204  virtual Real smallPressure() = 0;
205 
206  /// Component index within the primitive variables of the bulk modulus
207  /**
208  Return the component index withn the primitive variables for the
209  bulk modulus. Used for slope flattening (slope computation) used
210  as a normalization to measure shock strength.
211  */
212  virtual int bulkModulusIndex() = 0;
213 
214  /// Component index within the primitive variables of the density.
215  /**
216  Return the component index within the primitive variables for the
217  density. Used for fourth-order accurate artificial viscosity.
218  */
219  virtual int densityIndex();
220 
221  /// Compute the artificial viscosity contribution to the flux
222  /**
223  Compute the artificial viscosity contribution to the flux. This has
224  a default implementation but this can be overridded as needed.
225 
226  a_box is the valid cell-centered box.
227 
228  Increment a_F
229  on all a_dir-faces of a_box
230  using a_U
231  on all cells of bx1inDomain = grow(a_box, 1) & m_domain.
232  */
233  virtual void artVisc(FArrayBox& a_F,
234  const FArrayBox& a_U,
235  const Real& a_artificialViscosity,
236  const Real& a_currentTime,
237  const int& a_dir,
238  const Box& a_box);
239 
240 #ifdef CH_USE_HDF5
241  virtual void expressions(HDF5HeaderData& a_holder) const
242  {
243  }
244 #endif
245 
246 
247 protected:
248 
249  // Has this object been defined
251 
252  // Problem domain and grid spacing
255 
256  // Object containing various methods for the MOL computation
258 
259  // Flag to use fourth-order accurate artificial viscosity, strong shock
260  // threshhold M0sq (looks like the shock Mach number squared).
263 
264  // Initial and boundary condition object and has it been set
266  bool m_isBCSet;
267 
268 private:
269  // Disallowed for all the usual reasons
270  MOLPhysics& operator=(const MOLPhysics& a_input);
271  MOLPhysics(const MOLPhysics& a_input);
272 };
273 
274 #include "NamespaceFooter.H"
275 #endif
PhysIBC * m_bc
Definition: MOLPhysics.H:265
virtual void copyTo(MOLPhysics *a_mol) const
Copy our values into one of us.
bool m_useFourthOrderArtificialViscosity
Definition: MOLPhysics.H:261
MOLUtilities m_util
Definition: MOLPhysics.H:257
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
data to be added to HDF5 files.
Definition: CH_HDF5.H:519
virtual int numPrimitives() const =0
Number of primitive variables.
Real m_dx
Definition: MOLPhysics.H:254
virtual void soundSpeed(FArrayBox &a_speed, const FArrayBox &a_U, const Box &a_box)
Compute the maximum wave speed.
virtual int bulkModulusIndex()=0
Component index within the primitive variables of the bulk modulus.
Definition: MOLUtilities.H:32
virtual void define(const ProblemDomain &a_domain, const Real &a_dx)
Define the object.
virtual void consToPrim(FArrayBox &a_W, const FArrayBox &a_U, const Box &a_box)=0
Compute primitive variables from conserved variables.
virtual Vector< string > stateNames()=0
Names of the conserved variables.
Definition: MOLPhysics.H:37
virtual Real getFourthOrderArtificialViscosityParameter() const
Returns fourth-order artifical viscosity strong shock threshold.
virtual void getFlux(FArrayBox &a_flux, const FArrayBox &a_WHalf, const int &a_dir, const Box &a_box)
Compute the fluxes from primitive variable values on a face.
virtual bool isDefined() const
Is the object completely defined.
virtual void artVisc(FArrayBox &a_F, const FArrayBox &a_U, const Real &a_artificialViscosity, const Real &a_currentTime, const int &a_dir, const Box &a_box)
Compute the artificial viscosity contribution to the flux.
virtual void expressions(HDF5HeaderData &a_holder) const
Definition: MOLPhysics.H:241
virtual Real smallPressure()=0
Used to limit the absolute value of a "pressure" difference.
MOLPhysics()
Constructor.
PhysIBC * getPhysIBC() const
Get the initial and boundary condition object.
Structure for passing component ranges in code.
Definition: Interval.H:23
virtual int pressureIndex()=0
Component index within the primitive variables of the pressure.
virtual 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)=0
Compute the solution to the Riemann problem.
ProblemDomain m_domain
Definition: MOLPhysics.H:253
virtual void setFourthOrderArtificialViscosityParameter(const Real &M0sq)
Defines fourth-order artifical viscosity strong shock threshold.
double Real
Definition: REAL.H:33
virtual MOLPhysics * new_molPhysics() const =0
Object factory for this class.
virtual int densityIndex()
Component index within the primitive variables of the density.
MOLPhysics & operator=(const MOLPhysics &a_input)
Real m_M0sq
Definition: MOLPhysics.H:262
virtual ~MOLPhysics()
Destructor.
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
virtual Interval vectorFluxInterval() const
Interval within the flux variables corresponding to vector flux.
virtual void setCurrentBox(const Box &a_currentBox)
Set the current box (default implementation - do nothing)
virtual bool fourthOrderArtificialViscosityIsDefined() const
Returns true if 4th-order artificial viscosity is defined.
Definition: FArrayBox.H:45
virtual int numConserved() const =0
Number of conserved variables.
virtual int numFluxes() const =0
Number of flux variables.
void setPhysIBC(PhysIBC *a_bc)
Set the initial and boundary condition object.
virtual Interval velocityInterval() const =0
Interval within the primitive variables corresponding to the velocities.
bool m_isDefined
Definition: MOLPhysics.H:250
Physical/domain initial and boundary conditions.
Definition: PhysIBC.H:33
virtual Real getMaxWaveSpeed(const FArrayBox &a_U, const Box &a_box)=0
Compute the maximum wave speed.
bool m_isBCSet
Definition: MOLPhysics.H:266