8#ifndef OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_UTIL_HPP_
9#define OPENFPM_IO_SRC_HDF5_XDMFWRITER_HDF5_XDMFWRITER_UTIL_HPP_
12#include "Vector/map_vector.hpp"
27template<
typename type>
bool HDF5CreateDataSet(hid_t file_id,
const std::string & str ,
void * ptr,
size_t sz)
29 hid_t plist_id = H5Pcreate(H5P_DATASET_XFER);
34 hsize_t dimsf[1] = {sz};
35 hid_t filespace = H5Screate_simple(1, dimsf, NULL);
39 if (std::is_same<type,char>::value ==
true)
41 hid_t dset_id = H5Dcreate(file_id, str.c_str(), H5T_NATIVE_CHAR, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
45 herr_t status = H5Dwrite(dset_id, H5T_NATIVE_CHAR, H5S_ALL, H5S_ALL, plist_id, ptr);
99 else if (std::is_same<type,double>::value ==
true)
101 hid_t dset_id = H5Dcreate(file_id, str.c_str(), H5T_NATIVE_DOUBLE, filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
105 herr_t status = H5Dwrite(dset_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, plist_id, ptr);
129template<
typename T,
size_t p
id,
typename V>
140 static inline void write(hid_t file_id,
const std::string & str, V & v,
size_t stop)
146 for (
size_t j = 0 ; j < stop ; j++)
147 buffer.get(j) = v.template get<pid>(j);
149 HDF5CreateDataSet<T>(file_id,str.c_str(),buffer.getPointer(),stop*
sizeof(T));
154template<
typename T,
size_t p
id,
typename V,
size_t N1>
166 static inline void write(hid_t file_id,
const std::string & str, V & v,
size_t stop)
168 for (
size_t i1 = 0 ; i1 < N1 ; i1++)
174 for (
size_t j = 0 ; j < stop ; j++)
175 buffer.get(j) = v.template get<pid>(j)[i1];
177 std::stringstream sstr;
180 HDF5CreateDataSet<T>(file_id,std::string(str) + sstr.str(),v.getPointer(),stop*
sizeof(T));
186template<
typename T,
size_t p
id,
typename V,
size_t N1,
size_t N2>
198 static inline void write(hid_t file_id,
const std::string & str, V & v,
size_t stop)
200 for (
size_t i1 = 0 ; i1 < N1 ; i1++)
202 for (
size_t i2 = 0 ; i2 < N2 ; i2++)
208 for (
size_t j = 0 ; j < stop ; j++)
209 buffer.get(j) = v.template get<pid>(j)[i1][i2];
211 std::stringstream sstr;
212 sstr <<
"_" << i1 <<
"_" << i2;
214 HDF5CreateDataSet<T>(file_id,std::string(str) + sstr.str(),v.getPointer(),stop*
sizeof(T));
221template<
typename T,
size_t p
id,
typename V,
size_t N1,
size_t N2,
size_t N3>
233 static inline void write(hid_t file_id,
const std::string & str, V & v,
size_t stop)
235 for (
size_t i1 = 0 ; i1 < N1 ; i1++)
237 for (
size_t i2 = 0 ; i2 < N2 ; i2++)
239 for (
size_t i3 = 0 ; i3 < N3 ; i3++)
245 for (
size_t j = 0 ; j < stop ; j++)
246 buffer.get(j) = v.template get<pid>(j)[i1][i2][i3];
248 std::stringstream sstr;
249 sstr <<
"_" << i1 <<
"_" << i2 <<
"_" << i3;
251 HDF5CreateDataSet<T>(file_id,std::string(str) + sstr.str(),v.getPointer(),stop*
sizeof(T));
259template<
typename T,
size_t p
id,
typename V ,
size_t N1,
size_t N2,
size_t N3,
size_t N4>
271 static inline void write(hid_t file_id,
const std::string & str, V & v,
size_t stop)
273 for (
size_t i1 = 0 ; i1 < N1 ; i1++)
275 for (
size_t i2 = 0 ; i2 < N2 ; i2++)
277 for (
size_t i3 = 0 ; i3 < N3 ; i3++)
279 for (
size_t i4 = 0 ; i4 < N4 ; i4++)
285 for (
size_t j = 0 ; j < stop ; j++)
286 buffer.get(j) = v.template get<pid>(j)[i1][i2][i3][i4];
289 std::stringstream sstr;
290 sstr <<
"_" << i1 <<
"_" << i2 <<
"_" << i3 <<
"_" << i4;
292 HDF5CreateDataSet<T>(file_id,std::string(str) + sstr.str(),v.getPointer(),stop*
sizeof(T));
Implementation of 1-D std::vector like structure.
static void write(hid_t file_id, const std::string &str, V &v, size_t stop)
write
static void write(hid_t file_id, const std::string &str, V &v, size_t stop)
write
static void write(hid_t file_id, const std::string &str, V &v, size_t stop)
write
static void write(hid_t file_id, const std::string &str, V &v, size_t stop)
write
Write an HDF5 dataset in case of scalars and vectors.
static void write(hid_t file_id, const std::string &str, V &v, size_t stop)
write