Chombo + EB + MF  3.2
AMRLevelCons.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 _AMRLEVELCONS_H_
12 #define _AMRLEVELCONS_H_
13 
14 #include "FArrayBox.H"
15 #include "LevelData.H"
16 #include "AMRLevel.H"
17 #include "CoarseAverage.H"
18 #include "FourthOrderFineInterp.H"
19 #include "LevelFluxRegister.H"
20 
21 #include "LevelConsOperator.H"
22 #include "Box.H"
23 #include "IntVectSet.H"
24 #include "Vector.H"
25 #include "DisjointBoxLayout.H"
26 
27 #include "NamespaceHeader.H"
28 
29 /// AMR Level for fourth-order solution to conservation law
30 /**
31  */
32 class AMRLevelCons : public AMRLevel
33 {
34  friend class AMRLevelConsFactory ;
35 public:
36  /// Constructor
37  /**
38  */
39  AMRLevelCons();
40 
41  /// Destructor
42  /**
43  */
44  virtual ~AMRLevelCons();
45 
46  /// Define new AMR level
47  /**
48  */
49  virtual void define(AMRLevel* a_coarserLevelPtr,
50  const ProblemDomain& a_problemDomain,
51  int a_level,
52  int a_refRatio);
53 
54  /// Advance by one timestep by RK4, and return new timestep.
55  /**
56  */
57  virtual Real advance();
58 
59  /// add dissipation to m_Unew: Kreiss-Oliger artificial viscosity
60  /**
61  */
62  virtual void addDissipation();
63 
64  /// Things to do after a timestep -- reflux
65  /**
66  If (!m_hasFiner) then this does nothing except write out some
67  diagnostics depending on the verbosity level.
68  */
69  virtual void postTimeStep();
70 
71  /// Create tags for regridding
72  /**
73  */
74  virtual void tagCells(IntVectSet& a_tags) ;
75 
76  /// Create tags at initialization
77  /**
78  */
79  virtual void tagCellsInit(IntVectSet& a_tags) ;
80 
81  /// Set up data on this level after regridding
82  /**
83  */
84  virtual void regrid(const Vector<Box>& a_newGrids);
85 
86  /// Initialize grids
87  /**
88  */
89  virtual void initialGrid(const Vector<Box>& a_newGrids);
90 
91  /// Define m_Unew and m_Uold.
92  /**
93  */
94  virtual void defineDataHolders();
95 
96  /// Initialize data: Set m_Unew at time 0.
97  /**
98  */
99  virtual void initialData();
100 
101  /// Set a_U at time a_time.
102  /**
103  */
104  virtual void setData(LevelData<FArrayBox>& a_U,
105  Real a_time) const;
106 
107  /// Things to do after initialization
108  /**
109  */
110  virtual void postInitialize();
111 
112 #ifdef CH_USE_HDF5
113  /// Write checkpoint header
114  /**
115  */
116  virtual void writeCheckpointHeader(HDF5Handle& a_handle) const;
117 
118  /// Write checkpoint data for this level
119  /**
120  */
121  virtual void writeCheckpointLevel(HDF5Handle& a_handle) const;
122 
123  /// Read checkpoint header
124  /**
125  */
126  virtual void readCheckpointHeader(HDF5Handle& a_handle);
127 
128  /// Read checkpoint data for this level
129  /**
130  */
131  virtual void readCheckpointLevel(HDF5Handle& a_handle);
132 
133  /// Write plotfile header
134  /**
135  */
136  virtual void writePlotHeader(HDF5Handle& a_handle) const;
137 
138  /// Write plotfile data for this level
139  /**
140  */
141  virtual void writePlotLevel(HDF5Handle& a_handle) const;
142 #endif
143 
144  /// Returns the dt computed earlier for this level
145  /**
146  */
147  virtual Real computeDt();
148 
149  /// Compute dt using initial data
150  /**
151  */
152  virtual Real computeInitialDt();
153 
154  /// Return maximum speed from conserved variables
155  /**
156  */
157  virtual Real getMaxWaveSpeed(const LevelData<FArrayBox>& a_U);
158 
159  /// Set the CFL number
160  /**
161  */
162  virtual void CFL(Real a_cfl);
163 
164  /// Set the spatial order of accuracy
165  /**
166  can be 2 or 4 (default)
167  */
168  virtual void spaceOrder(int a_spaceOrder);
169 
170  /// sets whether to limit face values in operator
171  virtual void limitFaceValues(bool a_limitFaceValues);
172 
173  // sets whether to use high-order limiter
174  virtual void highOrderLimiter(bool a_highOrderLimiter);
175 
176  /// sets whether initial data is average; default false
177  virtual void initialAverage(bool a_initialAverage);
178 
179  /// sets whether to flatten extrapolations to faces
180  virtual void useFlattening(bool a_useFlattening);
181 
182  /// sets whether to use artificial viscosity
183  virtual void useArtVisc(bool a_useArtVisc);
184 
185  /// sets whether to turn off PPM
186  virtual void noPPM(bool a_noPPM);
187 
188  /// sets m_doDeconvolution
189  virtual void doDeconvolution(bool a_doDeconvolution);
190 
191  /// sets m_doFaceDeconvolution
192  virtual void doFaceDeconvolution(bool a_doFaceDeconvolution);
193 
194  /// sets whether to use artificial viscosity (from divergence)
195  virtual void useArtificialViscosity(bool a_useArtificialViscosity);
196 
197  /// sets coefficient of artificial viscosity (from divergence)
198  virtual void artificialViscosity(Real a_artificialViscosity);
199 
200  /// sets coefficient of artificial viscosity
201  virtual void ratioArtVisc(Real a_ratioArtVisc);
202 
203  /// sets whether forward Euler is used (instead of RK4)
204  virtual void forwardEuler(bool a_forwardEuler);
205 
206  /// sets whether to enforce a min value
207  virtual void enforceMinVal(bool a_enforceMinVal, Real a_minVal);
208 
209  /// Set the physical dimension of the longest side of the domain
210 
211  /**
212  */
213  virtual void domainLength(Real a_domainLength);
214 
215  /// Set the refinement threshold
216  /**
217  */
218  virtual void refinementThreshold(Real a_refineThresh);
219 
220  /// Set whether refinement threshold is scaled with dx
221  /**
222  */
223  virtual void refinementIsScaled(bool a_refinementIsScaled);
224 
225  /// Set whether to tag on pressure instead of on density
226  /**
227  */
228  virtual void tagPressure(bool a_tagPressure);
229 
230  /// Set whether to tag on vorticity instead of on density
231  /**
232  */
233  virtual void tagVorticity(bool a_tagVorticity);
234 
235  /// Set the tag buffer size
236  /**
237  */
238  void tagBufferSize(int a_tagBufferSize);
239 
240  /// Set the MOLPhysics class
241  /**
242  */
243  void molPhysics(const MOLPhysics* const a_molPhysics);
244 
245  /// Accessors
246  /**
247  */
249  {
250  return &m_Unew;
251  }
252 
253  // return high-order estimate of vorticity of m_Unew
254  void computeVorticity(LevelData<FArrayBox>& a_vorticity,
255  const LevelData<FArrayBox>& a_U) const;
256 
257 protected:
258 
259  virtual void setDefaultValues();
260 
261  // Create a load-balanced DisjointBoxLayout from a collection of Boxes
262  DisjointBoxLayout loadBalance(const Vector<Box>& a_grids);
263 
264  // Setup menagerie of data structures
265  virtual void levelSetup();
266 
267  // Transfer settings from this to m_levelConsOperator: called by levelSetup()
268  virtual void transferSettingsToLevelOp();
269 
270  // Transfer settings from a_amrConsPtr to this: called by define()
271  virtual void transferSettingsFromAMRLevel(AMRLevelCons* a_amrConsPtr);
272 
273  // Get the next coarser level
274  AMRLevelCons* getCoarserLevel() const;
275 
276  // Get the next finer level
277  AMRLevelCons* getFinerLevel() const;
278 
279  /// Advance by one timestep by RK4.
280  virtual void advanceU();
281 
282  /// Compute new timestep from m_Unew, and store it in m_dtNew.
283  virtual Real computeNewDt();
284 
285  /// Compute max vorticity of m_Unew, and store their magnitudes in a_vecMag.
286  virtual Real maxVorticity(LevelData<FArrayBox>& a_vecMag);
287 
288  /// Index within primitive variables for tagging cells
289  virtual int indexForTagging();
290 
291 private:
292  // Disallowed for all the usual reasons
293  void operator=(const AMRLevelCons& a_input);
294 
295  // Disallowed for all the usual reasons
296  AMRLevelCons(const AMRLevelCons& a_input);
297 
298 protected:
299 
300  // member variables
301 
302  // conserved variables U at old and new time
304 
305  // lower corner of problem domain in physical space
307 
308  // CFL number
310 
311  // spatial order of accuracy (default is 4)
313 
314  // if true, limit face values in advection operator
316 
317  /// if true, use high-order limiter
319 
320  // if true, initial values are average
322 
323  // if true, use flattening
325 
326  // if true, use artificial viscosity
328 
329  // if m_useArtVisc, artificial viscosity coefficient
331 
332  // use forward Euler if true, or RK4 if false
334 
335  // if true, enforce min value on advected quantity
337 
338  // Avoid PPM? Default false.
339  bool m_noPPM;
340 
341  // Do deconvolution? Default yes.
343 
344  // Do face deconvolution? Default yes.
346 
347  // use artificial viscosity (from divergence)?
349 
350  // coefficient of artificial viscosity (from divergence)
352 
353  // if enforcing minval, what value to enforce
355 
356  // Grid spacing
358 
359  // Averaging from coarse to fine level
361 
362  // New time step
364 
365  // Number of field variables (U) = number of conserved states
367 
368  // Names of conserved states
370 
371  // Number of ghost cells (in each direction)
373 
374  // Ghost cell vector
376 
377  // Physical dimension of the longest side of the domain
379 
380  // Interpolation from fine to coarse level
382 
383  // Level integrator
385 
386  // Flux register
388 
389  // Pointer to the class defining the physics of the problem
391 
392  // Refinement threshold for gradient
394 
395  // Whether refinement threshold is scaled with dx
397 
398  // Tag on pressure instead of on density?
400 
401  // Tag on vorticity instead of on density?
403 
404  // Tag buffer size
406 
407  // Flag coarser and finer levels
410 
412 };
413 
414 #include "NamespaceFooter.H"
415 
416 #endif
virtual void refinementThreshold(Real a_refineThresh)
Set the refinement threshold.
replaces coarse level data with an average of fine level data.
Definition: CoarseAverage.H:30
virtual void regrid(const Vector< Box > &a_newGrids)
Set up data on this level after regridding.
AMRLevelCons * getCoarserLevel() const
LevelConsOperator * m_levelConsOperatorPtr
Definition: AMRLevelCons.H:384
virtual Real maxVorticity(LevelData< FArrayBox > &a_vecMag)
Compute max vorticity of m_Unew, and store their magnitudes in a_vecMag.
virtual void enforceMinVal(bool a_enforceMinVal, Real a_minVal)
sets whether to enforce a min value
An irregular domain on an integer lattice.
Definition: IntVectSet.H:44
virtual void postInitialize()
Things to do after initialization.
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
void operator=(const AMRLevelCons &a_input)
virtual void domainLength(Real a_domainLength)
Set the physical dimension of the longest side of the domain.
void computeVorticity(LevelData< FArrayBox > &a_vorticity, const LevelData< FArrayBox > &a_U) const
Real m_ratioArtVisc
Definition: AMRLevelCons.H:330
virtual void tagVorticity(bool a_tagVorticity)
Set whether to tag on vorticity instead of on density.
virtual void setDefaultValues()
bool m_forwardEuler
Definition: AMRLevelCons.H:333
virtual void writePlotLevel(HDF5Handle &a_handle) const
Write plotfile data for this level.
bool m_useArtVisc
Definition: AMRLevelCons.H:327
bool m_hasFiner
Definition: AMRLevelCons.H:409
bool m_enforceMinVal
Definition: AMRLevelCons.H:336
virtual Real computeInitialDt()
Compute dt using initial data.
virtual void writeCheckpointLevel(HDF5Handle &a_handle) const
Write checkpoint data for this level.
virtual void ratioArtVisc(Real a_ratioArtVisc)
sets coefficient of artificial viscosity
Fourth-order interpolation in space.
Definition: FourthOrderFineInterp.H:25
AMRLevelCons()
Constructor.
bool m_refinementIsScaled
Definition: AMRLevelCons.H:396
Abstract base class for time-dependent data at a level of refinement.
Definition: AMRLevel.H:47
virtual void writePlotHeader(HDF5Handle &a_handle) const
Write plotfile header.
Definition: MOLPhysics.H:37
virtual int indexForTagging()
Index within primitive variables for tagging cells.
bool m_tagPressure
Definition: AMRLevelCons.H:399
virtual void useArtVisc(bool a_useArtVisc)
sets whether to use artificial viscosity
DisjointBoxLayout loadBalance(const Vector< Box > &a_grids)
virtual void readCheckpointLevel(HDF5Handle &a_handle)
Read checkpoint data for this level.
bool m_highOrderLimiter
if true, use high-order limiter
Definition: AMRLevelCons.H:318
Real m_artificialViscosity
Definition: AMRLevelCons.H:351
AMR Level for fourth-order solution to conservation law.
Definition: AMRLevelCons.H:32
Real m_r0
Definition: AMRLevelCons.H:306
Vector< std::string > m_stateNames
Definition: AMRLevelCons.H:369
LevelData< FArrayBox > m_Uold
Definition: AMRLevelCons.H:303
virtual void levelSetup()
virtual void tagCells(IntVectSet &a_tags)
Create tags for regridding.
bool m_doDeconvolution
Definition: AMRLevelCons.H:342
virtual Real getMaxWaveSpeed(const LevelData< FArrayBox > &a_U)
Return maximum speed from conserved variables.
virtual void initialData()
Initialize data: Set m_Unew at time 0.
virtual void CFL(Real a_cfl)
Set the CFL number.
void tagBufferSize(int a_tagBufferSize)
Set the tag buffer size.
virtual void readCheckpointHeader(HDF5Handle &a_handle)
Read checkpoint header.
LevelData< FArrayBox > * U()
Accessors.
Definition: AMRLevelCons.H:248
virtual void useArtificialViscosity(bool a_useArtificialViscosity)
sets whether to use artificial viscosity (from divergence)
virtual Real computeDt()
Returns the dt computed earlier for this level.
virtual void transferSettingsFromAMRLevel(AMRLevelCons *a_amrConsPtr)
LevelFluxRegister m_fluxRegister
Definition: AMRLevelCons.H:387
virtual void artificialViscosity(Real a_artificialViscosity)
sets coefficient of artificial viscosity (from divergence)
bool m_tagVorticity
Definition: AMRLevelCons.H:402
FourthOrderFineInterp m_fineInterp
Definition: AMRLevelCons.H:381
Real m_dx
Definition: AMRLevelCons.H:357
virtual void initialGrid(const Vector< Box > &a_newGrids)
Initialize grids.
virtual void forwardEuler(bool a_forwardEuler)
sets whether forward Euler is used (instead of RK4)
bool m_doFaceDeconvolution
Definition: AMRLevelCons.H:345
virtual void tagPressure(bool a_tagPressure)
Set whether to tag on pressure instead of on density.
AMR Cons Equation factory.
Definition: AMRLevelConsFactory.H:22
CoarseAverage * m_coarseAveragePtr
Definition: AMRLevelCons.H:360
virtual void postTimeStep()
Things to do after a timestep – reflux.
virtual void defineDataHolders()
Define m_Unew and m_Uold.
Real m_minVal
Definition: AMRLevelCons.H:354
double Real
Definition: REAL.H:33
virtual void doFaceDeconvolution(bool a_doFaceDeconvolution)
sets m_doFaceDeconvolution
virtual ~AMRLevelCons()
Destructor.
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
Real m_refineThresh
Definition: AMRLevelCons.H:393
virtual void setData(LevelData< FArrayBox > &a_U, Real a_time) const
Set a_U at time a_time.
virtual void advanceU()
Advance by one timestep by RK4.
virtual void limitFaceValues(bool a_limitFaceValues)
sets whether to limit face values in operator
void molPhysics(const MOLPhysics *const a_molPhysics)
Set the MOLPhysics class.
virtual Real computeNewDt()
Compute new timestep from m_Unew, and store it in m_dtNew.
DisjointBoxLayout m_grids
Definition: AMRLevelCons.H:411
virtual void highOrderLimiter(bool a_highOrderLimiter)
LevelFluxRegister-A class to encapsulate a levels worth of flux registers.
Definition: LevelFluxRegister.H:29
virtual void spaceOrder(int a_spaceOrder)
Set the spatial order of accuracy.
IntVect m_ghostVect
Definition: AMRLevelCons.H:375
int m_numStates
Definition: AMRLevelCons.H:366
virtual void refinementIsScaled(bool a_refinementIsScaled)
Set whether refinement threshold is scaled with dx.
bool m_noPPM
Definition: AMRLevelCons.H:339
virtual void useFlattening(bool a_useFlattening)
sets whether to flatten extrapolations to faces
Level Cons Operator - a class for evaluating the Laplacian.
Definition: LevelConsOperator.H:35
virtual void writeCheckpointHeader(HDF5Handle &a_handle) const
Write checkpoint header.
bool m_useArtificialViscosity
Definition: AMRLevelCons.H:348
Handle to a particular group in an HDF file.
Definition: CH_HDF5.H:294
int m_numGhost
Definition: AMRLevelCons.H:372
bool m_limitFaceValues
Definition: AMRLevelCons.H:315
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
virtual void addDissipation()
add dissipation to m_Unew: Kreiss-Oliger artificial viscosity
virtual Real advance()
Advance by one timestep by RK4, and return new timestep.
AMRLevelCons * getFinerLevel() const
LevelData< FArrayBox > m_Unew
Definition: AMRLevelCons.H:303
MOLPhysics * m_molPhysics
Definition: AMRLevelCons.H:390
virtual void doDeconvolution(bool a_doDeconvolution)
sets m_doDeconvolution
virtual void define(AMRLevel *a_coarserLevelPtr, const ProblemDomain &a_problemDomain, int a_level, int a_refRatio)
Define new AMR level.
bool m_hasCoarser
Definition: AMRLevelCons.H:408
virtual void noPPM(bool a_noPPM)
sets whether to turn off PPM
int m_spaceOrder
Definition: AMRLevelCons.H:312
virtual void transferSettingsToLevelOp()
virtual void tagCellsInit(IntVectSet &a_tags)
Create tags at initialization.
int m_tagBufferSize
Definition: AMRLevelCons.H:405
Real m_domainLength
Definition: AMRLevelCons.H:378
bool m_useFlattening
Definition: AMRLevelCons.H:324
Real m_cfl
Definition: AMRLevelCons.H:309
virtual void initialAverage(bool a_initialAverage)
sets whether initial data is average; default false
Real m_dtNew
Definition: AMRLevelCons.H:363
bool m_initialAverage
Definition: AMRLevelCons.H:321