Chombo + EB + MF  3.2
AMRLevelMappedCons.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 _AMRLEVELMAPPEDCONS_H_
12 #define _AMRLEVELMAPPEDCONS_H_
13 
14 #include "Vector.H"
15 #include "IntVectSet.H"
16 #include "Box.H"
17 #include "FArrayBox.H"
18 #include "DisjointBoxLayout.H"
19 #include "LevelData.H"
20 #include "LevelFluxRegister.H"
21 #include "CoarseAverage.H"
22 #include "AMRLevelCons.H"
23 #include "MappedLevelData.H"
24 #include "MultiBlockCoordSys.H"
25 #include "MultiBlockUtil.H"
28 
30 
31 #include "NamespaceHeader.H"
32 
33 //--Forward declarations
34 
35 class LevelGridMetrics;
36 
37 
38 /*******************************************************************************
39  */
40 /// AMR Level for fourth-order solution to conservation law
41 /**
42  *//*+*************************************************************************/
43 
45 {
47  friend class LevelGridMetrics;
48 
49 public:
50 
51  /// Factory constructor
52  AMRLevelMappedCons(MultiBlockCoordSysFactory *const a_coordSysFact,
53  const AMRLevelMappedStabilityStrategy* const a_stabilityStrategy,
54  const AMRLevelMappedTaggingStrategy* const a_taggingStategy);
55 
56  /// Destructor
57  virtual ~AMRLevelMappedCons();
58 
59 
60 /*==============================================================================
61  * Member functions
62  *============================================================================*/
63 
64  /// Define new AMR level
65  virtual void define(AMRLevel* a_coarserLevelPtr,
66  const ProblemDomain& a_problemDomain,
67  int a_level,
68  int a_refRatio);
69 
70  /// Advance by one timestep by RK4, and return new timestep.
71  virtual Real advance();
72 
73  /// add dissipation to m_Unew: Kreiss-Oliger artificial viscosity
74 // virtual void addDissipation();
75 
76  /// Things to do after a timestep -- reflux
77  virtual void postTimeStep();
78 
79  /// Create tags for regridding
80  virtual void tagCells(IntVectSet& a_tags) ;
81 
82  /// Create tags at initialization
83  virtual void tagCellsInit(IntVectSet& a_tags) ;
84 
85  /// Pre-regrid operations necessary for updating metric terms
86  virtual void preRegrid(int a_base_level,
87  const Vector<Vector<Box> >& a_new_grids);
88 
89  /// Set up data on this level after regridding
90  virtual void regrid(const Vector<Box>& a_newGrids);
91 
92  /// Initialize grids
93  virtual void initialGrid(const Vector<Box>& a_newGrids);
94 
95  /// Compute the grid metrics for mapped grids
96  virtual void postInitialGrid(const bool a_restart);
97 
98  /// Initialize data
99  virtual void initialData();
100 
101  /// Things to do after initialization
102  virtual void postInitialize();
103 
104 #ifdef CH_USE_HDF5
105  /// Write checkpoint header
106  virtual void writeCheckpointHeader(HDF5Handle& a_handle) const;
107 
108  /// Write checkpoint data for this level
109  virtual void writeCheckpointLevel(HDF5Handle& a_handle) const;
110 
111  /// Read checkpoint header
112  virtual void readCheckpointHeader(HDF5Handle& a_handle);
113 
114  /// Read checkpoint data for this level
115  virtual void readCheckpointLevel(HDF5Handle& a_handle);
116 
117  /// Write plotfile header
118  virtual void writePlotHeader(HDF5Handle& a_handle) const;
119 
120  /// Write plotfile data for this level
121  virtual void writePlotLevel(HDF5Handle& a_handle) const;
122 
123  /// Write mapped-grid info
124  virtual void writeMappedPlotFile() const;
125 
126 
127 #endif
128 
129  /// Conclude by testing conservation if necessary
130  virtual void conclude(int a_step) const;
131 
132  /// Compute dt using initial data
133  virtual Real computeInitialDt();
134 
135  void coordinateSystem(MultiBlockCoordSysFactory* a_coordSysFact);
136 
137  /// Return maximum speed from conserved variables
138  virtual Real getMaxWaveSpeed(const LevelData<FArrayBox>& a_U);
139 
140  /// Set whether to use a source term
141  void useSourceTerm(bool a_useSourceTerm);
142 
143  /// Set the source term
144  void sourceTerm(const LevelSourceTerm* const a_sourceTerm);
145 
146  /// Set whether to add artificial dissipation
147  void useArtificialDissipation(bool a_useArtificialDissipation);
148 
149  /// Set coefficient of artificial dissipation
150  void artificialDissipation(Real a_artificialDissipation);
151 
152  /// Set the MOLPhysics class
153 /*
154  void molPhysics(const MOLPhysics* const a_molPhysics);
155 */
156 
157 #if 0
158  /// return high-order estimate of vorticity of m_Unew
159  void computeVorticity(LevelData<FArrayBox>& a_vorticity,
160  const LevelData<FArrayBox>& a_U) const;
161 #endif
162 
163 protected:
164 
165  virtual void setDefaultValues();
166 
167 /*
168  /// Create a load-balanced DisjointBoxLayout from a collection of Boxes
169  DisjointBoxLayout loadBalance(const Vector<Box>& a_grids);
170 */
171 
172  /// Setup menagerie of data structures
173  virtual void levelSetup();
174 
175  /// Transfer settings from this to m_levelMappedConsOperator: called by levelSetup()
176  virtual void transferSettingsToLevelOp();
177 
178  /// Transfer settings from a_amrConsPtr to this: called by define()
179  virtual void transferSettingsFromAMRLevelMapped(AMRLevelMappedCons* a_amrConsPtr);
180 
181  /// Get the next coarser level
183 
184  /// Get the next finer level
186 
187  /// Advance by one timestep by RK4.
188  virtual void advanceU();
189 
190  /// Compute new timestep from m_Unew, and store it in m_dtNew.
191  virtual Real computeNewDt();
192 
193  /// Index within primitive variables for tagging cells
194  virtual int indexForTagging();
195 
196  /// Compute a norm for some reason
197  void myComputeNorm(const int a_type, Vector<Real>& a_norm) const;
198 
199  /// Compute and write out norm of conserved quantities
200  void reportNorm() const;
201 
202  /// Report norms of errors (requires exact solution)
203  void reportError() const;
204 
205  /// Initialize <U> and <JU> at time m_time.
206  virtual void setData(LevelData<FArrayBox>& a_U,
207  LevelData<FArrayBox>& a_JU) const;
208 
209  void writeJ(bool a_writeJ)
210  {
211  s_writeJ = a_writeJ;
212  }
213 
214  void writeExact(bool a_writeExact)
215  {
216  s_writeExact = a_writeExact;
217  }
218 
219  void writeError(bool a_writeError)
220  {
221  s_writeError = a_writeError;
222  }
223 
224  void writeMap(bool a_writeMap)
225  {
226  s_writeMap = a_writeMap;
227  }
228 
229 private:
230 
231  // Copy and assignment not allowed
232  AMRLevelMappedCons(const AMRLevelMappedCons& a_input);
233  void operator=(const AMRLevelMappedCons& a_input);
234 
235 
236 /*==============================================================================
237  * Data members
238  *============================================================================*/
239 
240 protected:
241 
242 //--Parameters initialized by factory constructor
243 
244  // Factory for the coordinate system in each block
246  // A pointer to the instance of the coordinate system for this level.
248  // A pointer to the instance of the coordinate system for finer level.
250 
252 
253 //--Parameters initialized by define
254 
255  // Grid metrics for the level
257 
258  // Level data (conserved variables <JU> and <U>)
260 
261  // Level integrator
263 
264  // Multiblock-capable flux register
266 
268 
270 
272 
274 
275  // Strategy for computing a stable time step.
277 
278  // Strategy for determining which cells to tag for refinement.
280 
281  // Prefix for the plot file name
282  std::string m_plotPrefix;
283 
285 
286  static int s_finestLevel; ///< The finest level from the initial
287  ///< grid or latest regrid.
288 
289 //--Testing/validation
290 
292  ///< L_1 norm of JU at start of solution
293  ///< used for checking conservation
294 
295  /// whether to write out J
296  static bool s_writeJ;
297 
298  /// whether to write out exact value from time
299  static bool s_writeExact;
300 
301  /// whether to write out error from time
302  static bool s_writeError;
303 
304  /// whether to write out mapping file
305  static bool s_writeMap;
306 
308 
310 };
311 
312 #include "NamespaceFooter.H"
313 
314 #endif
virtual void setDefaultValues()
Set the MOLPhysics class.
bool m_useSourceTerm
Definition: AMRLevelMappedCons.H:269
virtual void initialGrid(const Vector< Box > &a_newGrids)
Initialize grids.
virtual Real computeNewDt()
Compute new timestep from m_Unew, and store it in m_dtNew.
RefCountedPtr< LevelData< FArrayBox > > m_JUexactPtr
Definition: AMRLevelMappedCons.H:309
virtual void postInitialize()
Things to do after initialization.
A reference-counting handle class.
Definition: RefCountedPtr.H:173
MultiBlockCoordSysFactory * m_coordSysFact
Definition: AMRLevelMappedCons.H:245
virtual void readCheckpointLevel(HDF5Handle &a_handle)
Read checkpoint data for this level.
An irregular domain on an integer lattice.
Definition: IntVectSet.H:44
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
void reportNorm() const
Compute and write out norm of conserved quantities.
void useArtificialDissipation(bool a_useArtificialDissipation)
Set whether to add artificial dissipation.
void computeVorticity(LevelData< FArrayBox > &a_vorticity, const LevelData< FArrayBox > &a_U) const
virtual void writeMappedPlotFile() const
Write mapped-grid info.
one dimensional dynamic array
Definition: Vector.H:53
virtual void conclude(int a_step) const
Conclude by testing conservation if necessary.
Solution data on a level for mapped grids.
Definition: MappedLevelData.H:54
void myComputeNorm(const int a_type, Vector< Real > &a_norm) const
Compute a norm for some reason.
virtual Real advance()
Advance by one timestep by RK4, and return new timestep.
virtual void writeCheckpointHeader(HDF5Handle &a_handle) const
Write checkpoint header.
Abstract base class for time-dependent data at a level of refinement.
Definition: AMRLevel.H:47
void writeMap(bool a_writeMap)
Definition: AMRLevelMappedCons.H:224
void writeJ(bool a_writeJ)
Definition: AMRLevelMappedCons.H:209
AMR Level for fourth-order solution to conservation law.
Definition: AMRLevelCons.H:32
std::string m_plotPrefix
Definition: AMRLevelMappedCons.H:282
virtual void setData(LevelData< FArrayBox > &a_U, LevelData< FArrayBox > &a_JU) const
Initialize <U> and <JU> at time m_time.
virtual void advanceU()
Advance by one timestep by RK4.
AMR Cons Equation factory.
Definition: AMRLevelMappedConsFactory.H:22
RefCountedPtr< LevelData< FArrayBox > > m_UexactPtr
Definition: AMRLevelMappedCons.H:307
Definition: AMRLevelMappedStabilityStrategy.H:23
LevelMappedConsOperator * m_levelMappedConsOperatorPtr
Definition: AMRLevelMappedCons.H:262
AMRLevelMappedTaggingStrategy * m_taggingStrategy
Definition: AMRLevelMappedCons.H:279
virtual void initialData()
Initialize data.
virtual void writePlotLevel(HDF5Handle &a_handle) const
Write plotfile data for this level.
virtual void tagCellsInit(IntVectSet &a_tags)
Create tags at initialization.
static int s_finestLevel
Definition: AMRLevelMappedCons.H:286
virtual void postInitialGrid(const bool a_restart)
Compute the grid metrics for mapped grids.
static bool s_writeError
whether to write out error from time
Definition: AMRLevelMappedCons.H:302
virtual void writeCheckpointLevel(HDF5Handle &a_handle) const
Write checkpoint data for this level.
MultiBlockCoordSys * m_coordSys
Definition: AMRLevelMappedCons.H:247
void reportError() const
Report norms of errors (requires exact solution)
virtual void levelSetup()
Setup menagerie of data structures.
double Real
Definition: REAL.H:33
Grid metrics for a level.
Definition: LevelGridMetrics.H:223
virtual void preRegrid(int a_base_level, const Vector< Vector< Box > > &a_new_grids)
Pre-regrid operations necessary for updating metric terms.
LevelGridMetrics * m_levelGridMetricsPtr
Definition: AMRLevelMappedCons.H:256
AMRLevelMappedCons * getCoarserLevel() const
Get the next coarser level.
virtual void transferSettingsFromAMRLevelMapped(AMRLevelMappedCons *a_amrConsPtr)
Transfer settings from a_amrConsPtr to this: called by define()
static bool s_writeMap
whether to write out mapping file
Definition: AMRLevelMappedCons.H:305
Real m_artificialDissipation
Definition: AMRLevelMappedCons.H:273
Definition: LevelMappedConsOperator.H:42
virtual void writePlotHeader(HDF5Handle &a_handle) const
Write plotfile header.
virtual interface class encapsulating multi-block mapping API
Definition: MultiBlockCoordSys.H:34
AMRLevelMappedStabilityStrategy * m_stabilityStrategy
Definition: AMRLevelMappedCons.H:276
void useSourceTerm(bool a_useSourceTerm)
Set whether to use a source term.
AMRLevelMappedCons(MultiBlockCoordSysFactory *const a_coordSysFact, const AMRLevelMappedStabilityStrategy *const a_stabilityStrategy, const AMRLevelMappedTaggingStrategy *const a_taggingStategy)
Factory constructor.
bool m_useArtificialDissipation
Definition: AMRLevelMappedCons.H:271
static bool s_writeExact
whether to write out exact value from time
Definition: AMRLevelMappedCons.H:299
LevelFluxRegister-A class to encapsulate a levels worth of flux registers.
Definition: LevelFluxRegister.H:29
static Vector< Real > s_L1NormJUConsvRef
Definition: AMRLevelMappedCons.H:291
MultiBlockCoordSys * m_coordSysFine
Definition: AMRLevelMappedCons.H:249
The class MultiBlockUtil contains some functions used by MultiBlockLevelGeom, MultiBlockLevelExchange...
Definition: MultiBlockUtil.H:23
virtual void define(AMRLevel *a_coarserLevelPtr, const ProblemDomain &a_problemDomain, int a_level, int a_refRatio)
Define new AMR level.
virtual Real computeInitialDt()
Compute dt using initial data.
virtual void tagCells(IntVectSet &a_tags)
Create tags for regridding.
void sourceTerm(const LevelSourceTerm *const a_sourceTerm)
Set the source term.
Handle to a particular group in an HDF file.
Definition: CH_HDF5.H:294
virtual ~AMRLevelMappedCons()
Destructor.
virtual void readCheckpointHeader(HDF5Handle &a_handle)
Read checkpoint header.
pure-virtual base class defining factory interface for MultiBlockCoordSys
Definition: MultiBlockCoordSys.H:409
MultiBlockUtil m_mbUtil
Definition: AMRLevelMappedCons.H:251
Definition: LevelSourceTerm.H:21
AMRLevelMappedCons * getFinerLevel() const
Get the next finer level.
void operator=(const AMRLevelMappedCons &a_input)
void writeError(bool a_writeError)
Definition: AMRLevelMappedCons.H:219
virtual void postTimeStep()
add dissipation to m_Unew: Kreiss-Oliger artificial viscosity
static bool s_writeJ
whether to write out J
Definition: AMRLevelMappedCons.H:296
Maintenance of <U> and <JU>
virtual void regrid(const Vector< Box > &a_newGrids)
Set up data on this level after regridding.
Definition: AMRLevelMappedTaggingStrategy.H:24
AMR Level for fourth-order solution to conservation law.
Definition: AMRLevelMappedCons.H:44
void coordinateSystem(MultiBlockCoordSysFactory *a_coordSysFact)
void writeExact(bool a_writeExact)
Definition: AMRLevelMappedCons.H:214
virtual Real getMaxWaveSpeed(const LevelData< FArrayBox > &a_U)
Return maximum speed from conserved variables.
virtual int indexForTagging()
Index within primitive variables for tagging cells.
LevelSourceTerm * m_sourceTermPtr
Definition: AMRLevelMappedCons.H:284
void artificialDissipation(Real a_artificialDissipation)
Set coefficient of artificial dissipation.
MappedLevelData m_data
Definition: AMRLevelMappedCons.H:259
int m_levelStep
Definition: AMRLevelMappedCons.H:267
LevelFluxRegister * m_fluxRegisterPtr
Definition: AMRLevelMappedCons.H:265
virtual void transferSettingsToLevelOp()
Transfer settings from this to m_levelMappedConsOperator: called by levelSetup()