built restart utilities

This commit is contained in:
2024-09-03 16:02:40 +02:00
parent c33629cb88
commit 9c45fce644
11 changed files with 341 additions and 7 deletions
+38
View File
@@ -0,0 +1,38 @@
#include "generators/restart_generator.h"
#include "IO/restart.h"
#include "generators/vector_field_generator.h"
namespace generator {
Restart buildRestart(json_t* object) {
DEBUG_LEVEL_3("Build Restart.");
bool do_restart = json_bool(json_object_by_path(object, {"Do"}));
if (!do_restart) {
DEBUG_LEVEL_3("No Restart desired");
return Restart(false, "", "");
}
std::string filepath = readAbsoluteFilename(json_object_by_path(object, {"PathToH5"}));
DEBUG_LEVEL_3("Restart: file path:" + filepath);
std::string identifier;
int sync_period = json_int(json_object_by_path(object, {"SyncPeriod"}));
if(sync_period == 0 && json_string(json_object_by_path(object, {"SyncPeriod"}))
== "LastSyncPeriod") {
identifier = "LastSyncPeriod";
} else {
ASSERT_POSITIVE(&sync_period, "The SyncPeriod for the restart has to be either"
" positive or \"LastSyncPeriod\".");
identifier = "SyncPeriod_" + std::to_string(sync_period);
}
DEBUG_LEVEL_3("Restart: SyncPeriod to be started from: " + identifier);
return Restart(do_restart, filepath, identifier);
}
Restart buildRestart(Parameter& parameter) {
return buildRestart(
json_object_by_path(parameter.jsonFile(), {"Restart"}));
}
} // namespace generator
@@ -166,7 +166,7 @@ std::shared_ptr<SimulationOutput> buildSimulationOutput(
}
ASSERT_NOTNEGATIVE(&intervall, "The intervall for RestartInfo has to be either 0"
",if no output is required or positive otherwise");
DEBUG_LEVEL_3("Restart Interval: " + std::to_string(intervall));
DEBUG_LEVEL_3("Restart output interval: " + std::to_string(intervall));
bool overwrite_last = json_bool(
json_object_by_path(object, {"RestartInfo", "OverwriteLast"}));