small fixes and cosmetic changes

This commit is contained in:
2024-09-05 09:33:12 +02:00
parent 9c45fce644
commit 75bb2e4d85
11 changed files with 69 additions and 131 deletions
+15 -21
View File
@@ -39,40 +39,36 @@ void Restart::restart(std::map<std::string, std::shared_ptr<species::TrackedSpec
restart_identifier_;
restartDrawingDensityField(pair.second->densityForDrawing(), path);
}
}
void Restart::restartRandomNumbers(RandomNumbers* random) {
std::string path = "/RestartInfo/" + restart_identifier_
+ "/CPU_" + std::to_string(MpiCommunication::mpiRank());
std::stringstream engine_state = reader_.readEngineString(path);
std::mt19937* engine = random->engine();
engine_state >> *engine;
std::string path = "/RestartInfo/" + restart_identifier_
+ "/CPU_" + std::to_string(MpiCommunication::mpiRank());
std::stringstream engine_state = reader_.readEngineString(path);
std::mt19937* engine = random->engine();
engine_state >> *engine;
std::stringstream check;
check << *engine;
std::stringstream check;
check << *engine;
if(check.str() != engine_state.str()) {
ERROR("Something went wrong in the initialization of the "
"random engine.");
}
// DEBUG_LEVEL_3("Restart of random engine worked");
// std::uniform_real_distribution<double> dist(0,1);
// DEBUG_LEVEL_3("first value after loading rng: " + std::to_string(dist(*engine)));
if(check.str() != engine_state.str()) {
ERROR("Something went wrong in the initialization of the "
"random engine.");
}
}
// only restart the time from which the simulation is restarted.
// The "timestep" is calculated from the json input data (same as no restart).
void Restart::restartTimer(species::TrackedSpecie* reference_specie) {
double time;
double delta_t;
// physical time
{
std::string path = reference_specie->name() + "/DensityField/SimulationData/" +
restart_identifier_ + "/PhysicalTime";
DEBUG_LEVEL_3(path);
// probably add a function in the reader to read a single double value instead of
// a 1d array of doubles
// an 1d array of doubles
blitz::Array<double, 1> restart_time = reader_.readD1Double(path);
if(restart_time.size() != 1) {
ERROR("Physical time should be a single double value but " +
@@ -81,6 +77,7 @@ void Restart::restartTimer(species::TrackedSpecie* reference_specie) {
}
time = restart_time(0);
}
// delta t
{
std::string path = reference_specie->name() + "/CurrentCollector/SimulationData/" +
@@ -101,7 +98,7 @@ void Restart::restartTimer(species::TrackedSpecie* reference_specie) {
}
void Restart::restartDrawingDensityField(DynamicDensityField* field, std::string path) {
// restart TimeInBin-field
// restart TimeInBin field
{
std::string path_to_data = path + "/TimeInBin";
DEBUG_LEVEL_3(path_to_data);
@@ -126,8 +123,5 @@ void Restart::restartPoissonSolver(PoissonSolver* solver) {
"/Potential/";
DEBUG_LEVEL_3(path);
blitz::Array<double, 3> potential = reader_.readD3Double(path);
if(!blitz::all(potential.length() == solver->potential().length())) {
DEBUG_LEVEL_3("Restart Poissonsolver: wrong sizes of the potential");
}
solver->setPotential(potential);
}