Chombo + EB + MF  3.2
MappedLevelData.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 _MAPPEDLEVELDATA_H_
12 #define _MAPPEDLEVELDATA_H_
13 
14 
15 /******************************************************************************/
16 /**
17  * \file
18  *
19  * \brief Maintenance of <U> and <JU>
20  *
21  *//*+*************************************************************************/
22 
23 #include "Copier.H"
24 #include "FArrayBox.H"
25 #include "LevelData.H"
26 #include "NamespaceHeader.H"
27 
28 //--Forward declarations
29 
30 class LevelGridMetrics;
32 
33 
34 /*******************************************************************************
35  */
36 /// Solution data on a level for mapped grids
37 /**
38  * This class aids the user with maintaining <U> and <JU> on the level.
39  * These quantities are frequently updated during the AMR process requiring
40  * new compuations of <\U> and exchanging or filling ghosts. This routine
41  * tracks the number of ghosts and performs the appropriate operations to
42  * return either <\U> or <JU> with the requested number of valid or
43  * invalid ghost cells.
44  *
45  * \note
46  * <ul>
47  * <li> Beware that if getU() and getJUNew() are used as used as arguments
48  * to a function, the order in which they are invoked is not defined
49  * and getU() may have side-effects on <JU>
50  * </ul>
51  *
52  *//*+*************************************************************************/
53 
55 {
56 
57 public:
58 
59 /*==============================================================================
60  * Constructors and destructors
61  *============================================================================*/
62 
63 public:
64 
65  /// Default constructor
67 
68  /// Destructor
70 
71 private:
72 
73  // Copy and assignment not allowed
76 
77 
78 /*==============================================================================
79  * Member functions
80  *============================================================================*/
81 
82 public:
83 
84  ///
85  void define(LevelGridMetrics *const a_LGMP,
86  LevelData<FArrayBox> *const a_ULevP,
87  LevelData<FArrayBox> *const a_JUNewLevP,
88  LevelData<FArrayBox> *const a_JUOldLevP,
89  const LevelData<FArrayBox> *const a_CrULevP,
90  const int a_numComp,
91  const Interval& a_velocityIntv,
92  const int a_numGhostU,
93  const int a_numGhostJU = 1,
94  const bool a_trimUExchanger = false,
95  const bool a_trimJUExchanger = true,
96  const bool a_useJUExchangerForU = true);
97 
98  ///
99  void reshapeJUNew();
100 
101  ///
102  void reshapeJUOld();
103 
104  ///
105  void reshapeU();
106 
107  ///
108  const LevelData<FArrayBox>& getU(const int a_numValidGhost = 0,
109  const int a_numInvalidGhost = 0) const;
110 
111  ///
112  LevelData<FArrayBox>& getU(const int a_numValidGhost = 0,
113  const int a_numInvalidGhost = 0);
114 
115  ///
116  const LevelData<FArrayBox>& getJU(const int a_numValidGhost = 0,
117  const int a_numInvalidGhost = 0) const;
118 
119  ///
120  LevelData<FArrayBox>& getJU(const int a_numValidGhost = 0,
121  const int a_numInvalidGhost = 0);
122 
123  /// Return JUOld (always raw)
125 
126  /// Return pointer to U data with no computation
127  const LevelData<FArrayBox>& rawU() const;
129 
130  /// Return pointer to JU data with no computation
131  const LevelData<FArrayBox>& rawJU() const;
133 
134  /// Invalidate all of <U>
135  void invalidateU(const bool a_this2FnInterpDataInvalid = true);
136 
137  ///
138  void invalidateJUGhosts();
139 
140  /// Invalidate all ghost data and all of <U>
141  void invalidate(const bool a_this2FnInterpDataInvalid = true);
142 
143  /// (assumes the same layout)
144  void copyJUNewToOld();
145 
146  /// (assumes different layouts)
147  void copyJUOldToNew();
148 
149  ///
150  void swapJUNewAndOld();
151 
152  /// Return the exchange copier for U
153  const Copier& getUExchangeCopier() const;
154 
155  /// Return the exchange copier for JU
156  const Copier& getJUExchangeCopier() const;
157 
158 //--Used to reference objects in this class, even before defined
159 
160  /// Return the exchange copier for U (before defined)
161  const Copier& refUExchangeCopier() const;
162 
163  /// Return the exchange copier for JU (before defined)
164  const Copier& refJUExchangeCopier() const;
165 
166 protected:
167 
168  ///
169  void deallocate();
170 
171  ///
172  void fillInvalidGhosts();
173 
174  ///
175  bool hasCoarser() const;
176 
177 
178 /*==============================================================================
179  * Data members
180  *============================================================================*/
181 
182 protected:
184 
187 
189 
192 
193  Interval m_velocityIntv; ///< The velocity interval in the
194  ///< components of <U> (or any other
195  ///< space vectors but only 1 is
196  ///< supported)
197 
198  int m_invalidGhostStatusU; ///< The number of invalid ghosts (those
199  ///< that do not overlap valid cells on
200  ///< this level) in which /<U/> has been
201  ///< interpolated.
203 
206 
207  int m_validCFLayerStatusU; ///< If > 0, the number of layers of valid
208  ///< cells near the coarse-fine interface
209  ///< that have not been filled
210  int m_extraBlockStatusU; ///< The number of extra-block ghost cells
211  ///< in which <U> has been exchanged.
212  ///< These are really valid ghosts but
213  ///< are tracked separately.
214 
216 
219 
222 
223  int m_allocU;
226 
230 
232 
233  bool m_defined;
234 };
235 
236 
237 /*******************************************************************************
238  *
239  * Class MappedLevelData: inline member definitions
240  *
241  ******************************************************************************/
242 
243 /*--------------------------------------------------------------------*/
244 // Return pointer to U data with no computation
245 /** Should only be used for accessing memory. Assume data is invalid.
246  *//*-----------------------------------------------------------------*/
247 
248 inline const LevelData<FArrayBox>&
250 {
252  return *m_ULevP;
253 }
254 
255 inline LevelData<FArrayBox>&
257 {
259  return *m_ULevP;
260 }
261 
262 /*--------------------------------------------------------------------*/
263 // Return pointer to JU data with no computation
264 /** Should only be used for accessing memory. Assume data is invalid.
265  *//*-----------------------------------------------------------------*/
266 
267 inline const LevelData<FArrayBox>&
269 {
271  return *(m_JULevP[m_indexJUNew]);
272 }
273 
274 inline LevelData<FArrayBox>&
276 {
278  return *(m_JULevP[m_indexJUNew]);
279 }
280 
281 /*--------------------------------------------------------------------*/
282 // Return JUOld
283 /** You can't set ghosts anymore so make sure JUNew has ghosts set
284  * properly before you make it old.
285  *//*-----------------------------------------------------------------*/
286 
287 inline LevelData<FArrayBox>&
289 {
291  return *(m_JULevP[m_indexJUOld]);
292 }
293 
294 /*--------------------------------------------------------------------*/
295 // Return the exchange copier for U
296 /*--------------------------------------------------------------------*/
297 
298 inline const Copier&
300 {
302  return m_UExchangeCopier;
303 }
304 
305 /*--------------------------------------------------------------------*/
306 // Return the exchange copier for JU
307 /*--------------------------------------------------------------------*/
308 
309 inline const Copier&
311 {
313  return m_JUExchangeCopier;
314 }
315 
316 /*--------------------------------------------------------------------*/
317 // Return the exchange copier for U (before defined)
318 /** Should only be used for accessing memory. Assume not defined.
319  *//*-----------------------------------------------------------------*/
320 
321 inline const Copier&
323 {
324  return m_UExchangeCopier;
325 }
326 
327 /*--------------------------------------------------------------------*/
328 // Return the exchange copier for JU (before defined)
329 /** Should only be used for accessing memory. Assume not defined.
330  *//*-----------------------------------------------------------------*/
331 
332 inline const Copier&
334 {
335  return m_JUExchangeCopier;
336 }
337 
338 /*--------------------------------------------------------------------*/
339 
340 inline bool
342 {
343  return (m_CrULevP != 0);
344 }
345 
346 #include "NamespaceFooter.H"
347 #endif
void invalidate(const bool a_this2FnInterpDataInvalid=true)
Invalidate all ghost data and all of <U>
const Copier & refJUExchangeCopier() const
Return the exchange copier for JU (before defined)
Definition: MappedLevelData.H:333
void copyJUOldToNew()
(assumes different layouts)
void fillInvalidGhosts()
int m_indexJUOld
Definition: MappedLevelData.H:220
#define CH_assert(cond)
Definition: CHArray.H:37
bool m_haveValidCrFnU
Definition: MappedLevelData.H:231
void define(LevelGridMetrics *const a_LGMP, LevelData< FArrayBox > *const a_ULevP, LevelData< FArrayBox > *const a_JUNewLevP, LevelData< FArrayBox > *const a_JUOldLevP, const LevelData< FArrayBox > *const a_CrULevP, const int a_numComp, const Interval &a_velocityIntv, const int a_numGhostU, const int a_numGhostJU=1, const bool a_trimUExchanger=false, const bool a_trimJUExchanger=true, const bool a_useJUExchangerForU=true)
const LevelData< FArrayBox > & rawJU() const
Return pointer to JU data with no computation.
Definition: MappedLevelData.H:268
bool m_defined
Definition: MappedLevelData.H:233
const LevelData< FArrayBox > & rawU() const
Return pointer to U data with no computation.
Definition: MappedLevelData.H:249
Solution data on a level for mapped grids.
Definition: MappedLevelData.H:54
A strange but true thing to make copying from one boxlayoutdata to another fast.
Definition: Copier.H:152
int m_numGhostU
Definition: MappedLevelData.H:217
LevelGridMetrics * m_LGMP
Definition: MappedLevelData.H:183
Copier m_JUExchangeCopier
Definition: MappedLevelData.H:191
bool m_trimJUExchanger
Definition: MappedLevelData.H:228
int m_numComp
Definition: MappedLevelData.H:215
The class MultiBlockLevelExchange stores topological and geometric information.
Definition: MultiBlockLevelExchange.H:29
const Copier & refUExchangeCopier() const
Return the exchange copier for U (before defined)
Definition: MappedLevelData.H:322
void invalidateU(const bool a_this2FnInterpDataInvalid=true)
Invalidate all of <U>
int m_invalidGhostStatusJU
Definition: MappedLevelData.H:202
void invalidateJUGhosts()
LevelData< FArrayBox > & getJUOld()
Return JUOld (always raw)
Definition: MappedLevelData.H:288
int m_extraBlockStatusU
Definition: MappedLevelData.H:210
Structure for passing component ranges in code.
Definition: Interval.H:23
int m_invalidGhostStatusU
Definition: MappedLevelData.H:198
Grid metrics for a level.
Definition: LevelGridMetrics.H:223
~MappedLevelData()
Destructor.
Copier m_UExchangeCopier
Definition: MappedLevelData.H:190
void swapJUNewAndOld()
const Copier & getUExchangeCopier() const
Return the exchange copier for U.
Definition: MappedLevelData.H:299
bool m_useJUExchangerForU
Definition: MappedLevelData.H:229
const LevelData< FArrayBox > & getJU(const int a_numValidGhost=0, const int a_numInvalidGhost=0) const
int m_allocJUNew
Definition: MappedLevelData.H:224
bool hasCoarser() const
Definition: MappedLevelData.H:341
const LevelData< FArrayBox > * m_CrULevP
Definition: MappedLevelData.H:188
int m_validCFLayerStatusU
Definition: MappedLevelData.H:207
int m_validStatusU
Definition: MappedLevelData.H:204
LevelData< FArrayBox > * m_ULevP
Definition: MappedLevelData.H:185
bool m_trimUExchanger
Definition: MappedLevelData.H:227
int m_numGhostJU
Definition: MappedLevelData.H:218
const Copier & getJUExchangeCopier() const
Return the exchange copier for JU.
Definition: MappedLevelData.H:310
void copyJUNewToOld()
(assumes the same layout)
int m_allocJUOld
Definition: MappedLevelData.H:225
Interval m_velocityIntv
Definition: MappedLevelData.H:193
const LevelData< FArrayBox > & getU(const int a_numValidGhost=0, const int a_numInvalidGhost=0) const
MappedLevelData & operator=(const MappedLevelData &)
int m_allocU
Definition: MappedLevelData.H:223
LevelData< FArrayBox > * m_JULevP[2]
Definition: MappedLevelData.H:186
int m_indexJUNew
Definition: MappedLevelData.H:221
MappedLevelData()
Default constructor.
int m_validStatusJU
Definition: MappedLevelData.H:205