Chombo + EB  3.0
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 /**
65  Writes hierarchy of levels in HDF5 format. Only available if the
66  preprocessor macro HDF5 is defined at compilation.
67 
68  This function differs from the previous one in that
69  <i>a_vectData</i>[<i>ind</i>][<i>lev</i>]
70  indexes a LevelData<NodeFArrayBox>* (which may have several components)
71  at level <i>lev</i>.
72 
73  This is blocking.
74 */
75 void
76 WriteAMRHierarchyHDF5(/// file to send output to
77  const string& filename,
78  /// grids at each level
79  const Vector<DisjointBoxLayout>& a_vectGrids,
80  /// data indexed by set and then by level
81  const Vector<Vector<LevelData<NodeFArrayBox>* > >& a_vectData,
82  /// 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.
83  const Vector<string>& a_vectNames,
84  /// domain at coarsest level
85  const Box& a_domain,
86  /// grid spacing at coarsest level
87  const Real& a_dx,
88  /// time step at coarsest level
89  const Real& a_dt,
90  /// time
91  const Real& a_time,
92  /// 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
93  const Vector<int>& a_vectRatio,
94  /// number of levels to write out
95  const int& a_numLevels);
96 
97 ///
98 /**
99  Writes hierarchy of levels in HDF5 format. Only available if the
100  preprocessor macro HDF5 is defined at compilation.
101 
102  This is not blocking.
103 */
104 void
105 WriteAMRHierarchyHDF5(/// handle to send output to
106  HDF5Handle& handle,
107  /// grids at each level
108  const Vector<DisjointBoxLayout>& a_vectGrids,
109  /// data indexed by level
110  const Vector<LevelData<NodeFArrayBox>* > & a_vectData,
111  /// names of variables in <i>a_vectData</i>
112  const Vector<string>& a_vectNames,
113  /// domain at coarsest level
114  const Box& a_domain,
115  /// grid spacing at coarsest level
116  const Real& a_dx,
117  /// time step at coarsest level
118  const Real& a_dt,
119  /// time
120  const Real& a_time,
121  /// 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
122  const Vector<int>& a_vectRatio,
123  /// number of levels to write out
124  const int& a_numLevels,
125  /// physical coordinates of lower corner of cell at IntVect 0
126  const RealVect& a_origin = RealVect::Zero,
127  /// Interval of components to be written
128  const Interval& a_comps = Interval() );
129 
130 ///
131 /**
132  Writes hierarchy of levels in HDF5 format. Only available if the
133  preprocessor macro HDF5 is defined at compilation.
134 
135  This is blocking.
136 */
137 void
138 WriteAMRHierarchyHDF5(/// file to send output to
139  const string& filename,
140  /// grids at each level
141  const Vector<DisjointBoxLayout>& a_vectGrids,
142  /// data indexed by level
143  const Vector<LevelData<NodeFArrayBox>* > & a_vectData,
144  /// domain at coarsest level
145  const Box& a_domain,
146  /// 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
147  const Vector<int>& a_vectRatio,
148  /// number of levels to write out
149  const int& a_numLevels);
150 
151 ///
152 /**
153  Writes hierarchy of levels in HDF5 format. Only available if the
154  preprocessor macro HDF5 is defined at compilation.
155 
156  This is not blocking.
157 */
158 void
159 WriteAMRHierarchyHDF5(/// handle to send output to
160  HDF5Handle& handle,
161  /// grids at each level
162  const Vector<DisjointBoxLayout>& a_vectGrids,
163  /// data indexed by level
164  const Vector<LevelData<NodeFArrayBox>* > & a_vectData,
165  /// domain at coarsest level
166  const Box& a_domain,
167  /// 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
168  const Vector<int>& a_vectRatio,
169  /// number of levels to write out
170  const int& a_numLevels);
171 
172 ///
173 /**
174  Reads hierarchy of levels in HDF5 format. Only available if the
175  preprocessor macro HDF5 is defined at compilation. Returns 0 on success.
176 
177  Returns status code with values:
178  - 0: success
179  - -1: bogus number of levels
180  - -2: bogus number of components
181  - -3: error in readlevel
182  - -4: file open failed
183 
184  This is blocking.
185 */
186 int
187 ReadAMRHierarchyHDF5(/// file to read input from
188  const string& filename,
189  /// grids at each level
190  Vector<DisjointBoxLayout>& a_vectGrids,
191  /// data indexed by level
192  Vector<LevelData<NodeFArrayBox>* > & a_vectData,
193  /// names of variables in <i>a_vectData</i>
194  Vector<string>& a_vectNames,
195  /// domain at coarsest level
196  Box& a_domain,
197  /// grid spacing at coarsest level
198  Real& a_dx,
199  /// time step at coarsest level
200  Real& a_dt,
201  /// time
202  Real& a_time,
203  /// 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
204  Vector<int>& a_refRatio,
205  /// number of levels to read in
206  int& a_numLevels,
207  bool a_setGhost = false);
208 
209 ///
210 /**
211  Reads hierarchy of levels in HDF5 format. Only available if the
212  preprocessor macro HDF5 is defined at compilation. Returns 0 on success.
213 
214  Returns status code with values:
215  - 0: success
216  - -1: bogus number of levels
217  - -2: bogus number of components
218  - -3: error in readlevel
219  - -4: file open failed
220 
221  This is not blocking.
222 */
223 int
224 ReadAMRHierarchyHDF5(/// handle to read input from
225  HDF5Handle& handle,
226  /// grids at each level
227  Vector<DisjointBoxLayout>& a_vectGrids,
228  /// data indexed by level
229  Vector<LevelData<NodeFArrayBox>* > & a_vectData,
230  /// names of variables in <i>a_vectData</i>
231  Vector<string>& a_vectNames,
232  /// domain at coarsest level
233  Box& a_domain,
234  /// grid spacing at coarsest level
235  Real& a_dx,
236  /// time step at coarsest level
237  Real& a_dt,
238  /// time
239  Real& a_time,
240  /// 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
241  Vector<int>& a_refRatio,
242  /// number of levels to read in
243  int& a_numLevels,
244  bool a_setGhost = false);
245 
246 
247 ///
248 /**
249  Reads hierarchy of levels in HDF5 format. Only available if the
250  preprocessor macro HDF5 is defined at compilation. Returns 0 on success.
251 
252  Returns status code with values:
253  - 0: success
254  - -1: bogus number of levels
255  - -2: bogus number of components
256  - -3: error in readlevel
257  - -4: file open failed
258 
259  This is blocking.
260 */
261 int
262 ReadAMRHierarchyHDF5(/// file to read input from
263  const string& filename,
264  /// grids at each level
265  Vector<DisjointBoxLayout>& a_vectGrids,
266  /// data indexed by level
267  Vector<LevelData<NodeFArrayBox>* > & a_vectData,
268  /// domain at coarsest level
269  Box& a_domain,
270  /// 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
271  Vector<int>& a_refRatio,
272  /// number of levels to read in
273  int& a_numLevels,
274  bool a_setGhost = false);
275 
276 ///
277 /**
278  Reads hierarchy of levels in HDF5 format. Only available if the
279  preprocessor macro HDF5 is defined at compilation. Returns 0 on success.
280 
281  Returns status code with values:
282  - 0: success
283  - -1: bogus number of levels
284  - -2: bogus number of components
285  - -3: error in readlevel
286  - -4: file open failed
287 
288  This is not blocking.
289 */
290 int
291 ReadAMRHierarchyHDF5(/// handle to input from
292  HDF5Handle& handle,
293  /// grids at each level
294  Vector<DisjointBoxLayout>& a_vectGrids,
295  /// data indexed by level
296  Vector<LevelData<NodeFArrayBox>* > & a_vectData,
297  /// domain at coarsest level
298  Box& a_domain,
299  /// 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
300  Vector<int>& a_refRatio,
301  /// number of levels to read in
302  int& a_numLevels,
303  bool a_setGhost = false);
304 
305 
306 ///
307 /**
308  Writes a plotfile using the same format as WriteAMRHierarchyHDF5, but
309  for a NodeFArrayBox. This is useful for debugging.
310  *<i>a_dataPtr</i> is written to a file named nfab.hdf5
311 */
312 void
313 writeNFAB(const NodeFArrayBox* a_dataPtr);
314 
315 ///
316 /**
317  View *<i>a_dataPtr</i> by writing it to an HDF5 plotfile (to a
318  temporary file) and then running ChomboVis with a python script
319  which brings up a data browser by default. The file has the same
320  format as WriteAMRHierarchyHDF5, but for a single NodeFArrayBox.
321  This is useful for debugging.
322 */
323 void
324 viewNFAB(const NodeFArrayBox* a_dataPtr);
325 
326 ///
327 /**
328  Writes a plotfile using the same format as WriteAMRHierarchyHDF5, but
329  for a NodeFArrayBox. This is useful for debugging.
330  *<i>a_dataPtr</i> is written to the file given by a_filename.
331 */
332 void
333 writeNFABname(const NodeFArrayBox* a_dataPtr,
334  const char* a_filename);
335 
336 ///
337 /**
338  Write a plotfile using the same format as WriteAMRHierarchyHDF5, but
339  for a single LevelData<NodeFArrayBox>. Useful for debugging.
340  *<i>a_dataPtr</i> is written to a file named LDF.hdf5.
341 */
342 void
343 writeNodeLevel(const LevelData<NodeFArrayBox>* a_dataPtr);
344 
345 ///
346 /**
347  View *<i>a_dataPtr</i> by writing it to an HDF5 plotfile (to a
348  temporary file) and then running ChomboVis with a python script
349  which brings up a data browser by default. The file has the same
350  format as WriteAMRHierarchyHDF5, but for a single
351  LevelData<NodeFArrayBox>. This is useful for debugging.
352 */
353 void
354 viewNodeLevel(const LevelData<NodeFArrayBox>* a_dataPtr);
355 
356 ///
357 /**
358  Write a plotfile using the same format as WriteAMRHierarchyHDF5, but
359  for a single LevelData<FArrayBox>. Useful for debugging.
360  *<i>a_dataPtr</i> is written to the file given by <i>a_filename</i>.
361 */
362 void
364  const char* a_filename);
365 
366 ///
367 /**
368  Write a plotfile with levels that don't necessarily begin with
369  0 (will translate things so that base level comes out as level 0, etc.).
370  Levels in Vector arguments should correspond with actual levels,
371  and so should be defined for <i>a_levels</i>.begin() through
372  <i>a_levels</i>.end().
373 
374  This is blocking.
375 */
376 void
377 WritePartialAMRHierarchyHDF5(/// file to send output to
378  const string& filename,
379  /// grids at each level
380  const Vector<DisjointBoxLayout>& a_vectGrids,
381  /// data indexed by level
382  const Vector<LevelData<FArrayBox>* > & a_vectData,
383  /// names of variables in <i>a_vectData</i>
384  const Vector<string>& a_vectNames,
385  /// domain at base level given by <i>a_levels</i>.begin()
386  const Box& a_baseDomain,
387  /// grid spacing at base level
388  const Real& a_baseDx,
389  /// time step at base level
390  const Real& a_dt,
391  /// time
392  const Real& a_time,
393  /// 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
394  const Vector<int>& a_vectRatio,
395  /// indices of levels to write out
396  const Interval& a_levels);
397 
398 ///
399 /**
400  Write a plotfile with levels that don't necessarily begin with
401  0 (will translate things so that base level comes out as level 0, etc.).
402  Levels in Vector arguments should correspond with actual levels,
403  and so should be defined for <i>a_levels</i>.begin() through
404  <i>a_levels</i>.end().
405 
406  This function differs from the previous one in that
407  <i>a_vectData</i>[<i>ind</i>][<i>lev</i>]
408  indexes a LevelData<NodeFArrayBox>* (which may have several components)
409  at level <i>lev</i>.
410 
411  This is blocking.
412 */
413 void
414 WritePartialAMRHierarchyHDF5(/// file to send output to
415  const string& filename,
416  /// grids at each level
417  const Vector<DisjointBoxLayout>& a_vectGrids,
418  /// data indexed by set and then by level
419  const Vector<Vector<LevelData<NodeFArrayBox>* > >& a_vectData,
420  /// names of variables in <i>a_vectData</i>
421  const Vector<string>& a_vectNames,
422  /// domain at base level given by <i>a_levels</i>.begin()
423  const Box& a_baseDomain,
424  /// grid spacing at base level
425  const Real& a_baseDx,
426  /// time step at base level
427  const Real& a_dt,
428  /// time
429  const Real& a_time,
430  /// 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
431  const Vector<int>& a_vectRatio,
432  /// indices of levels to write out
433  const Interval& a_levels);
434 
435 #include "NamespaceFooter.H"
436 #endif // include guard
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:416
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:465
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:267
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:87