Chombo + EB + MF  3.2
BlockWrite.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 _BLOCKWRITE_H_
12 #define _BLOCKWRITE_H_
13 
14 #ifdef CH_USE_HDF5 // if you don't have CH_USE_HDF5, then this file is useless
15 
16 #include "CH_HDF5.H"
17 
18 #include <iostream>
19 
20 using std::endl;
21 
22 #ifdef CH_MPI
23 #include "mpi.h"
24 #endif
25 
26 #include "LevelData.H"
27 #include "HDF5Portable.H"
28 #include <string>
29 #include <map>
30 #include "RealVect.H"
31 #include "CH_Timer.H"
32 #include "LoadBalance.H"
33 #include "LayoutIterator.H"
34 #include "Vector.H"
35 #include "memtrack.H"
36 #include "FluxBox.H"
37 #include "CH_HDF5.H"
38 
39 #include "NamespaceHeader.H"
40 
41 ///
42 template <class T> int
43 blockReadLevel(HDF5Handle& a_handle,
44  const int& a_level,
45  LevelData<T>& a_data,
46  Real& a_dx,
47  Real& a_dt,
48  Real& a_time,
49  Box& a_domain,
50  int& a_refRatio,
51  const Interval& a_comps,
52  bool setGhost);
53 
54 ///
55 template <class T> int
56 blockWriteLevel(HDF5Handle& a_handle,
57  const int& a_level,
58  const LevelData<T>& a_data,
59  const Real& a_dx,
60  const Real& a_dt,
61  const Real& a_time,
62  const Box& a_domain,
63  const int& a_refRatio,
64  const IntVect& outputGhost,
65  const Interval& comps);
66 
67 ///
68 template <class T> int
69 blockWrite(HDF5Handle& a_handle,
70  const BoxLayoutData<T>& a_data,
71  const std::string& a_name,
72  const IntVect& a_outputGhost,
73  const Interval& a_comps);
74 
75 ///
76 template <class T>
77 int
78 blockWrite(HDF5Handle& a_handle,
79  const LevelData<T>& a_data,
80  const std::string& a_name,
81  const IntVect& a_outputGhost,
82  const Interval& a_in_comps);
83 
84 ///
85 template <class T> void
86 blockLocalOffsets(Vector<long long>& a_localOffsets,
87  long long & a_localTotalSize,
88  Vector<Box> & a_localBoxes,
89  const BoxLayoutData<T>& a_data,
90  const Interval& a_comps,
91  const IntVect& a_outputGhost);
92 
93 ///
94 template <class T> void
95 blockWriteToBuffer(void* a_buffer,
96  const BoxLayoutData<T>& a_data,
97  const Interval& a_comps,
98  const IntVect& a_outputGhost);
99 
100 ///
101 int
102 gatherBoxesAndOffsets(long long& a_offsetThisProc,
103  long long& a_allProcSize,
104  Vector<long long>& a_globalOffsets,
105  Vector<Box>& a_globalBoxes,
106  const Vector<long long>& a_localOffsets,
107  const Vector<Box>& a_localBoxes,
108  const long long& a_localSize);
109 
110 ///
111 int
113  void* a_buffer,
114  const std::string& a_name,
115  Vector<Box>& a_boxes,
116  Vector<long long>& a_offsets,
117  const Vector<hid_t>& a_types,
118  const BoxLayout& a_layout,
119  const long long& a_thisprocsize);
120 
121 /// read BoxLayoutData named a_name from location specified by a_handle.
122 /**
123  Read BoxLayoutData named a_name from location specified by a_handle. User must supply the correct BoxLayout for this function if redefineData == true. \\
124  returns: success: 0\\
125  bad location: 1\\
126  HDF5 error: negative error code.\\
127 */
128 template <class T>
129 int blockRead(HDF5Handle& a_handle,
130  BoxLayoutData<T>& a_data,
131  const std::string& a_name,
132  const BoxLayout& a_layout,
133  const Interval& a_comps = Interval(),
134  bool redefineData = true);
135 
136 /// read LevelData named a_name from location specified by a_handle.
137 /**
138 
139  Read LevelData named a_name from location specified by a_handle.
140  User must supply the correct BoxLayout for this function.
141 
142  Arg a_name is significant: the HDF5 group to which a_handle is set is
143  is assumed to contain a dataset called <a_name>:datatype=<some integer>,
144  a dataset called <a_name>:offsets=<some integer>, and a subgroup named
145  <a_name>_attributes. You will have all these items if you dumped your
146  LevelData out using the corresponding write() function defined here.
147 
148  If arg redefineData==false, then the user must pass in a valid LevelData.
149  Otherwise, this function figures out how many components and ghost cells there
150  are, and allocates the correct amount of space. The actual FArray data held
151  by the LevelData gets filled in here, regardless of redefineData; "redefine"
152  alludes to the family of define() functions.
153 
154  returns: success: 0\\
155  bad location: 1\\
156  HDF5 error: negative error code.\\
157 */
158 template <class T>
159 int blockRead(HDF5Handle& a_handle,
160  LevelData<T>& a_data,
161  const std::string& a_name,
162  const DisjointBoxLayout& a_layout,
163  const Interval& a_comps = Interval(),
164  bool redefineData = true);
165 
166 //implementation
167 #include "BlockWriteI.H"
168 
169 #endif //ifdef CH_USE_HDF5
170 #endif //ifndef __BlockWrite__
int gatherBoxesAndOffsets(long long &a_offsetThisProc, long long &a_allProcSize, Vector< long long > &a_globalOffsets, Vector< Box > &a_globalBoxes, const Vector< long long > &a_localOffsets, const Vector< Box > &a_localBoxes, const long long &a_localSize)
Definition: BlockWriteI.H:94
A not-necessarily-disjoint collective of boxes.
Definition: BoxLayout.H:145
int blockWriteLevel(HDF5Handle &a_handle, const int &a_level, const LevelData< T > &a_data, const Real &a_dx, const Real &a_dt, const Real &a_time, const Box &a_domain, const int &a_refRatio, const IntVect &outputGhost, const Interval &comps)
Definition: BlockWriteI.H:335
int blockWrite(HDF5Handle &a_handle, const BoxLayoutData< T > &a_data, const std::string &a_name, const IntVect &a_outputGhost, const Interval &a_comps)
Definition: BlockWriteI.H:264
void blockWriteToBuffer(void *a_buffer, const BoxLayoutData< T > &a_data, const Interval &a_comps, const IntVect &a_outputGhost)
int blockWriteBufferToFile(HDF5Handle &a_handle, void *a_buffer, const std::string &a_name, Vector< Box > &a_boxes, Vector< long long > &a_offsets, const Vector< hid_t > &a_types, const BoxLayout &a_layout, const long long &a_thisprocsize)
Definition: BlockWriteI.H:158
Structure for passing component ranges in code.
Definition: Interval.H:23
new code
Definition: BoxLayoutData.H:170
Data on a BoxLayout.
Definition: BoxLayoutData.H:97
double Real
Definition: REAL.H:33
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
void blockLocalOffsets(Vector< long long > &a_localOffsets, long long &a_localTotalSize, Vector< Box > &a_localBoxes, const BoxLayoutData< T > &a_data, const Interval &a_comps, const IntVect &a_outputGhost)
Definition: BlockWriteI.H:30
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
Handle to a particular group in an HDF file.
Definition: CH_HDF5.H:294
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
int blockReadLevel(HDF5Handle &a_handle, const int &a_level, LevelData< T > &a_data, Real &a_dx, Real &a_dt, Real &a_time, Box &a_domain, int &a_refRatio, const Interval &a_comps, bool setGhost)
Definition: BlockWriteI.H:375
int blockRead(HDF5Handle &a_handle, BoxLayoutData< T > &a_data, const std::string &a_name, const BoxLayout &a_layout, const Interval &a_comps=Interval(), bool redefineData=true)
read BoxLayoutData named a_name from location specified by a_handle.
Definition: BlockWriteI.H:464