Chombo + EB + MF  3.2
LevelConsOperator.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 _LEVELCONSOPERATOR_H_
12 #define _LEVELCONSOPERATOR_H_
13 
14 // Original design: Phil Colella
15 // Original implementation:
16 // Implementation date:
17 
18 #include "FArrayBox.H"
19 #include "FluxBox.H"
20 #include "DisjointBoxLayout.H"
21 #include "LevelData.H"
22 #include "FourthOrderFillPatch.H"
23 #include "LevelFluxRegister.H"
24 #include "ProblemDomain.H"
25 #include "MOLPhysics.H"
26 #include "PatchConsOperator.H"
27 #include "TimeInterpolatorRK4.H"
28 
29 #include "NamespaceHeader.H"
30 
31 /// Level Cons Operator - a class for evaluating the Laplacian.
32 
33 /**
34  */
36 {
37 public:
38  /// Default constructor
39  /**
40  Object requires define() to be called before all other functions.
41  */
43 
44  /// Destructor
45  /**
46  Destroys all objects created by define(). Passed in data references
47  of define() are left alone.
48  */
49  virtual ~LevelConsOperator();
50 
51  /// Actual constructor.
52  /**
53  Inside the routine, we cast away const-ness on the data members
54  for the assignment. The arguments passed in are maintained const
55  (coding standards). a_refine is the refinement ratio between
56  this level and the next coarser level. For the coarsest level, an
57  empty DisjointBoxLayout is passed in for coarserDisjointBoxLayout.
58  */
59  virtual void define(const DisjointBoxLayout& a_thisDisjointBoxLayout,
60  const DisjointBoxLayout& a_coarserDisjointBoxLayout,
61  const ProblemDomain& a_domain,
62  const int& a_refineCoarse,
63  const Real& a_dx,
64  const MOLPhysics* const a_molPhysics,
65  const int& a_numStates,
66  const bool& a_hasCoarser,
67  const bool& a_hasFiner);
68 
69  /// Evaluate the operator (div(flux) ) at a given time.
70  /**
71  For the coarsest level, UcoarseOld and UcoarseNew are empty
72  LevelData<FArrayBox> objects. Also, either UcoarseOld or
73  UcoarseNew might be empty to indicate that t(nf) = t(nc) the
74  one grid is at the current time and interpolation is not required
75  for boundary condition generation. U must be defined on the same
76  DisjointBoxLayouts as were used in define(). Coarse flux register
77  is flux register with the next coarser level. Fine flux register is
78  the flux register with the next finer level. To the finer level FR,
79  this level is the coarse level. To the coarser level FR, this level
80  is the fine level.
81  */
82  virtual void evalRHS(LevelData<FArrayBox>& a_LofU,
84  LevelFluxRegister& a_finerFluxRegister,
85  LevelFluxRegister& a_coarserFluxRegister,
86  const LevelData<FArrayBox>& a_UcoarseOld,
87  const Real& a_timeCoarseOld,
88  const LevelData<FArrayBox>& a_UcoarseNew,
89  const Real& a_timeCoarseNew,
90  Real a_time,
91  Real a_weight);
92 
93  /*
94  Called by evalRHS for the patch-by-patch operations.
95  */
96  virtual void evalRHSpatches(LevelData<FArrayBox>& a_LofU,
97  const LevelData<FArrayBox>& a_U,
98  LevelFluxRegister& a_finerFluxRegister,
99  LevelFluxRegister& a_coarserFluxRegister,
100  Real a_weight);
101 
102 
103  /// update solution -- soln += dt*rhs (required by LevelRK4)
104  virtual void updateODE(LevelData<FArrayBox>& a_soln,
105  const LevelData<FArrayBox>& a_rhs,
106  Real a_dt);
107 
108 
109  /// reset fluxes contained in this object to zero
110  virtual void resetFluxes();
111 
112 
113  /// returns reference to fluxes computed and accumulated by this operator.
115 
116 
117  /// define newSoln to match existingSoln, including ghost cells
118  /** (required by LevelRK4)
119  */
120  virtual void defineSolnData(LevelData<FArrayBox>& a_newSoln,
121  const LevelData<FArrayBox>& a_existingSoln);
122 
123 
124  /// define RHS data based on existingSoln (in this case, w/o ghost cells)
125  /** (required by LevelRK4)
126  */
127  virtual void defineRHSData(LevelData<FArrayBox>& a_newRHS,
128  const LevelData<FArrayBox>& a_existingSoln);
129 
130 
131  /// copy data from src->dest
132  /** (required by LevelRK4)
133  */
134  void copySolnData(LevelData<FArrayBox>& a_dest,
135  const LevelData<FArrayBox>& a_src);
136 
137  /// set spatial order of accuracy
138  /*
139  Can be 2 or 4 (default)
140  */
141  void spaceOrder(int a_spaceOrder);
142 
143 
144  /// if true, limit face values
145  void limitFaceValues(bool a_limitFaceValues);
146 
147  // sets whether to use high-order limiter
148  void highOrderLimiter(bool a_highOrderLimiter);
149 
150  /// sets whether to flatten extrapolations to faces
151  void useFlattening(bool a_useFlattening);
152 
153  /// sets m_noPPM
154  void noPPM(bool a_noPPM);
155 
156  /// sets m_doDeconvolution
157  void doDeconvolution(bool a_doDeconvolution);
158 
159  /// sets m_doFaceDeconvolution
160  void doFaceDeconvolution(bool a_doFaceDeconvolution);
161 
162  /// sets whether to use artificial viscosity (from divergence)
163  void useArtificialViscosity(bool a_useArtificialViscosity);
164 
165  /// sets coefficient of artificial viscosity (from divergence)
166  void artificialViscosity(Real a_artificialViscosity);
167 
168  /// sets whether to use forward Euler instead of RK4
169  void forwardEuler(bool a_forwardEuler);
170 
171  /// sets m_numGhost, the number of ghost cells
172  void numGhost(int a_numGhost);
173 
174  /// set number of calls that will be made to evalRHS
175  void evalCountMax(int a_evalCountMax);
176 
177  /// reset m_evalCount to 0
178  void resetEvalCount();
179 
180  /// add artificial viscosity to a_Unew
181  virtual void addArtificialViscosity(LevelData<FArrayBox>& a_Unew,
182  const LevelData<FArrayBox>& a_Uold,
183  LevelFluxRegister& a_finerFluxRegister,
184  LevelFluxRegister& a_coarserFluxRegister,
185  Real a_oldTime,
186  Real a_weight);
187 
188  /// update a_finerFluxRegister and a_coarserFluxRegister
189  virtual void updateFluxTotalsAndRegisters(// used to update flux registers: it is shifted and shifted back, but data remain unchanged
190  FluxBox& a_Fface,
191  LevelFluxRegister& a_finerFluxRegister,
192  LevelFluxRegister& a_coarserFluxRegister,
193  const DataIndex& a_dataIndex,
194  Real a_weight);
195 
196  /// Return time interpolator object within patch-fill object.
198 
199  /// fill in ghost cells of a_U
200  virtual void fillGhosts(LevelData<FArrayBox>& a_U,
201  const Real& a_time,
202  const Real& a_timeCoarseOld,
203  const Real& a_timeCoarseNew);
204 
205  /// fill in ghost cells of a_U to RK4 intermediates
206  virtual void fillGhostsRK4(LevelData<FArrayBox>& a_U,
207  const Real& a_time,
208  int a_stage,
209  const Real& a_timeCoarseOld,
210  const Real& a_timeCoarseNew);
211 
212  virtual void exchangeGhosts(LevelData<FArrayBox>& a_U);
213 
214 protected:
215 
216  /// sets m_flattening
217  virtual void defineFlattening();
218 
219  /// sets m_patchConsOperator
220  virtual void definePatch(const MOLPhysics* const a_molPhysics);
221 
222  /// sets m_exchangeCopier
223  virtual void defineExchanger();
224 
225  virtual void setPatchIndex(const DataIndex& a_ind) const;
226 
227  // Box layout for this level
229 
230  // Patch integrator
232 
233  // Number of ghost cells need locally for this level
235 
236  // Exchange copier
238 
239  // pointer to advection velocities
240  // LevelData<FluxBox>* m_advVelPtr;
241 
243 
244  // Interpolator for filling in ghost cells from the next coarser level
245  // QuadCFInterp m_patcher;
246  // PiecewiseLinearFillPatch m_patcher;
248 
249  // Grid spacing
251 
252  // Problem domain - index space for this level
254 
255  // Refinement ratio between this level and the next coarser
257 
258  // Number of conserved variables
260 
261  // Number of conservative fluxes and other face centered quantities
263 
264  // Flags for the existence of coarser and finer levels, respectively
267 
268  // flattening coefficients, if m_useFlattening
270 
271  // spatial order of accuracy
273 
274  // if true, limit face values
276 
277  /// if true, use high-order limiter
279 
280  // if true, use flattening
282 
284 
285  // Avoid PPM? Default false.
286  bool m_noPPM;
287 
288  // Do deconvolution? Default yes.
290 
291  // Do face deconvolution? Default yes.
293 
294  // number of calls that will be made to evalRHS
296 
297  // number of calls that have been made to evalRHS so far
299 
300  // use artificial viscosity (from divergence)?
302 
303  // coefficient of artificial viscosity (from divergence)
305 
306  // whether to use forward Euler instead of RK4
308 
309  // define() has been called
310  bool m_defined;
311 
312 private:
313 
314  // Disallowed for all the usual reasons
315  void operator=(const LevelConsOperator& a_input);
316 
317  // Disallowed for all the usual reasons
318  LevelConsOperator(const LevelConsOperator& a_input);
319 };
320 
321 #include "NamespaceFooter.H"
322 
323 #endif
virtual void fillGhosts(LevelData< FArrayBox > &a_U, const Real &a_time, const Real &a_timeCoarseOld, const Real &a_timeCoarseNew)
fill in ghost cells of a_U
virtual void resetFluxes()
reset fluxes contained in this object to zero
bool m_hasFiner
Definition: LevelConsOperator.H:266
int m_evalCount
Definition: LevelConsOperator.H:298
int m_spaceOrder
Definition: LevelConsOperator.H:272
Real m_dx
Definition: LevelConsOperator.H:250
LevelConsOperator()
Default constructor.
Copier m_exchangeCopier
Definition: LevelConsOperator.H:237
bool m_limitFaceValues
Definition: LevelConsOperator.H:275
bool m_forwardEuler
Definition: LevelConsOperator.H:307
PatchConsOperator * m_patchConsOperatorPtr
Definition: LevelConsOperator.H:231
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
LevelData< FluxBox > & getFluxes()
returns reference to fluxes computed and accumulated by this operator.
virtual ~LevelConsOperator()
Destructor.
FourthOrderFillPatch m_patcher
Definition: LevelConsOperator.H:247
void forwardEuler(bool a_forwardEuler)
sets whether to use forward Euler instead of RK4
int m_evalCountMax
Definition: LevelConsOperator.H:295
void useArtificialViscosity(bool a_useArtificialViscosity)
sets whether to use artificial viscosity (from divergence)
bool m_useArtificialViscosity
Definition: LevelConsOperator.H:301
void highOrderLimiter(bool a_highOrderLimiter)
bool m_useFlattening
Definition: LevelConsOperator.H:281
A strange but true thing to make copying from one boxlayoutdata to another fast.
Definition: Copier.H:152
virtual void defineExchanger()
sets m_exchangeCopier
void copySolnData(LevelData< FArrayBox > &a_dest, const LevelData< FArrayBox > &a_src)
copy data from src->dest
Definition: MOLPhysics.H:37
void resetEvalCount()
reset m_evalCount to 0
void spaceOrder(int a_spaceOrder)
set spatial order of accuracy
void limitFaceValues(bool a_limitFaceValues)
if true, limit face values
bool m_defined
Definition: LevelConsOperator.H:310
void artificialViscosity(Real a_artificialViscosity)
sets coefficient of artificial viscosity (from divergence)
int m_refineCoarse
Definition: LevelConsOperator.H:256
int m_numFields
Definition: LevelConsOperator.H:283
virtual void evalRHSpatches(LevelData< FArrayBox > &a_LofU, const LevelData< FArrayBox > &a_U, LevelFluxRegister &a_finerFluxRegister, LevelFluxRegister &a_coarserFluxRegister, Real a_weight)
virtual void evalRHS(LevelData< FArrayBox > &a_LofU, LevelData< FArrayBox > &a_U, LevelFluxRegister &a_finerFluxRegister, LevelFluxRegister &a_coarserFluxRegister, const LevelData< FArrayBox > &a_UcoarseOld, const Real &a_timeCoarseOld, const LevelData< FArrayBox > &a_UcoarseNew, const Real &a_timeCoarseNew, Real a_time, Real a_weight)
Evaluate the operator (div(flux) ) at a given time.
virtual void defineFlattening()
sets m_flattening
void doDeconvolution(bool a_doDeconvolution)
sets m_doDeconvolution
bool m_noPPM
Definition: LevelConsOperator.H:286
A FArrayBox-like container for face-centered fluxes.
Definition: FluxBox.H:22
void doFaceDeconvolution(bool a_doFaceDeconvolution)
sets m_doFaceDeconvolution
ProblemDomain m_domain
Definition: LevelConsOperator.H:253
virtual void defineRHSData(LevelData< FArrayBox > &a_newRHS, const LevelData< FArrayBox > &a_existingSoln)
define RHS data based on existingSoln (in this case, w/o ghost cells)
double Real
Definition: REAL.H:33
Patch Cons Operator - a class for evaluating the Laplacian.
Definition: PatchConsOperator.H:30
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
Time interpolator class using 4th-order Runge-Kutta.
Definition: TimeInterpolatorRK4.H:24
void evalCountMax(int a_evalCountMax)
set number of calls that will be made to evalRHS
BoxLayoutData< FArrayBox > m_flattening
Definition: LevelConsOperator.H:269
virtual void fillGhostsRK4(LevelData< FArrayBox > &a_U, const Real &a_time, int a_stage, const Real &a_timeCoarseOld, const Real &a_timeCoarseNew)
fill in ghost cells of a_U to RK4 intermediates
LevelFluxRegister-A class to encapsulate a levels worth of flux registers.
Definition: LevelFluxRegister.H:29
TimeInterpolatorRK4 & getTimeInterpolator()
Return time interpolator object within patch-fill object.
void operator=(const LevelConsOperator &a_input)
int m_numCons
Definition: LevelConsOperator.H:259
void numGhost(int a_numGhost)
sets m_numGhost, the number of ghost cells
bool m_hasCoarser
Definition: LevelConsOperator.H:265
Definition: DataIndex.H:114
bool m_doDeconvolution
Definition: LevelConsOperator.H:289
virtual void exchangeGhosts(LevelData< FArrayBox > &a_U)
Real m_artificialViscosity
Definition: LevelConsOperator.H:304
Level Cons Operator - a class for evaluating the Laplacian.
Definition: LevelConsOperator.H:35
virtual void addArtificialViscosity(LevelData< FArrayBox > &a_Unew, const LevelData< FArrayBox > &a_Uold, LevelFluxRegister &a_finerFluxRegister, LevelFluxRegister &a_coarserFluxRegister, Real a_oldTime, Real a_weight)
add artificial viscosity to a_Unew
void useFlattening(bool a_useFlattening)
sets whether to flatten extrapolations to faces
virtual void setPatchIndex(const DataIndex &a_ind) const
int m_numGhost
Definition: LevelConsOperator.H:234
int m_numFluxes
Definition: LevelConsOperator.H:262
virtual void defineSolnData(LevelData< FArrayBox > &a_newSoln, const LevelData< FArrayBox > &a_existingSoln)
define newSoln to match existingSoln, including ghost cells
DisjointBoxLayout m_grids
Definition: LevelConsOperator.H:228
bool m_doFaceDeconvolution
Definition: LevelConsOperator.H:292
virtual void updateFluxTotalsAndRegisters(FluxBox &a_Fface, LevelFluxRegister &a_finerFluxRegister, LevelFluxRegister &a_coarserFluxRegister, const DataIndex &a_dataIndex, Real a_weight)
update a_finerFluxRegister and a_coarserFluxRegister
Fourth-order interpolation in time and space to ghost cells.
Definition: FourthOrderFillPatch.H:27
virtual void updateODE(LevelData< FArrayBox > &a_soln, const LevelData< FArrayBox > &a_rhs, Real a_dt)
update solution – soln += dt*rhs (required by LevelRK4)
virtual void define(const DisjointBoxLayout &a_thisDisjointBoxLayout, const DisjointBoxLayout &a_coarserDisjointBoxLayout, const ProblemDomain &a_domain, const int &a_refineCoarse, const Real &a_dx, const MOLPhysics *const a_molPhysics, const int &a_numStates, const bool &a_hasCoarser, const bool &a_hasFiner)
Actual constructor.
void noPPM(bool a_noPPM)
sets m_noPPM
bool m_highOrderLimiter
if true, use high-order limiter
Definition: LevelConsOperator.H:278
virtual void definePatch(const MOLPhysics *const a_molPhysics)
sets m_patchConsOperator
LevelData< FluxBox > m_fluxes
Definition: LevelConsOperator.H:242