Chombo + EB  3.2
PatchGodunov.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 _PATCHGODUNOV_H_
12 #define _PATCHGODUNOV_H_
13 
14 #include "Box.H"
15 #include "IntVectSet.H"
16 #include "Vector.H"
17 #include "FluxBox.H"
18 
19 #include "GodunovPhysics.H"
20 #include "GodunovUtilities.H"
21 #include "NamespaceHeader.H"
22 
23 class HDF5HeaderData;
24 
25 ///
26 /**
27  The base class PatchGodunov provides an implementation of a second-order,
28  unsplit Godunov method acting on a single grid/patch. PatchGodunov
29  provides an interface to the level integrator, LevelGodunov, which manages
30  the entire level and flux corrections (via flux registers) to the coarser
31  and finer levels.
32  */
34 {
35 public:
36  /// Constructor
37  /**
38  */
39  PatchGodunov();
40 
41  /// Destructor
42  /**
43  */
44  virtual ~PatchGodunov();
45 
46  /// Define the object
47  /**
48  */
49  virtual void define(/// problem domain
50  const ProblemDomain& a_domain,
51  /// grid spacing
52  const Real& a_dx,
53  /// physics class
54  const GodunovPhysics* const a_gdnvPhysicsPtr,
55  /// order of the normal predictorr: 0 for CTU, 1 for PLM, 2 for PPM
56  const int& a_normalPredOrder,
57  /// whether to use 4th-order slopes
58  const bool& a_useFourthOrderSlopes,
59  /// whether to apply slope limiting to primitive variables
60  const bool& a_usePrimLimiting,
61  /// whether to apply slope limiting to characteristic variables
62  const bool& a_useCharLimiting,
63  /// whether to apply slope flattening
64  const bool& a_useFlattening,
65  /// whether to apply artificial viscosity
66  const bool& a_useArtificialViscosity,
67  /// artificial viscosity coefficient
68  const Real& a_artificialViscosity);
69 
70  /// Set the current time before calling updateState(), computeWHalf(), computeUpdate().
71  /**
72  */
73  virtual void setCurrentTime(const Real& a_currentTime);
74 
75  /// Set the current box before calling updateState(), computeWHalf(), computeUpdate().
76  /**
77  */
78  virtual void setCurrentBox(const Box& a_currentBox);
79 
80  /// Update the conserved variables and return the fluxes used to do this.
81  /**
82  */
83  virtual void updateState(/// conserved variables, updated in this routine
84  FArrayBox& a_U,
85  /// fluxes from 2nd-order unsplit Godunov method, returned
86  FluxBox& a_F,
87  /// maximum wave speed, returned
88  Real& a_maxWaveSpeed,
89  /// source terms, or null constructed if none
90  const FArrayBox& a_S,
91  /// time step
92  const Real& a_dt,
93  /// Box of a_U
94  const Box& a_box);
95 
96  virtual void updateState(/// conserved variables, updated in this routine
97  FArrayBox& a_U,
98  /// fluxes from 2nd-order unsplit Godunov method, returned
99  FluxBox& a_F,
100  /// primitive variables extrapolated to cell faces and a half time step
101  FluxBox& a_wHalf,
102  /// maximum wave speed, returned
103  Real& a_maxWaveSpeed,
104  /// source terms, or null constructed if none
105  const FArrayBox& a_S,
106  /// time step
107  const Real& a_dt,
108  /// Box of a_U
109  const Box& a_box);
110 
111  /// Compute the time-centered values of the primitive variables on cell faces.
112  /**
113  This API is used in cases where some operation over the whole
114  level must be performed on the face-centered variables prior to the
115  final difference update. Examples include incompressible flow and MHD,
116  in which it is necessary to compute the projection of a face-centered
117  vector field on its divergence-free part. To complete the differencing,
118  it is necessary to call the member function computeUpdate().
119  */
120  virtual void computeWHalf(/// primitive variables extrapolated to cell faces and a half time step
121  FluxBox& a_WHalf,
122  /// conserved variables at beginning of time step
123  const FArrayBox& a_U,
124  /// source terms, or null constructed if none
125  const FArrayBox& a_S,
126  /// time step
127  const Real& a_dt,
128  /// Box of a_U
129  const Box& a_box);
130 
131  /// Compute the increment in the conserved variables from face variables.
132  /**
133  Compute dU = dt*dU/dt, the change in the conserved variables over
134  the time step. The fluxes are returned are suitable for use in refluxing.
135  */
136  virtual void computeUpdate(/// change in conserved variables over the time step
137  FArrayBox& a_dU,
138  /// fluxes for refluxing
139  FluxBox& a_F,
140  /// conserved variables at beginning of time step
141  const FArrayBox& a_U,
142  /// primitive variables extrapolated to cell faces and a half time step
143  const FluxBox& a_WHalf,
144  /// time step
145  const Real& a_dt,
146  /// Box of a_U
147  const Box& a_box);
148 
149  /// Compute fluxes from primitive variables on faces
150  /**
151  */
152  void computeFluxes(FluxBox& a_F,
153  const FluxBox& a_WHalf,
154  const Box& a_box);
155 
156  /// CTU normal predictor
157  /**
158  Compute the increments in the characteristic amplitudes using CTU
159  (for CTU, increments are zero)
160  */
161  void CTUNormalPred(FArrayBox& a_WMinus,
162  FArrayBox& a_WPlus,
163  const Real& a_dt,
164  const Real& a_dx,
165  const FArrayBox& a_W,
166  const FArrayBox& a_flat,
167  const int& a_dir,
168  const Box& a_box);
169 
170  /// PLM normal predictor
171  /**
172  Compute the increments in the characteristic amplitudes using PLM
173  */
174  void PLMNormalPred(FArrayBox& a_WMinus,
175  FArrayBox& a_WPlus,
176  const Real& a_dt,
177  const Real& a_dx,
178  const FArrayBox& a_W,
179  const FArrayBox& a_flat,
180  const int& a_dir,
181  const Box& a_box);
182 
183  /// PPM normal predictor
184  /**
185  Compute the increments in the characteristic amplitudes using PPM
186  */
187  void PPMNormalPred(FArrayBox& a_WMinus,
188  FArrayBox& a_WPlus,
189  const Real& a_dt,
190  const Real& a_dx,
191  const FArrayBox& a_W,
192  const FArrayBox& a_flat,
193  const int& a_dir,
194  const Box& a_box);
195 
196  /// Accessor to get at the GodunovPhysics object
197  /**
198  */
200 
201  //! Get the problem domain for this object.
202  const ProblemDomain& problemDomain() const;
203 
204  /// Is the object completely defined
205  /**
206  Return true if the object is completely defined.
207  */
208  virtual bool isDefined() const;
209 
210  /// Set whether to use high-order limiter.
211  void highOrderLimiter(bool a_highOrderLimiter);
212 
213  //! Returns the grid spacing at this level.
214  Real dx() const;
215 
216 #ifdef CH_USE_HDF5
217  virtual void expressions(HDF5HeaderData& a_holder) const
218  {
219  }
220 #endif
221 
222 protected:
223  // Problem domain and grid spacing
226 
227  // Object providing physics information
229 
230  // Object containing various methods for the Godunov computation
232 
233  // Order of the normal predictor (1 -> PLM, 2-> PPM)
235 
236  // Use 4th order slope computations (otherwise, use 2nd order)
238 
239  // Do slope limiting in the primitive or characteristic variables, respect.
242 
243  // Do slope flattening - MUST BE USING 4th order slopes
245 
246  // Apply artificial viscosity of a set value
249 
250  // Current time and has it been set
253 
254  // Current box and has it been set
257 
258  // Has this object been defined
260 
261 private:
262 
263  // Disallowed for all the usual reasons
264  void operator=(const PatchGodunov&);
265  PatchGodunov(const PatchGodunov&);
266 };
267 
268 #include "NamespaceFooter.H"
269 #endif
void CTUNormalPred(FArrayBox &a_WMinus, FArrayBox &a_WPlus, const Real &a_dt, const Real &a_dx, const FArrayBox &a_W, const FArrayBox &a_flat, const int &a_dir, const Box &a_box)
CTU normal predictor.
ProblemDomain m_domain
Definition: PatchGodunov.H:224
bool m_isCurrentBoxSet
Definition: PatchGodunov.H:256
int m_normalPredOrder
Definition: PatchGodunov.H:234
bool m_useCharLimiting
Definition: PatchGodunov.H:241
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
virtual void updateState(FArrayBox &a_U, FluxBox &a_F, Real &a_maxWaveSpeed, const FArrayBox &a_S, const Real &a_dt, const Box &a_box)
Update the conserved variables and return the fluxes used to do this.
data to be added to HDF5 files.
Definition: CH_HDF5.H:519
virtual bool isDefined() const
Is the object completely defined.
Definition: GodunovUtilities.H:31
void PLMNormalPred(FArrayBox &a_WMinus, FArrayBox &a_WPlus, const Real &a_dt, const Real &a_dx, const FArrayBox &a_W, const FArrayBox &a_flat, const int &a_dir, const Box &a_box)
PLM normal predictor.
bool m_useFourthOrderSlopes
Definition: PatchGodunov.H:237
virtual void computeWHalf(FluxBox &a_WHalf, const FArrayBox &a_U, const FArrayBox &a_S, const Real &a_dt, const Box &a_box)
Compute the time-centered values of the primitive variables on cell faces.
GodunovUtilities m_util
Definition: PatchGodunov.H:231
Real dx() const
Returns the grid spacing at this level.
bool m_useFlattening
Definition: PatchGodunov.H:244
virtual void expressions(HDF5HeaderData &a_holder) const
Definition: PatchGodunov.H:217
virtual void computeUpdate(FArrayBox &a_dU, FluxBox &a_F, const FArrayBox &a_U, const FluxBox &a_WHalf, const Real &a_dt, const Box &a_box)
Compute the increment in the conserved variables from face variables.
Real m_currentTime
Definition: PatchGodunov.H:251
Real m_dx
Definition: PatchGodunov.H:225
virtual void setCurrentBox(const Box &a_currentBox)
Set the current box before calling updateState(), computeWHalf(), computeUpdate().
virtual ~PatchGodunov()
Destructor.
GodunovPhysics * getGodunovPhysicsPtr()
Accessor to get at the GodunovPhysics object.
void highOrderLimiter(bool a_highOrderLimiter)
Set whether to use high-order limiter.
A FArrayBox-like container for face-centered fluxes.
Definition: FluxBox.H:22
double Real
Definition: REAL.H:33
virtual void define(const ProblemDomain &a_domain, const Real &a_dx, const GodunovPhysics *const a_gdnvPhysicsPtr, const int &a_normalPredOrder, const bool &a_useFourthOrderSlopes, const bool &a_usePrimLimiting, const bool &a_useCharLimiting, const bool &a_useFlattening, const bool &a_useArtificialViscosity, const Real &a_artificialViscosity)
Define the object.
bool m_usePrimLimiting
Definition: PatchGodunov.H:240
void computeFluxes(FluxBox &a_F, const FluxBox &a_WHalf, const Box &a_box)
Compute fluxes from primitive variables on faces.
void PPMNormalPred(FArrayBox &a_WMinus, FArrayBox &a_WPlus, const Real &a_dt, const Real &a_dx, const FArrayBox &a_W, const FArrayBox &a_flat, const int &a_dir, const Box &a_box)
PPM normal predictor.
void operator=(const PatchGodunov &)
const ProblemDomain & problemDomain() const
Get the problem domain for this object.
bool m_isCurrentTimeSet
Definition: PatchGodunov.H:252
Definition: GodunovPhysics.H:40
GodunovPhysics * m_gdnvPhysics
Definition: PatchGodunov.H:228
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
Box m_currentBox
Definition: PatchGodunov.H:255
Definition: FArrayBox.H:45
Definition: PatchGodunov.H:33
PatchGodunov()
Constructor.
bool m_useArtificialViscosity
Definition: PatchGodunov.H:247
bool m_isDefined
Definition: PatchGodunov.H:259
Real m_artificialViscosity
Definition: PatchGodunov.H:248
virtual void setCurrentTime(const Real &a_currentTime)
Set the current time before calling updateState(), computeWHalf(), computeUpdate().