Chombo + EB + MF  3.2
NodeAMRIO.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 // NodeAMRIO.H
12 // petermc, 4 March 2003
13 // adapted from AMRIO by DTGraves, Fri, Dec 3, 1999
14 
15 #ifndef _NODEAMRIO_H_
16 #define _NODEAMRIO_H_
17 #include "REAL.H"
18 
19 #include "LevelData.H"
20 #include "RealVect.H"
21 #include "Vector.H"
22 #include "NodeFArrayBox.H"
23 #include <string>
24 
25 #include "IntVect.H"
26 #include "NamespaceHeader.H"
27 using std::string;
28 using std::istream;
29 
30 ///
31 /**
32  Writes hierarchy of levels in HDF5 format. Only available if the
33  preprocessor macro HDF5 is defined at compilation.
34 
35  This is blocking.
36 */
37 void
38 WriteAMRHierarchyHDF5(/// file to send output to
39  const string& filename,
40  /// grids at each level
41  const Vector<DisjointBoxLayout>& a_vectGrids,
42  /// data indexed by level
43  const Vector<LevelData<NodeFArrayBox>* > & a_vectData,
44  /// names of variables in <i>a_vectData</i>
45  const Vector<string>& a_vectNames,
46  /// domain at coarsest level
47  const Box& a_domain,
48  /// grid spacing at coarsest level
49  const Real& a_dx,
50  /// time step at coarsest level
51  const Real& a_dt,
52  /// time
53  const Real& a_time,
54  /// refinement ratios between adjacent levels, starting with <i>a_refRatio</i>[0], the refinement ratio between levels 0 and 1; Vector length at least <i>a_numLevels</i>-1
55  const Vector<int>& a_vectRatio,
56  /// number of levels to write out
57  const int& a_numLevels,
58  /// physical coordinates of lower corner of cell at IntVect 0
59  const RealVect& a_origin = RealVect::Zero,
60  /// Interval of components to be written
61  const Interval& a_comps = Interval() );
62 
63 /**
64  Writes hierarchy of levels in HDF5 format. Only available if the
65  preprocessor macro HDF5 is defined at compilation.
66 
67  This is blocking.
68 */
69 void
70 WriteAnisotropicAMRHierarchyHDF5(/// file to send output to
71  const string& filename,
72  /// grids at each level
73  const Vector<DisjointBoxLayout>& a_vectGrids,
74  /// data indexed by level
75  const Vector<LevelData<NodeFArrayBox>* > & a_vectData,
76  /// names of variables in <i>a_vectData</i>
77  const Vector<string>& a_vectNames,
78  /// domain at coarsest level
79  const Box& a_domain,
80  /// grid spacing in each direction at coarsest level
81  const RealVect& a_dx,
82  /// time step at coarsest level
83  const Real& a_dt,
84  /// time
85  const Real& a_time,
86  /// refinement ratios in each direction between adjacent levels, starting with <i>a_refRatio</i>[0], the refinement ratio between levels 0 and 1; Vector length at least <i>a_numLevels</i>-1
87  const Vector<IntVect>& a_vectRatios,
88  /// number of levels to write out
89  const int& a_numLevels,
90  /// physical coordinates of lower corner of cell at IntVect 0
91  const RealVect& a_origin = RealVect::Zero,
92  /// Interval of components to be written
93  const Interval& a_comps = Interval() );
94 ///
95 /**
96  Writes hierarchy of levels in HDF5 format. Only available if the
97  preprocessor macro HDF5 is defined at compilation.
98 
99  This function differs from the previous one in that
100  <i>a_vectData</i>[<i>ind</i>][<i>lev</i>]
101  indexes a LevelData<NodeFArrayBox>* (which may have several components)
102  at level <i>lev</i>.
103 
104  This is blocking.
105 */
106 void
107 WriteAMRHierarchyHDF5(/// file to send output to
108  const string& filename,
109  /// grids at each level
110  const Vector<DisjointBoxLayout>& a_vectGrids,
111  /// data indexed by set and then by level
112  const Vector<Vector<LevelData<NodeFArrayBox>* > >& a_vectData,
113  /// names of variables in <i>a_vectData</i>: first the names of the components of <i>a_vectData</i>[0], then the names of the components of <i>a_vectData[1]</i>, etc.
114  const Vector<string>& a_vectNames,
115  /// domain at coarsest level
116  const Box& a_domain,
117  /// grid spacing at coarsest level
118  const Real& a_dx,
119  /// time step at coarsest level
120  const Real& a_dt,
121  /// time
122  const Real& a_time,
123  /// refinement ratios between adjacent levels, starting with <i>a_refRatio</i>[0], the refinement ratio between levels 0 and 1; Vector length at least <i>a_numLevels</i>-1
124  const Vector<int>& a_vectRatio,
125  /// number of levels to write out
126  const int& a_numLevels);
127 
128 ///
129 /**
130  Writes hierarchy of levels in HDF5 format. Only available if the
131  preprocessor macro HDF5 is defined at compilation.
132 
133  This is not blocking.
134 */
135 void
136 WriteAMRHierarchyHDF5(/// handle to send output to
137  HDF5Handle& handle,
138  /// grids at each level
139  const Vector<DisjointBoxLayout>& a_vectGrids,
140  /// data indexed by level
141  const Vector<LevelData<NodeFArrayBox>* > & a_vectData,
142  /// names of variables in <i>a_vectData</i>
143  const Vector<string>& a_vectNames,
144  /// domain at coarsest level
145  const Box& a_domain,
146  /// grid spacing at coarsest level
147  const Real& a_dx,
148  /// time step at coarsest level
149  const Real& a_dt,
150  /// time
151  const Real& a_time,
152  /// refinement ratios between adjacent levels, starting with <i>a_refRatio</i>[0], the refinement ratio between levels 0 and 1; Vector length at least <i>a_numLevels</i>-1
153  const Vector<int>& a_vectRatio,
154  /// number of levels to write out
155  const int& a_numLevels,
156  /// physical coordinates of lower corner of cell at IntVect 0
157  const RealVect& a_origin = RealVect::Zero,
158  /// Interval of components to be written
159  const Interval& a_comps = Interval() );
160 
161 ///
162 /**
163  Writes hierarchy of levels in HDF5 format. Only available if the
164  preprocessor macro HDF5 is defined at compilation.
165 
166  This is not blocking.
167 */
168 void
169 WriteAnisotropicAMRHierarchyHDF5(/// handle to send output to
170  HDF5Handle& handle,
171  /// grids at each level
172  const Vector<DisjointBoxLayout>& a_vectGrids,
173  /// data indexed by level
174  const Vector<LevelData<NodeFArrayBox>* > & a_vectData,
175  /// names of variables in <i>a_vectData</i>
176  const Vector<string>& a_vectNames,
177  /// domain at coarsest level
178  const Box& a_domain,
179  /// grid spacing at coarsest level
180  const RealVect& a_dx,
181  /// time step at coarsest level
182  const Real& a_dt,
183  /// time
184  const Real& a_time,
185  /// refinement ratios between adjacent levels, starting with <i>a_refRatio</i>[0], the refinement ratio between levels 0 and 1; Vector length at least <i>a_numLevels</i>-1
186  const Vector<IntVect>& a_vectRatios,
187  /// number of levels to write out
188  const int& a_numLevels,
189  /// physical coordinates of lower corner of cell at IntVect 0
190  const RealVect& a_origin = RealVect::Zero,
191  /// Interval of components to be written
192  const Interval& a_comps = Interval() );
193 
194 ///
195 /**
196  Writes hierarchy of levels in HDF5 format. Only available if the
197  preprocessor macro HDF5 is defined at compilation.
198 
199  This is blocking.
200 */
201 void
202 WriteAMRHierarchyHDF5(/// file to send output to
203  const string& filename,
204  /// grids at each level
205  const Vector<DisjointBoxLayout>& a_vectGrids,
206  /// data indexed by level
207  const Vector<LevelData<NodeFArrayBox>* > & a_vectData,
208  /// domain at coarsest level
209  const Box& a_domain,
210  /// refinement ratios between adjacent levels, starting with <i>a_refRatio</i>[0], the refinement ratio between levels 0 and 1; Vector length at least <i>a_numLevels</i>-1
211  const Vector<int>& a_vectRatio,
212  /// number of levels to write out
213  const int& a_numLevels);
214 
215 ///
216 /**
217  Writes hierarchy of levels in HDF5 format. Only available if the
218  preprocessor macro HDF5 is defined at compilation.
219 
220  This is not blocking.
221 */
222 void
223 WriteAMRHierarchyHDF5(/// handle to send output to
224  HDF5Handle& handle,
225  /// grids at each level
226  const Vector<DisjointBoxLayout>& a_vectGrids,
227  /// data indexed by level
228  const Vector<LevelData<NodeFArrayBox>* > & a_vectData,
229  /// domain at coarsest level
230  const Box& a_domain,
231  /// refinement ratios between adjacent levels, starting with <i>a_refRatio</i>[0], the refinement ratio between levels 0 and 1; Vector length at least <i>a_numLevels</i>-1
232  const Vector<int>& a_vectRatio,
233  /// number of levels to write out
234  const int& a_numLevels);
235 
236 ///
237 /**
238  Reads hierarchy of levels in HDF5 format. Only available if the
239  preprocessor macro HDF5 is defined at compilation. Returns 0 on success.
240 
241  Returns status code with values:
242  - 0: success
243  - -1: bogus number of levels
244  - -2: bogus number of components
245  - -3: error in readlevel
246  - -4: file open failed
247 
248  This is blocking.
249 */
250 int
251 ReadAMRHierarchyHDF5(/// file to read input from
252  const string& filename,
253  /// grids at each level
254  Vector<DisjointBoxLayout>& a_vectGrids,
255  /// data indexed by level
256  Vector<LevelData<NodeFArrayBox>* > & a_vectData,
257  /// names of variables in <i>a_vectData</i>
258  Vector<string>& a_vectNames,
259  /// domain at coarsest level
260  Box& a_domain,
261  /// grid spacing at coarsest level
262  Real& a_dx,
263  /// time step at coarsest level
264  Real& a_dt,
265  /// time
266  Real& a_time,
267  /// refinement ratios between adjacent levels, starting with <i>a_refRatio</i>[0], the refinement ratio between levels 0 and 1; Vector length at least <i>a_numLevels</i>-1
268  Vector<int>& a_refRatio,
269  /// number of levels to read in
270  int& a_numLevels,
271  bool a_setGhost = false);
272 
273 ///
274 /**
275  Reads hierarchy of levels in HDF5 format. Only available if the
276  preprocessor macro HDF5 is defined at compilation. Returns 0 on success.
277 
278  Returns status code with values:
279  - 0: success
280  - -1: bogus number of levels
281  - -2: bogus number of components
282  - -3: error in readlevel
283  - -4: file open failed
284 
285  This is not blocking.
286 */
287 int
288 ReadAMRHierarchyHDF5(/// handle to read input from
289  HDF5Handle& handle,
290  /// grids at each level
291  Vector<DisjointBoxLayout>& a_vectGrids,
292  /// data indexed by level
293  Vector<LevelData<NodeFArrayBox>* > & a_vectData,
294  /// names of variables in <i>a_vectData</i>
295  Vector<string>& a_vectNames,
296  /// domain at coarsest level
297  Box& a_domain,
298  /// grid spacing at coarsest level
299  Real& a_dx,
300  /// time step at coarsest level
301  Real& a_dt,
302  /// time
303  Real& a_time,
304  /// refinement ratios between adjacent levels, starting with <i>a_refRatio</i>[0], the refinement ratio between levels 0 and 1; Vector length at least <i>a_numLevels</i>-1
305  Vector<int>& a_refRatio,
306  /// number of levels to read in
307  int& a_numLevels,
308  bool a_setGhost = false);
309 
310 ///
311 /**
312  Reads hierarchy of levels in HDF5 format. Only available if the
313  preprocessor macro HDF5 is defined at compilation. Returns 0 on success.
314 
315  Returns status code with values:
316  - 0: success
317  - -1: bogus number of levels
318  - -2: bogus number of components
319  - -3: error in readlevel
320  - -4: file open failed
321 
322  This is blocking.
323 */
324 int
325 ReadAMRHierarchyHDF5(/// file to read input from
326  const string& filename,
327  /// grids at each level
328  Vector<DisjointBoxLayout>& a_vectGrids,
329  /// data indexed by level
330  Vector<LevelData<NodeFArrayBox>* > & a_vectData,
331  /// domain at coarsest level
332  Box& a_domain,
333  /// refinement ratios between adjacent levels, starting with <i>a_refRatio</i>[0], the refinement ratio between levels 0 and 1; Vector length at least <i>a_numLevels</i>-1
334  Vector<int>& a_refRatio,
335  /// number of levels to read in
336  int& a_numLevels,
337  bool a_setGhost = false);
338 
339 ///
340 /**
341  Reads hierarchy of levels in HDF5 format. Only available if the
342  preprocessor macro HDF5 is defined at compilation. Returns 0 on success.
343 
344  Returns status code with values:
345  - 0: success
346  - -1: bogus number of levels
347  - -2: bogus number of components
348  - -3: error in readlevel
349  - -4: file open failed
350 
351  This is not blocking.
352 */
353 int
354 ReadAMRHierarchyHDF5(/// handle to input from
355  HDF5Handle& handle,
356  /// grids at each level
357  Vector<DisjointBoxLayout>& a_vectGrids,
358  /// data indexed by level
359  Vector<LevelData<NodeFArrayBox>* > & a_vectData,
360  /// domain at coarsest level
361  Box& a_domain,
362  /// refinement ratios between adjacent levels, starting with <i>a_refRatio</i>[0], the refinement ratio between levels 0 and 1; Vector length at least <i>a_numLevels</i>-1
363  Vector<int>& a_refRatio,
364  /// number of levels to read in
365  int& a_numLevels,
366  bool a_setGhost = false);
367 
368 ///
369 /**
370  Writes a plotfile using the same format as WriteAMRHierarchyHDF5, but
371  for a NodeFArrayBox. This is useful for debugging.
372  *<i>a_dataPtr</i> is written to a file named nfab.hdf5
373 */
374 void
375 writeNFAB(const NodeFArrayBox* a_dataPtr);
376 
377 ///
378 /**
379  View *<i>a_dataPtr</i> by writing it to an HDF5 plotfile (to a
380  temporary file) and then running ChomboVis with a python script
381  which brings up a data browser by default. The file has the same
382  format as WriteAMRHierarchyHDF5, but for a single NodeFArrayBox.
383  This is useful for debugging.
384 */
385 void
386 viewNFAB(const NodeFArrayBox* a_dataPtr);
387 
388 ///
389 /**
390  Writes a plotfile using the same format as WriteAMRHierarchyHDF5, but
391  for a NodeFArrayBox. This is useful for debugging.
392  *<i>a_dataPtr</i> is written to the file given by a_filename.
393 */
394 void
395 writeNFABname(const NodeFArrayBox* a_dataPtr,
396  const char* a_filename);
397 
398 ///
399 /**
400  Write a plotfile using the same format as WriteAMRHierarchyHDF5, but
401  for a single LevelData<NodeFArrayBox>. Useful for debugging.
402  *<i>a_dataPtr</i> is written to a file named LDF.hdf5.
403 */
404 void
405 writeNodeLevel(const LevelData<NodeFArrayBox>* a_dataPtr);
406 
407 ///
408 /**
409  View *<i>a_dataPtr</i> by writing it to an HDF5 plotfile (to a
410  temporary file) and then running ChomboVis with a python script
411  which brings up a data browser by default. The file has the same
412  format as WriteAMRHierarchyHDF5, but for a single
413  LevelData<NodeFArrayBox>. This is useful for debugging.
414 */
415 void
416 viewNodeLevel(const LevelData<NodeFArrayBox>* a_dataPtr);
417 
418 ///
419 /**
420  Write a plotfile using the same format as WriteAMRHierarchyHDF5, but
421  for a single LevelData<FArrayBox>. Useful for debugging.
422  *<i>a_dataPtr</i> is written to the file given by <i>a_filename</i>.
423 */
424 void
426  const char* a_filename);
427 
428 ///
429 /**
430  Write a plotfile with levels that don't necessarily begin with
431  0 (will translate things so that base level comes out as level 0, etc.).
432  Levels in Vector arguments should correspond with actual levels,
433  and so should be defined for <i>a_levels</i>.begin() through
434  <i>a_levels</i>.end().
435 
436  This is blocking.
437 */
438 void
439 WritePartialAMRHierarchyHDF5(/// file to send output to
440  const string& filename,
441  /// grids at each level
442  const Vector<DisjointBoxLayout>& a_vectGrids,
443  /// data indexed by level
444  const Vector<LevelData<FArrayBox>* > & a_vectData,
445  /// names of variables in <i>a_vectData</i>
446  const Vector<string>& a_vectNames,
447  /// domain at base level given by <i>a_levels</i>.begin()
448  const Box& a_baseDomain,
449  /// grid spacing at base level
450  const Real& a_baseDx,
451  /// time step at base level
452  const Real& a_dt,
453  /// time
454  const Real& a_time,
455  /// refinement ratios between adjacent levels, starting with <i>a_refRatio</i>[0], the refinement ratio between levels 0 and 1; Vector length at least <i>a_numLevels</i>-1
456  const Vector<int>& a_vectRatio,
457  /// indices of levels to write out
458  const Interval& a_levels);
459 
460 ///
461 /**
462  Write a plotfile with levels that don't necessarily begin with
463  0 (will translate things so that base level comes out as level 0, etc.).
464  Levels in Vector arguments should correspond with actual levels,
465  and so should be defined for <i>a_levels</i>.begin() through
466  <i>a_levels</i>.end().
467 
468  This function differs from the previous one in that
469  <i>a_vectData</i>[<i>ind</i>][<i>lev</i>]
470  indexes a LevelData<NodeFArrayBox>* (which may have several components)
471  at level <i>lev</i>.
472 
473  This is blocking.
474 */
475 void
476 WritePartialAMRHierarchyHDF5(/// file to send output to
477  const string& filename,
478  /// grids at each level
479  const Vector<DisjointBoxLayout>& a_vectGrids,
480  /// data indexed by set and then by level
481  const Vector<Vector<LevelData<NodeFArrayBox>* > >& a_vectData,
482  /// names of variables in <i>a_vectData</i>
483  const Vector<string>& a_vectNames,
484  /// domain at base level given by <i>a_levels</i>.begin()
485  const Box& a_baseDomain,
486  /// grid spacing at base level
487  const Real& a_baseDx,
488  /// time step at base level
489  const Real& a_dt,
490  /// time
491  const Real& a_time,
492  /// refinement ratios between adjacent levels, starting with <i>a_refRatio</i>[0], the refinement ratio between levels 0 and 1; Vector length at least <i>a_numLevels</i>-1
493  const Vector<int>& a_vectRatio,
494  /// indices of levels to write out
495  const Interval& a_levels);
496 
497 #include "NamespaceFooter.H"
498 #endif // include guard
void WriteAnisotropicAMRHierarchyHDF5(const string &filename, const Vector< DisjointBoxLayout > &a_vectGrids, const Vector< LevelData< NodeFArrayBox > * > &a_vectData, const Vector< string > &a_vectNames, const Box &a_domain, const RealVect &a_dx, const Real &a_dt, const Real &a_time, const Vector< IntVect > &a_vectRatios, const int &a_numLevels, const RealVect &a_origin=RealVect::Zero, const Interval &a_comps=Interval())
void writeNodeLevel(const LevelData< NodeFArrayBox > *a_dataPtr)
void WriteAMRHierarchyHDF5(const string &filename, const Vector< DisjointBoxLayout > &a_vectGrids, const Vector< LevelData< NodeFArrayBox > * > &a_vectData, const Vector< string > &a_vectNames, const Box &a_domain, const Real &a_dx, const Real &a_dt, const Real &a_time, const Vector< int > &a_vectRatio, const int &a_numLevels, const RealVect &a_origin=RealVect::Zero, const Interval &a_comps=Interval())
int ReadAMRHierarchyHDF5(const string &filename, Vector< DisjointBoxLayout > &a_vectGrids, Vector< LevelData< NodeFArrayBox > * > &a_vectData, Vector< string > &a_vectNames, Box &a_domain, Real &a_dx, Real &a_dt, Real &a_time, Vector< int > &a_refRatio, int &a_numLevels, bool a_setGhost=false)
static const RealVect Zero
Definition: RealVect.H:421
Structure for passing component ranges in code.
Definition: Interval.H:23
double Real
Definition: REAL.H:33
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
void WritePartialAMRHierarchyHDF5(const string &filename, const Vector< DisjointBoxLayout > &a_vectGrids, const Vector< LevelData< FArrayBox > * > &a_vectData, const Vector< string > &a_vectNames, const Box &a_baseDomain, const Real &a_baseDx, const Real &a_dt, const Real &a_time, const Vector< int > &a_vectRatio, const Interval &a_levels)
Handle to a particular group in an HDF file.
Definition: CH_HDF5.H:294
void writeNFAB(const NodeFArrayBox *a_dataPtr)
void viewNodeLevel(const LevelData< NodeFArrayBox > *a_dataPtr)
void writeNFABname(const NodeFArrayBox *a_dataPtr, const char *a_filename)
void viewNFAB(const NodeFArrayBox *a_dataPtr)
void writeNodeLevelname(const LevelData< NodeFArrayBox > *a_dataPtr, const char *a_filename)
A wrapper for an FArrayBox to contain NODE-centered data.
Definition: NodeFArrayBox.H:122