added basic parallel output for the
string representation of the rng engine state
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include "mpi.h"
|
||||
#include "IO/simulation_output.h"
|
||||
#include "IO/hdf5_writer.h"
|
||||
|
||||
@@ -29,6 +30,10 @@ void SimulationOutput::setPotentialOutput(OutputTask task) {
|
||||
task_potential_ = task;
|
||||
}
|
||||
|
||||
void SimulationOutput::setRestartInfoOutput(OutputTask task) {
|
||||
task_rng_ = task;
|
||||
}
|
||||
|
||||
void SimulationOutput::writeMetaData(
|
||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
||||
const std::shared_ptr<PoissonSolver>& poisson_solver) {
|
||||
@@ -58,7 +63,8 @@ void SimulationOutput::writeMetaData(
|
||||
void SimulationOutput::writeSimulationData(
|
||||
int cpu_sync,
|
||||
std::map<std::string, std::shared_ptr<species::TrackedSpecie>>& species,
|
||||
PoissonSolver* poisson_solver) {
|
||||
PoissonSolver* poisson_solver,
|
||||
std::mt19937* engine) {
|
||||
if (MpiCommunication::mpi_rank == 0) {
|
||||
DEBUG_LEVEL_2("Write density field data.");
|
||||
for (auto& task : tasks_density_fields_) {
|
||||
@@ -91,6 +97,12 @@ void SimulationOutput::writeSimulationData(
|
||||
task_potential_.overwrite_last);
|
||||
}
|
||||
}
|
||||
|
||||
// if the rng intervall = 0 (no neg. intervalls allowed) -> no output,
|
||||
// otherwise the intervall used the same as for the other output
|
||||
if((task_rng_.intervall > 0) && (cpu_sync%task_rng_.intervall == 0)) {
|
||||
writeRestartData(engine, cpu_sync, task_rng_.overwrite_last);
|
||||
}
|
||||
}
|
||||
|
||||
void SimulationOutput::writeSimulationData(DynamicDensityField* density_field,
|
||||
@@ -159,6 +171,28 @@ void SimulationOutput::writeSimulationData(PoissonSolver* poisson_solver,
|
||||
writePotential(poisson_solver, path);
|
||||
}
|
||||
|
||||
void SimulationOutput::writeRestartData(std::mt19937* engine, int cpu_sync,
|
||||
bool overwrite_last) {
|
||||
std::string path_base = "/RestartInfo/SyncPeriod_" +
|
||||
std::to_string(cpu_sync) +
|
||||
"/CPU_";
|
||||
if (overwrite_last) {
|
||||
path_base = "/RestartInfo/LastSyncPeriod/CPU_";
|
||||
}
|
||||
DEBUG_LEVEL_3(path_base);
|
||||
DEBUG_LEVEL_3("Write restart info.");
|
||||
writeRandomEngineState(engine, path_base);
|
||||
DEBUG_LEVEL_3("Done");
|
||||
}
|
||||
|
||||
void SimulationOutput::writeRandomEngineState(std::mt19937* engine, std::string path) {
|
||||
std::ostringstream engine_state;
|
||||
engine_state << (*engine);
|
||||
DEBUG_LEVEL_0(std::to_string(engine_state.str().size()));
|
||||
DEBUG_LEVEL_0(std::to_string(sizeof(*engine)));
|
||||
writer.writeRNG(engine_state.str(), path);
|
||||
}
|
||||
|
||||
void SimulationOutput::writeNumDeletions(DeletionLogger* logger,
|
||||
std::string path) {
|
||||
std::string path_to_deletions = path + "/NumDeletions";
|
||||
|
||||
Reference in New Issue
Block a user