Now writing the json file to the output hdf5
This commit is contained in:
@@ -43,7 +43,8 @@ class SimulationOutput {
|
|||||||
|
|
||||||
void writeMetaData(
|
void writeMetaData(
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
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);
|
||||||
|
|
||||||
void writeSimulationData(
|
void writeSimulationData(
|
||||||
int cpu_sync,
|
int cpu_sync,
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ class Simulation {
|
|||||||
|
|
||||||
int timestep = 0;
|
int timestep = 0;
|
||||||
int injectionGroupOffset = 0;
|
int injectionGroupOffset = 0;
|
||||||
|
|
||||||
|
std::string parameter_file_path_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SIMULATION_H */
|
#endif /* SIMULATION_H */
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include <fstream>
|
||||||
#include "mpi.h"
|
#include "mpi.h"
|
||||||
#include "IO/simulation_output.h"
|
#include "IO/simulation_output.h"
|
||||||
#include "IO/hdf5_writer.h"
|
#include "IO/hdf5_writer.h"
|
||||||
@@ -43,7 +44,8 @@ void SimulationOutput::setParticleOutput(OutputTask task) {
|
|||||||
|
|
||||||
void SimulationOutput::writeMetaData(
|
void SimulationOutput::writeMetaData(
|
||||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
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) {
|
if (MpiCommunication::mpi_rank == 0) {
|
||||||
for (auto& pair : species) {
|
for (auto& pair : species) {
|
||||||
writeMetaData(pair.second.get());
|
writeMetaData(pair.second.get());
|
||||||
@@ -66,10 +68,28 @@ void SimulationOutput::writeMetaData(
|
|||||||
writeMetaData(poisson_solver.get(), specie_path);
|
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");
|
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"
|
#include "tools/simulation_time.h"
|
||||||
|
|
||||||
Simulation::Simulation(std::string parameter_filename)
|
Simulation::Simulation(std::string parameter_filename)
|
||||||
: parameter_(parameter_filename) {
|
: parameter_(parameter_filename), parameter_file_path_(parameter_filename) {
|
||||||
init(parameter_);
|
init(parameter_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ void Simulation::init(Parameter& parameter) {
|
|||||||
#ifdef debug
|
#ifdef debug
|
||||||
DEBUG_LEVEL_0("Output meta data.");
|
DEBUG_LEVEL_0("Output meta data.");
|
||||||
#endif
|
#endif
|
||||||
output_->writeMetaData(tracked_species_, poisson_solver_);
|
output_->writeMetaData(tracked_species_, poisson_solver_, parameter_file_path_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int eventsThisCpu(int events_all_cpus) {
|
int eventsThisCpu(int events_all_cpus) {
|
||||||
|
|||||||
Reference in New Issue
Block a user