20 std::unique_ptr<CsvParser> m_snapshot_field_data;
21 std::unique_ptr<IniParserSnapshot> m_snapshot_ini_data;
22 bool m_no_snapshot{
false};
23 bool m_keep_sim_config{
false};
24 bool m_keep_module_inis{
false};
47 m_keep_sim_config = sim->m_simulation_config.getBoolParameters(
"_snapshot_keep_sim");
55 m_keep_module_inis = sim->m_simulation_config.getBoolParameters(
"_snapshot_keep_module");
65 std::cout << sim->m_simulation_config.getStringParameters(
"snapshot") <<
"\n";
66 if (sim->m_simulation_config.getStringParameters(
"snapshot") ==
"None")
71 std::string
filename{sim->m_simulation_config.getStringParameters(
"snapshot")};
74 m_snapshot_ini_data = std::make_unique<IniParserSnapshot>(
filename);
75 std::cout <<
"\033[32m[SnapshotLoader] Successfully read snapshot file: "
76 << sim->m_simulation_config.getStringParameters(
"snapshot") <<
"\033[0m\n";
98 double elapsed_time{0.0};
113 sim->elapsed_time = elapsed_time;
114 sim->time_step =
int(elapsed_time / sim->m_simulation_config.getDoubleParameters(
"time_delta"));
115 std::cout <<
"\033[32m[SnapshotLoader] Successfully loaded snapshot file field data\033[0m\n";
133 if (m_no_snapshot || m_keep_module_inis)
156 m_snapshot_ini_data->getModuleContents(
module_name));
170 m_snapshot_ini_data->getModuleContents(
module_name));
180 std::cerr <<
"[SnapshotLoader] Couldn't find module: " <<
module_name
181 <<
" in all loaded modules. Please load this module to complete snapshot "
183 throw std::runtime_error(
184 "Couldn't find specified module from snapshot file in all loaded modules.\n");
188 <<
"\033[32m[SnapshotLoader] Successfully loaded snapshot file module ini files\033[0m\n";
199 if (m_no_snapshot || m_keep_sim_config)
204 m_snapshot_ini_data->getModuleContents(
"SimulationConfig"))
208 if (
key !=
"snapshot_save_file")
210 sim->m_simulation_config.forceValueOverwrite(
key,
214 std::cout <<
"\033[32m[SnapshotLoader] Successfully loaded snapshot file simulation "
215 "configuration data\033[0m\n";
Error class to throw when a module chain has circular or missing dependencies. Inherits from std::exc...
Definition ChainManager.h:28
Class which loads snapshot files and writes their data to the inis and fields. Loads any file created...
Definition SnapshotLoader.h:18
SnapshotLoader(SimulationClassBase< T > *sim)
Constructor of the SnapshotLoader.
Definition SnapshotLoader.h:42
void overwriteIniFiles(SimulationClassBase< T > *sim, std::vector< std::shared_ptr< GenericManagingModule< T > > > &all_modules, std::vector< std::shared_ptr< GenericSubmodule< T > > > &all_submodules)
Overwrites the content of the module ini files within each module. Throws an error,...
Definition SnapshotLoader.h:128
void overwriteSimFields(SimulationClassBase< T > *sim)
Overwrites the fields in sim with the ones from the snapshot.
Definition SnapshotLoader.h:90
void overwriteSimConfig(SimulationClassBase< T > *sim)
Overwrite the simulation config data (default.ini + user supplied run ini).
Definition SnapshotLoader.h:197