29 std::unique_ptr<CsvParser> m_snapshot_field_data;
30 std::unique_ptr<IniParserSnapshot> m_snapshot_ini_data;
31 bool m_no_snapshot{
false};
32 bool m_keep_sim_config{
false};
33 bool m_keep_module_inis{
false};
76 m_keep_sim_config = sim->m_simulation_config.getBoolParameters(
"_snapshot_keep_sim");
84 m_keep_module_inis = sim->m_simulation_config.getBoolParameters(
"_snapshot_keep_module");
97 snapshotStr = sim->m_simulation_config.getStringParameters(
"snapshot");
101 std::cout <<
"[SnapshotLoader] No snapshot key found in config. Skipping snapshot load.\n";
102 m_no_snapshot =
true;
108 std::cout <<
"[SnapshotLoader] Snapshot value is 'None'. Skipping snapshot load.\n";
109 m_no_snapshot =
true;
124 m_snapshot_ini_data = std::make_unique<IniParserSnapshot>(
filename);
125 if (sim->my_rank == 0)
127 std::cout <<
"\033[32m[SnapshotLoader] Successfully read snapshot file: " <<
filename
131 catch (
const std::exception&
e)
133 std::cerr <<
"[SnapshotLoader] Failed to read snapshot file '" <<
filename
134 <<
"': " <<
e.what() <<
"\n";
135 m_no_snapshot =
true;
156 double elapsed_time{0.0};
171 sim->elapsed_time = elapsed_time;
172 sim->time_step =
int(elapsed_time / sim->m_simulation_config.getDoubleParameters(
"time_delta"));
174 if (sim->my_rank == 0)
177 <<
"\033[32m[SnapshotLoader] Successfully loaded snapshot file field data\033[0m\n";
196 if (m_no_snapshot || m_keep_module_inis)
219 m_snapshot_ini_data->getModuleContents(
module_name));
233 m_snapshot_ini_data->getModuleContents(
module_name));
243 std::cerr <<
"[SnapshotLoader]: Couldn't find module: " <<
module_name
244 <<
" in all loaded modules. Please load this module to complete snapshot "
246 throw std::runtime_error(
247 static_cast<std::string
>(
"[SnapshotLoader]: Couldn't find specified module from "
248 "snapshot file in all loaded modules."));
251 if (sim->my_rank == 0)
253 std::cout <<
"\033[32m[SnapshotLoader] Successfully loaded snapshot file module ini "
266 if (m_no_snapshot || m_keep_sim_config)
271 m_snapshot_ini_data->getModuleContents(
"SimulationConfig"))
275 if (
key !=
"snapshot_save_file")
277 sim->m_simulation_config.forceValueOverwrite(
key,
281 if (sim->my_rank == 0)
283 std::cout <<
"\033[32m[SnapshotLoader] Successfully loaded snapshot file simulation "
284 "configuration data\033[0m\n";
305 numerical_layers = sim->m_simulation_config.getIntParameters(
"numerical_layers");
327 sim->elapsed_time = elapsed_time;
328 sim->time_step =
int(elapsed_time / sim->m_simulation_config.getDoubleParameters(
"time_delta"));
381 field_file = sim->m_simulation_config.getStringParameters(
"snapshot");
385 std::cerr <<
"Could not find file type separator '.' in supplied snapshot file path. "
386 "Please specify the full path with file type.";
387 throw std::runtime_error(
388 "Could not find file type separator '.' in supplied snapshot file path. "
389 "Please specify the full path with file type.");
410 if (sim->m_field_map.find(
field_name) == sim->m_field_map.end())
413 <<
" not found in m_field_map! Could not fully load snapshot - terminating.";
414 throw std::runtime_error(
415 "Field could not be found in m_field_map despite loading snapshot. Check "
416 "your snapshot file and configuration!");
447 if (sim->my_rank < sim->number_of_larger_procs)
467 if (sim->my_rank < sim->number_of_larger_procs)
486 <<
"[SnapshotLoader]: Field in SnapshotLoader is of irregular size! Currently only "
487 "supporting sizes of numerical_layers * numbers_of_facets or numbers_of_facets.\n";
488 throw std::runtime_error(
489 "[SnapshotLoader]: Field in SnapshotLoader is of irregular size! Currently only "
490 "supporting sizes of numerical_layers * numbers_of_facets or numbers_of_facets.\n");
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:37
CsrSparseMatrix()
Constructor for an empty CsrSparseMatrix object. Leaves all storage arrays empty but sets the flag to...
Definition CsrMatrix.h:94
std::pair< int, int > size() const
Function that returns the size of the matrix as a pair in (rows, columns) format.
Definition GenericMatrix.h:120
Class which loads snapshot files and writes their data to the inis and fields. Loads any file created...
Definition SnapshotLoader.h:27
SnapshotLoader(SimulationClassBase< T > *sim)
Constructor of the SnapshotLoader.
Definition SnapshotLoader.h:71
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:191
void overwriteSimFields(SimulationClassBase< T > *sim)
Overwrites the fields in sim with the ones from the snapshot.
Definition SnapshotLoader.h:145
void overwriteSimConfig(SimulationClassBase< T > *sim)
Overwrite the simulation config data (default.ini + user supplied run ini).
Definition SnapshotLoader.h:264