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

try to be smarter about resizing datasets

parent bd831135
No related branches found
No related tags found
No related merge requests found
...@@ -52,7 +52,8 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -52,7 +52,8 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
//begincpp //begincpp
std::string temp_string; std::string temp_string;
hsize_t dims[4]; hsize_t dims[4];
hid_t Cdset, Cspace; hid_t group;
hid_t Cspace, Cdset;
int ndims; int ndims;
// store kspace information // store kspace information
Cdset = H5Dopen(stat_file, "/kspace/kshell", H5P_DEFAULT); Cdset = H5Dopen(stat_file, "/kspace/kshell", H5P_DEFAULT);
...@@ -75,20 +76,11 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base): ...@@ -75,20 +76,11 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
Cdset = H5Dopen(stat_file, "/kspace/dk", H5P_DEFAULT); Cdset = H5Dopen(stat_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);
group = H5Gopen(stat_file, "/statistics", H5P_DEFAULT);
H5Ovisit(group, H5_INDEX_NAME, H5_ITER_NATIVE, grow_statistics_dataset, NULL);
H5Gclose(group);
//endcpp //endcpp
""" """
for field in ['velocity', 'vorticity']:
for key in ['/statistics/xlines/{0}'.format(field),
'/statistics/moments/{0}'.format(field),
'/statistics/histograms/{0}'.format(field),
'/statistics/spectra/{0}_{0}'.format(field)]:
self.file_datasets_grow += ('Cdset = H5Dopen(stat_file, "{0}", H5P_DEFAULT);\n'.format(key) +
'Cspace = H5Dget_space(Cdset);\n' +
'ndims = H5Sget_simple_extent_dims(Cspace, dims, NULL);\n' +
'dims[0] += niter_todo/niter_stat;\n' +
'H5Dset_extent(Cdset, dims);\n' +
'H5Sclose(Cspace);\n' +
'H5Dclose(Cdset);\n')
self.style = {} self.style = {}
self.statistics = {} self.statistics = {}
self.fluid_output = 'fs->write(\'v\', \'c\');\n' self.fluid_output = 'fs->write(\'v\', \'c\');\n'
......
...@@ -102,6 +102,22 @@ class fluid_particle_base(bfps.code): ...@@ -102,6 +102,22 @@ class fluid_particle_base(bfps.code):
self.includes += self.particle_includes self.includes += self.particle_includes
self.variables += self.particle_variables self.variables += self.particle_variables
self.definitions += self.particle_definitions self.definitions += self.particle_definitions
self.definitions += ('int grow_single_dataset(hid_t dset, int tincrement)\n{\n' +
'int ndims;\n' +
'hsize_t dims[4];\n' +
'hsize_t space;\n' +
'space = H5Dget_space(dset);\n' +
'ndims = H5Sget_simple_extent_dims(space, dims, NULL);\n' +
'dims[0] += tincrement;\n' +
'H5Dset_extent(dset, dims);\n' +
'H5Sclose(space);\n' +
'return EXIT_SUCCESS;\n}\n')
self.definitions += ('herr_t grow_statistics_dataset(hid_t o_id, const char *name, const H5O_info_t *info, void *op_data)\n{\n' +
'if (info->type == H5O_TYPE_DATASET)\n{\n' +
'hsize_t dset = H5Dopen(o_id, name, H5P_DEFAULT);\n' +
'grow_single_dataset(dset, niter_todo/niter_stat);\n'
'H5Dclose(dset);\n}\n' +
'return 0;\n}\n')
self.definitions += ('int grow_file_datasets()\n{\n' + self.definitions += ('int grow_file_datasets()\n{\n' +
'int file_problems = 0;\n' + 'int file_problems = 0;\n' +
self.file_datasets_grow + self.file_datasets_grow +
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment