Now writing the json file to the output hdf5
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include <fstream>
|
||||
#include "mpi.h"
|
||||
#include "IO/simulation_output.h"
|
||||
#include "IO/hdf5_writer.h"
|
||||
@@ -43,7 +44,8 @@ void SimulationOutput::setParticleOutput(OutputTask task) {
|
||||
|
||||
void SimulationOutput::writeMetaData(
|
||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
||||
const std::shared_ptr<PoissonSolver>& poisson_solver) {
|
||||
const std::shared_ptr<PoissonSolver>& poisson_solver,
|
||||
std::string parameter_file_path) {
|
||||
if (MpiCommunication::mpi_rank == 0) {
|
||||
for (auto& pair : species) {
|
||||
writeMetaData(pair.second.get());
|
||||
@@ -66,10 +68,28 @@ void SimulationOutput::writeMetaData(
|
||||
writeMetaData(poisson_solver.get(), specie_path);
|
||||
}
|
||||
|
||||
// write the number of mpi processes used in the current simulation
|
||||
// write the number of mpi processes used in the current simulation
|
||||
{
|
||||
writer.write(MpiCommunication::mpiSize(), "/NumberProcesses");
|
||||
}
|
||||
|
||||
// write the json file to the hdf output
|
||||
{
|
||||
std::stringstream file;
|
||||
std::ifstream istream(parameter_file_path.c_str());
|
||||
istream >> file.rdbuf();
|
||||
|
||||
// find occurance of last slash in the path of the parameter
|
||||
size_t slshidx = parameter_file_path.rfind("/");
|
||||
|
||||
std::string hdf5path = (slshidx == std::string::npos) ?
|
||||
"/" + parameter_file_path :
|
||||
parameter_file_path.substr(slshidx);
|
||||
|
||||
SIM_INFO("blubb: " + hdf5path);
|
||||
|
||||
writer.write(file.str(), hdf5path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "tools/simulation_time.h"
|
||||
|
||||
Simulation::Simulation(std::string parameter_filename)
|
||||
: parameter_(parameter_filename) {
|
||||
: parameter_(parameter_filename), parameter_file_path_(parameter_filename) {
|
||||
init(parameter_);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ void Simulation::init(Parameter& parameter) {
|
||||
#ifdef debug
|
||||
DEBUG_LEVEL_0("Output meta data.");
|
||||
#endif
|
||||
output_->writeMetaData(tracked_species_, poisson_solver_);
|
||||
output_->writeMetaData(tracked_species_, poisson_solver_, parameter_file_path_);
|
||||
}
|
||||
|
||||
int eventsThisCpu(int events_all_cpus) {
|
||||
|
||||
Reference in New Issue
Block a user