Skip to content
Snippets Groups Projects
Commit 9b9f505f authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

use only C-API in NavierStokes

parent 1b4b7469
Branches
Tags
No related merge requests found
...@@ -53,7 +53,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -53,7 +53,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
hid_t Cdset, Cspace; hid_t Cdset, Cspace;
int ndims; int ndims;
// store kspace information // store kspace information
Cdset = H5Dopen(data_file->getId(), "/kspace/kshell", H5P_DEFAULT); Cdset = H5Dopen(parameter_file, "/kspace/kshell", H5P_DEFAULT);
Cspace = H5Dget_space(Cdset); Cspace = H5Dget_space(Cdset);
H5Sget_simple_extent_dims(Cspace, dims, NULL); H5Sget_simple_extent_dims(Cspace, dims, NULL);
if (fs->nshells != dims[0]) if (fs->nshells != dims[0])
...@@ -63,13 +63,13 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -63,13 +63,13 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
} }
H5Dwrite(Cdset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, fs->kshell); H5Dwrite(Cdset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, fs->kshell);
H5Dclose(Cdset); H5Dclose(Cdset);
Cdset = H5Dopen(data_file->getId(), "/kspace/nshell", H5P_DEFAULT); Cdset = H5Dopen(parameter_file, "/kspace/nshell", H5P_DEFAULT);
H5Dwrite(Cdset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, fs->nshell); H5Dwrite(Cdset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, fs->nshell);
H5Dclose(Cdset); H5Dclose(Cdset);
Cdset = H5Dopen(data_file->getId(), "/kspace/kM", H5P_DEFAULT); Cdset = H5Dopen(parameter_file, "/kspace/kM", H5P_DEFAULT);
H5Dwrite(Cdset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &fs->kM); H5Dwrite(Cdset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &fs->kM);
H5Dclose(Cdset); H5Dclose(Cdset);
Cdset = H5Dopen(data_file->getId(), "/kspace/dk", H5P_DEFAULT); Cdset = H5Dopen(parameter_file, "/kspace/dk", H5P_DEFAULT);
H5Dwrite(Cdset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &fs->dk); H5Dwrite(Cdset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &fs->dk);
H5Dclose(Cdset); H5Dclose(Cdset);
//endcpp //endcpp
...@@ -79,7 +79,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -79,7 +79,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
'/statistics/moments/{0}'.format(field), '/statistics/moments/{0}'.format(field),
'/statistics/histograms/{0}'.format(field), '/statistics/histograms/{0}'.format(field),
'/statistics/spectra/{0}_{0}'.format(field)]: '/statistics/spectra/{0}_{0}'.format(field)]:
self.file_datasets_grow += ('Cdset = H5Dopen(data_file->getId(), "{0}", H5P_DEFAULT);\n'.format(key) + self.file_datasets_grow += ('Cdset = H5Dopen(parameter_file, "{0}", H5P_DEFAULT);\n'.format(key) +
'Cspace = H5Dget_space(Cdset);\n' + 'Cspace = H5Dget_space(Cdset);\n' +
'ndims = H5Sget_simple_extent_dims(Cspace, dims, NULL);\n' + 'ndims = H5Sget_simple_extent_dims(Cspace, dims, NULL);\n' +
'dims[0] += niter_todo/niter_stat;\n' + 'dims[0] += niter_todo/niter_stat;\n' +
...@@ -154,14 +154,14 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -154,14 +154,14 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
"""] """]
stat_template = """ stat_template = """
//begincpp //begincpp
Cdset = H5Dopen(data_file->getId(), "{0}", H5P_DEFAULT); Cdset = H5Dopen(parameter_file, "{0}", H5P_DEFAULT);
wspace = H5Dget_space(Cdset); wspace = H5Dget_space(Cdset);
ndims = H5Sget_simple_extent_dims(wspace, dims, NULL); ndims = H5Sget_simple_extent_dims(wspace, dims, NULL);
mspace = H5Screate_simple(ndims, count, NULL); mspace = H5Screate_simple(ndims, count, NULL);
H5Sselect_hyperslab(wspace, H5S_SELECT_SET, offset, NULL, count, NULL); H5Sselect_hyperslab(wspace, H5S_SELECT_SET, offset, NULL, count, NULL);
H5Dwrite(Cdset, {1}, mspace, wspace, H5P_DEFAULT, {2}); H5Dwrite(Cdset, {1}, mspace, wspace, H5P_DEFAULT, {2});
H5Dclose(Cdset); H5Dclose(Cdset);
Cdset = H5Dopen(data_file->getId(), "{3}", H5P_DEFAULT); Cdset = H5Dopen(parameter_file, "{3}", H5P_DEFAULT);
H5Dwrite(Cdset, {1}, mspace, wspace, H5P_DEFAULT, {4}); H5Dwrite(Cdset, {1}, mspace, wspace, H5P_DEFAULT, {4});
H5Sclose(mspace); H5Sclose(mspace);
H5Sclose(wspace); H5Sclose(wspace);
...@@ -248,7 +248,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -248,7 +248,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
temp_string = (std::string("/particles/") + temp_string = (std::string("/particles/") +
std::string(ps{0}->name) + std::string(ps{0}->name) +
std::string("/{1}")); std::string("/{1}"));
Cdset = H5Dopen(data_file->getId(), temp_string.c_str(), H5P_DEFAULT); Cdset = H5Dopen(parameter_file, temp_string.c_str(), H5P_DEFAULT);
Cspace = H5Dget_space(Cdset); Cspace = H5Dget_space(Cdset);
ndims = H5Sget_simple_extent_dims(Cspace, dims, NULL); ndims = H5Sget_simple_extent_dims(Cspace, dims, NULL);
dims[0] += niter_todo/niter_part; dims[0] += niter_todo/niter_part;
...@@ -288,7 +288,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -288,7 +288,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
std::string temp_string = (std::string("/particles/") + std::string temp_string = (std::string("/particles/") +
std::string(ps{0}->name) + std::string(ps{0}->name) +
std::string("/velocity")); std::string("/velocity"));
hid_t Cdset = H5Dopen(data_file->getId(), temp_string.c_str(), H5P_DEFAULT); hid_t Cdset = H5Dopen(parameter_file, temp_string.c_str(), H5P_DEFAULT);
hid_t mspace, wspace; hid_t mspace, wspace;
int ndims; int ndims;
hsize_t count[3], offset[3], dims[3]; hsize_t count[3], offset[3], dims[3];
...@@ -307,7 +307,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -307,7 +307,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
temp_string = (std::string("/particles/") + temp_string = (std::string("/particles/") +
std::string(ps{0}->name) + std::string(ps{0}->name) +
std::string("/acceleration")); std::string("/acceleration"));
Cdset = H5Dopen(data_file->getId(), temp_string.c_str(), H5P_DEFAULT); Cdset = H5Dopen(parameter_file, temp_string.c_str(), H5P_DEFAULT);
H5Dwrite(Cdset, H5T_NATIVE_DOUBLE, mspace, wspace, H5P_DEFAULT, acceleration); H5Dwrite(Cdset, H5T_NATIVE_DOUBLE, mspace, wspace, H5P_DEFAULT, acceleration);
H5Sclose(mspace); H5Sclose(mspace);
H5Sclose(wspace); H5Sclose(wspace);
......
...@@ -53,7 +53,6 @@ class code(base): ...@@ -53,7 +53,6 @@ class code(base):
#include "fluid_solver.hpp" #include "fluid_solver.hpp"
#include <iostream> #include <iostream>
#include <hdf5.h> #include <hdf5.h>
#include <H5Cpp.h>
#include <string> #include <string>
#include <cstring> #include <cstring>
#include <fftw3-mpi.h> #include <fftw3-mpi.h>
...@@ -62,8 +61,7 @@ class code(base): ...@@ -62,8 +61,7 @@ class code(base):
self.variables = 'int myrank, nprocs;\n' self.variables = 'int myrank, nprocs;\n'
self.variables += 'int iteration;\n' self.variables += 'int iteration;\n'
self.variables += 'char simname[256], fname[256];\n' self.variables += 'char simname[256], fname[256];\n'
self.variables += ('H5::H5File *data_file;\n' + self.variables += ('hid_t parameter_file, Cdset;\n')
'hid_t parameter_file, Cdset;\n')
self.definitions = '' self.definitions = ''
self.main_start = """ self.main_start = """
//begincpp //begincpp
...@@ -93,10 +91,7 @@ class code(base): ...@@ -93,10 +91,7 @@ class code(base):
read_parameters(parameter_file); read_parameters(parameter_file);
H5Fclose(parameter_file); H5Fclose(parameter_file);
if (myrank == 0) if (myrank == 0)
{ parameter_file = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT);
data_file = new H5::H5File(std::string(simname) + std::string(".h5"), H5F_ACC_RDWR);
parameter_file = data_file->getId();
}
//endcpp //endcpp
""" """
for ostream in ['cout', 'cerr']: for ostream in ['cout', 'cerr']:
...@@ -106,9 +101,10 @@ class code(base): ...@@ -106,9 +101,10 @@ class code(base):
// clean up // clean up
if (myrank == 0) if (myrank == 0)
{ {
Cdset = H5Dopen(data_file->getId(), "iteration", H5P_DEFAULT); Cdset = H5Dopen(parameter_file, "iteration", H5P_DEFAULT);
H5Dwrite(Cdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &iteration); H5Dwrite(Cdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &iteration);
H5Dclose(Cdset); H5Dclose(Cdset);
H5Fclose(parameter_file);
} }
fftwf_mpi_cleanup(); fftwf_mpi_cleanup();
fftw_mpi_cleanup(); fftw_mpi_cleanup();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment