Skip to content
Snippets Groups Projects
Commit ffcf3d04 authored by Berenger Bramas's avatar Berenger Bramas Committed by Cristian Lalescu
Browse files

Update to pass the filename and parent group name

parent 46b0ba2c
No related branches found
No related tags found
2 merge requests!21Bugfix/nansampling,!19Feature/sampling new particles test (extension of Update particles sampling for variable dim)
...@@ -73,43 +73,18 @@ int NSVEparticles<rnumber>::do_stats() ...@@ -73,43 +73,18 @@ int NSVEparticles<rnumber>::do_stats()
if (!(this->iteration % this->niter_part == 0)) if (!(this->iteration % this->niter_part == 0))
return EXIT_SUCCESS; return EXIT_SUCCESS;
hid_t file_id, pgroup_id;
// open particle file, and tracers0 group
hid_t plist_id_par = H5Pcreate(H5P_FILE_ACCESS);
assert(plist_id_par >= 0);
int retTest = H5Pset_fapl_mpio(
plist_id_par,
this->particles_output_writer_mpi->getComWriter(),
MPI_INFO_NULL);
assert(retTest >= 0);
// Parallel HDF5 write
file_id = H5Fopen(
(this->simname + "_particles.h5").c_str(),
H5F_ACC_RDWR | H5F_ACC_DEBUG,
plist_id_par);
// file_id = H5Fcreate(filename.c_str(), H5F_ACC_TRUNC | H5F_ACC_DEBUG/*H5F_ACC_EXCL*/, H5P_DEFAULT/*H5F_ACC_RDWR*/, plist_id_par);
assert(file_id >= 0);
H5Pclose(plist_id_par);
pgroup_id = H5Gopen(
file_id,
"tracers0",
H5P_DEFAULT);
//after fluid stats, cvelocity contains Fourier representation of vel field //after fluid stats, cvelocity contains Fourier representation of vel field
this->fs->cvelocity->ift(); this->fs->cvelocity->ift();
// sample velocity // sample velocity
sample_from_particles_system(*this->fs->cvelocity,// field to save sample_from_particles_system(*this->fs->cvelocity,// field to save
this->ps, this->ps,
pgroup_id, // hdf5 datagroup TODO (this->simname + "_particles.h5"), // filename
"tracers0", // hdf5 parent group
"velocity" // dataset basename TODO "velocity" // dataset basename TODO
); );
H5Gclose(pgroup_id);
H5Fclose(file_id);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
......
...@@ -18,23 +18,54 @@ class particles_output_sampling_hdf5 : public abstract_particles_output<partsize ...@@ -18,23 +18,54 @@ class particles_output_sampling_hdf5 : public abstract_particles_output<partsize
size_particle_positions, size_particle_positions,
size_particle_rhs>; size_particle_rhs>;
hid_t parent_group; hid_t file_id, pgroup_id;
const std::string dataset_name; const std::string dataset_name;
const bool use_collective_io; const bool use_collective_io;
public: public:
particles_output_sampling_hdf5(MPI_Comm in_mpi_com, particles_output_sampling_hdf5(MPI_Comm in_mpi_com,
const partsize_t inTotalNbParticles, const partsize_t inTotalNbParticles,
const hid_t in_parent_group, const std::string& in_filename,
const std::string& in_groupname,
const std::string& in_dataset_name, const std::string& in_dataset_name,
const bool in_use_collective_io = false) const bool in_use_collective_io = false)
: Parent(in_mpi_com, inTotalNbParticles, 1), : Parent(in_mpi_com, inTotalNbParticles, 1),
parent_group(in_parent_group),
dataset_name(in_dataset_name), dataset_name(in_dataset_name),
use_collective_io(in_use_collective_io){} use_collective_io(in_use_collective_io){
hid_t plist_id_par = H5Pcreate(H5P_FILE_ACCESS);
assert(plist_id_par >= 0);
int retTest = H5Pset_fapl_mpio(
plist_id_par,
Parent::getComWriter(),
MPI_INFO_NULL);
assert(retTest >= 0);
// Parallel HDF5 write
file_id = H5Fopen(
in_filename.c_str(),
H5F_ACC_RDWR | H5F_ACC_DEBUG,
plist_id_par);
assert(file_id >= 0);
retTest = H5Pclose(plist_id_par);
assert(retTest >= 0);
pgroup_id = H5Gopen(
file_id,
in_groupname.c_str(),
H5P_DEFAULT);
assert(pgroup_id >= 0);
}
~particles_output_sampling_hdf5(){
int retTest = H5Gclose(pgroup_id);
assert(retTest >= 0);
retTest = H5Fclose(file_id);
assert(retTest >= 0);
}
void write( void write(
const int idx_time_step, const int /*idx_time_step*/,
const real_number* /*particles_positions*/, const real_number* /*particles_positions*/,
const std::unique_ptr<real_number[]>* particles_rhs, const std::unique_ptr<real_number[]>* particles_rhs,
const partsize_t nb_particles, const partsize_t nb_particles,
...@@ -65,7 +96,7 @@ public: ...@@ -65,7 +96,7 @@ public:
hid_t dataspace = H5Screate_simple(3, datacount, NULL); hid_t dataspace = H5Screate_simple(3, datacount, NULL);
assert(dataspace >= 0); assert(dataspace >= 0);
hid_t dataset_id = H5Dcreate( parent_group, hid_t dataset_id = H5Dcreate( pgroup_id,
dataset_name.c_str(), dataset_name.c_str(),
type_id, type_id,
dataspace, dataspace,
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
template <class partsize_t, class particles_rnumber, class rnumber, field_backend be, field_components fc> template <class partsize_t, class particles_rnumber, class rnumber, field_backend be, field_components fc>
void sample_from_particles_system(const field<rnumber, be, fc>& in_field, // a pointer to a field<rnumber, FFTW, fc> void sample_from_particles_system(const field<rnumber, be, fc>& in_field, // a pointer to a field<rnumber, FFTW, fc>
std::unique_ptr<abstract_particles_system<partsize_t, particles_rnumber>>& ps, // a pointer to an particles_system<double> std::unique_ptr<abstract_particles_system<partsize_t, particles_rnumber>>& ps, // a pointer to an particles_system<double>
hid_t gid, // an hid_t identifying an HDF5 group const std::string& filename,
const std::string& parent_groupname,
const std::string& fname){ const std::string& fname){
const int size_particle_rhs = ncomp(fc); const int size_particle_rhs = ncomp(fc);
const partsize_t nb_particles = ps->getLocalNbParticles(); const partsize_t nb_particles = ps->getLocalNbParticles();
...@@ -26,7 +27,8 @@ void sample_from_particles_system(const field<rnumber, be, fc>& in_field, // a p ...@@ -26,7 +27,8 @@ void sample_from_particles_system(const field<rnumber, be, fc>& in_field, // a p
particles_output_sampling_hdf5<partsize_t, particles_rnumber, 3, size_particle_rhs> outputclass(MPI_COMM_WORLD, particles_output_sampling_hdf5<partsize_t, particles_rnumber, 3, size_particle_rhs> outputclass(MPI_COMM_WORLD,
ps->getGlobalNbParticles(), ps->getGlobalNbParticles(),
gid, filename,
parent_groupname,
datasetname); datasetname);
outputclass.save(ps->getParticlesPositions(), outputclass.save(ps->getParticlesPositions(),
&sample_rhs, &sample_rhs,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment