Now writing the json file to the output hdf5

This commit is contained in:
2026-11-24 09:28:57 +01:00
parent d82fb6dab8
commit c6687a23c3
4 changed files with 28 additions and 5 deletions
+22 -2
View File
@@ -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);
}
}
}