Chombo + EB + MF  3.2
ParticleIO.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 // functions for I/O of particle data
12 
13 #ifndef _PARTICLEIO_H_
14 #define _PARTICLEIO_H_
15 
16 #include <list>
17 using std::list;
18 
19 #include "REAL.H"
20 #include "Vector.H"
21 #include "LayoutIterator.H"
22 #include "CH_HDF5.H"
23 #include "SPMD.H"
24 #include "ListBox.H"
25 #include "ParticleData.H"
26 
27 #include "NamespaceHeader.H"
28 
29 #ifdef CH_USE_HDF5
30 
31 /// Write chunk of data and upgrade offset. Not meant to be a user-facing function.
32 void writeDataChunk(size_t& offset,
33  const hid_t& dataspace,
34  const hid_t& dataset,
35  const hid_t& H5T_type,
36  const unsigned long dataLength,
37  const void* const data);
38 
39 /// Read chunk of data and upgrade offset. Not meant to be a user-facing function.
40 void readDataChunk(size_t& offset,
41  const hid_t& dataspace,
42  const hid_t& dataset,
43  const hid_t& H5T_type,
44  const unsigned long dataLength,
45  void* const data,
46  const size_t stride=1,
47  const size_t block=1);
48 
49 /// Write the particle header to the HDF5 file. Not meant to be a user-facing function.
50 void write_hdf_part_header(HDF5Handle& a_handle,
51  const BoxLayout& a_grids,
52  const vector<unsigned long long>& a_partPerBox,
53  const std::string& a_dataType);
54 
55 /// Read the particle header from the HDF5 file. Not meant to be a user-facing function.
56 void read_hdf_part_header(HDF5Handle& a_handle,
57  Vector<Box>& a_grids,
58  vector<unsigned long long>& a_particlesPerBox,
59  const std::string& a_dataType,
60  const std::string& a_path);
61 
62 /// A helper function that writes a vector of 'T's to the HDF5 file under a_dataname
63 template <class T>
64 void write_vect_to_header(HDF5Handle& a_handle,
65  const vector<T>& a_vect,
66  const hid_t& H5T_type,
67  const std::string& a_dataname);
68 
69 /// A helper function that reads a vector of 'T's to the HDF5 file under a_dataname
70 template <class T>
71 void read_vect_from_header(HDF5Handle& a_handle,
72  vector<T>& a_vect,
73  const hid_t& H5T_type,
74  const std::string& a_dataname);
75 
76 /// Write the particle data contained in a_particles to the HDF5 file described by a_handle.
77 /// This is the function that users should actually call. The string a_dataType gives a way
78 /// to label the particles, in case multiple particle types are present.
79 template<class P> void
81  const ParticleData<P>& a_particles,
82  const std::string& a_dataType);
83 
84 /// Read the particle data contained in the HDF5 file described by a_handle into a_particles.
85 /// This is the function that users should actually call. The string a_dataType gives a way
86 /// to label the particles, in case multiple particle types are present.
87 template<class P>
88 void readParticlesFromHDF(HDF5Handle& a_handle,
89  ParticleData<P>& a_particles,
90  const std::string& a_dataType);
91 
92 /// Like the above, but takes a Vector<P> instead of a ParticleData.
93 template<class P> void
95  const ParticleData<P>& a_particles,
96  const Box& a_domain,
97  const std::string& a_dataType);
98 
99 #endif // HDF5
100 
101 #include "NamespaceFooter.H"
102 
103 // implementation
104 #include "ParticleIOI.H"
105 
106 #endif
void write_vect_to_header(HDF5Handle &a_handle, const vector< T > &a_vect, const hid_t &H5T_type, const std::string &a_dataname)
A helper function that writes a vector of &#39;T&#39;s to the HDF5 file under a_dataname. ...
Definition: ParticleIOI.H:26
void writeDataChunk(size_t &offset, const hid_t &dataspace, const hid_t &dataset, const hid_t &H5T_type, const unsigned long dataLength, const void *const data)
Write chunk of data and upgrade offset. Not meant to be a user-facing function.
void read_vect_from_header(HDF5Handle &a_handle, vector< T > &a_vect, const hid_t &H5T_type, const std::string &a_dataname)
A helper function that reads a vector of &#39;T&#39;s to the HDF5 file under a_dataname.
Definition: ParticleIOI.H:62
void readDataChunk(size_t &offset, const hid_t &dataspace, const hid_t &dataset, const hid_t &H5T_type, const unsigned long dataLength, void *const data, const size_t stride=1, const size_t block=1)
Read chunk of data and upgrade offset. Not meant to be a user-facing function.
A not-necessarily-disjoint collective of boxes.
Definition: BoxLayout.H:145
void readParticlesFromHDF(HDF5Handle &a_handle, ParticleData< P > &a_particles, const std::string &a_dataType)
Definition: ParticleIOI.H:244
void read_hdf_part_header(HDF5Handle &a_handle, Vector< Box > &a_grids, vector< unsigned long long > &a_particlesPerBox, const std::string &a_dataType, const std::string &a_path)
Read the particle header from the HDF5 file. Not meant to be a user-facing function.
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
void write_hdf_part_header(HDF5Handle &a_handle, const BoxLayout &a_grids, const vector< unsigned long long > &a_partPerBox, const std::string &a_dataType)
Write the particle header to the HDF5 file. Not meant to be a user-facing function.
void writeParticlesToHDF(HDF5Handle &a_handle, const ParticleData< P > &a_particles, const std::string &a_dataType)
Definition: ParticleIOI.H:93
Handle to a particular group in an HDF file.
Definition: CH_HDF5.H:294
Definition: ParticleData.H:67