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