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

fix writing of particle state

parent d5cdf490
No related branches found
No related tags found
No related merge requests found
...@@ -387,116 +387,46 @@ void distributed_particles<particle_type, rnumber, interp_neighbours>::write( ...@@ -387,116 +387,46 @@ void distributed_particles<particle_type, rnumber, interp_neighbours>::write(
this->comm); this->comm);
delete[] yy; delete[] yy;
if (this->myrank == 0) if (this->myrank == 0)
{ this->write_point3D_chunk(dset_name, 0, data);
std::string temp_string = (std::string(this->name) +
std::string("/") +
std::string(dset_name));
hid_t dset = H5Dopen(data_file_id, temp_string.c_str(), H5P_DEFAULT);
hid_t mspace, wspace;
hsize_t count[3], offset[3];
wspace = H5Dget_space(dset);
H5Sget_simple_extent_dims(wspace, count, NULL);
assert(count[2] == 3);
count[0] = 1;
offset[0] = this->iteration / this->traj_skip;
offset[1] = 0;
offset[2] = 0;
mspace = H5Screate_simple(3, count, NULL);
H5Sselect_hyperslab(wspace, H5S_SELECT_SET, offset, NULL, count, NULL);
H5Dwrite(dset, H5T_NATIVE_DOUBLE, mspace, wspace, H5P_DEFAULT, data);
H5Sclose(mspace);
H5Sclose(wspace);
H5Dclose(dset);
}
delete[] data; delete[] data;
} }
template <int particle_type, class rnumber, int interp_neighbours> template <int particle_type, class rnumber, int interp_neighbours>
void distributed_particles<particle_type, rnumber, interp_neighbours>::write( void distributed_particles<particle_type, rnumber, interp_neighbours>::write(
const hid_t data_file_id, const hid_t data_file_id,
const char *dset_name, const bool write_rhs)
std::unordered_map<int, single_particle_state<particle_type>> &y) {
double *temp0 = new double[this->chunk_size*this->ncomponents];
double *temp1 = new double[this->chunk_size*this->ncomponents];
for (int cindex=0; cindex<this->get_number_of_chunks(); cindex++)
{ {
//double *data = new double[this->nparticles*this->ncomponents]; //write state
//double *yy = new double[this->nparticles*this->ncomponents]; std::fill_n(temp0, this->ncomponents*this->chunk_size, 0);
//std::fill_n(yy, this->nparticles*this->ncomponents, 0); for (int p=0; p<this->chunk_size; p++)
//for (int p=0; p<this->nparticles; p++) {
//{ auto pp = this->state.find(p + cindex*this->chunk_size);
// auto pp = y.find(p); if (pp != this->state.end())
// if (pp != y.end()) std::copy(pp->second.data,
// std::copy(pp->second.data, pp->second.data + this->ncomponents,
// pp->second.data + this->ncomponents, temp0 + pp->first*this->ncomponents);
// yy + pp->first*this->ncomponents);
//}
//MPI_Allreduce(
// yy,
// data,
// this->ncomponents*this->nparticles,
// MPI_DOUBLE,
// MPI_SUM,
// this->comm);
//delete[] yy;
//if (this->myrank == 0)
//{
// std::string temp_string = (std::string(this->name) +
// std::string("/") +
// std::string(dset_name));
// hid_t dset = H5Dopen(data_file_id, temp_string.c_str(), H5P_DEFAULT);
// hid_t mspace, wspace;
// hsize_t count[3], offset[3];
// wspace = H5Dget_space(dset);
// H5Sget_simple_extent_dims(wspace, count, NULL);
// count[0] = 1;
// offset[0] = this->iteration / this->traj_skip;
// offset[1] = 0;
// offset[2] = 0;
// mspace = H5Screate_simple(3, count, NULL);
// H5Sselect_hyperslab(wspace, H5S_SELECT_SET, offset, NULL, count, NULL);
// H5Dwrite(dset, H5T_NATIVE_DOUBLE, mspace, wspace, H5P_DEFAULT, data);
// H5Sclose(mspace);
// H5Sclose(wspace);
// H5Dclose(dset);
//}
//delete[] data;
} }
MPI_Allreduce(
template <int particle_type, class rnumber, int interp_neighbours> temp0,
void distributed_particles<particle_type, rnumber, interp_neighbours>::write( temp1,
const hid_t data_file_id, this->ncomponents*this->chunk_size,
const bool write_rhs) MPI_DOUBLE,
MPI_SUM,
this->comm);
if (this->myrank == 0)
this->write_state_chunk(cindex, temp1);
//write rhs
if (this->iteration > 0)
for (int i=0; i<this->integration_steps; i++)
{ {
this->write(data_file_id, "state", this->state); }
//if (this->myrank == 0) }
//{ delete[] temp0;
// if (write_rhs) delete[] temp1;
// {
// std::string temp_string = (
// std::string("/") +
// std::string(this->name) +
// std::string("/rhs"));
// hid_t dset = H5Dopen(data_file_id, temp_string.c_str(), H5P_DEFAULT);
// hid_t wspace = H5Dget_space(dset);
// hsize_t count[4], offset[4];
// H5Sget_simple_extent_dims(wspace, count, NULL);
// //writing to last available position
// offset[0] = count[0] - 1;
// offset[1] = 0;
// offset[2] = 0;
// offset[3] = 0;
// count[0] = 1;
// count[1] = 1;
// hid_t mspace = H5Screate_simple(4, count, NULL);
// for (int i=0; i<this->integration_steps; i++)
// {
// offset[1] = i;
// H5Sselect_hyperslab(wspace, H5S_SELECT_SET, offset, NULL, count, NULL);
// H5Dwrite(dset, H5T_NATIVE_DOUBLE, mspace, wspace, H5P_DEFAULT, this->rhs[i]);
// }
// H5Sclose(mspace);
// H5Sclose(wspace);
// H5Dclose(dset);
// }
//}
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment