15#include <spdlog/spdlog.h>
30 : linear_solver_library_setup(argc, argv),
32 controller(vtkSmartPointer<vtkMPIController>::New()),
34 test_definition{std::nullopt}
38 vtkMPIController::SetGlobalController(
controller);
43 std::string
const& project,
44 std::vector<std::string>
const& xml_patch_file_names,
45 bool const reference_path_is_set, std::string
const& reference_path,
46 bool const nonfatal, std::string
const& outdir, std::string
const& mesh_dir,
47 std::string
const& script_dir,
bool const write_prj)
49 INFO(
"Reading project file {}.",
50 std::filesystem::relative(project).
string());
51 DBUG(
"Project file: {}.", std::filesystem::absolute(project).
string());
53 std::stringstream prj_stream;
57 project, !nonfatal,
"OpenGeoSysProject", prj_stream);
59 if (!reference_path_is_set)
61 project_config.ignoreConfigParameter(
"test_definition");
67 project_config.getConfigSubtree(
"test_definition"), reference_path,
72 "No tests were constructed from the test definitions, "
73 "but reference solutions path was given.");
76 INFO(
"Cleanup possible output files before running ogs.");
81 if (
auto t = project_config.getConfigSubtreeOptional(
"insitu"))
85 t->getConfigSubtree(
"scripts"),
90 project_config.ignoreConfigParameter(
"insitu");
93 project_data = std::make_unique<ProjectData>(project_config,
95 outdir, mesh_dir, script_dir);
97 INFO(
"Initialize processes.");
104 checkAndInvalidate(project_config);
108 auto time_value = time_loop.currentTime()();
109 INFO(
"Time step #0 started. Time: {}. Step size: 0.", time_value);
113 time_loop.initialize();
114 INFO(
"Time step #0 took {:g} s.", init_timer.
elapsed());
120 return time_loop.currentTime()();
126 return time_loop.endTime()();
132 if (time_loop.currentTime() < time_loop.endTime())
134 auto const result = time_loop.executeTimeStep();
135 if (time_loop.calculateNextTimeStep())
137 time_loop.outputLastTimeStep();
158 INFO(
"Solve processes.");
160 while (time_loop.currentTime() < time_loop.endTime())
162 time_loop.executeTimeStep();
163 if (!time_loop.calculateNextTimeStep())
169 return time_loop.successful_time_step;
175 time_loop.outputLastTimeStep();
192#if defined(USE_PETSC)
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Mesh class.
Definition of the RunTime class.
void signalHandler(int signum)
static std::atomic< int > gSignalThatStoppedMe
Declaration of class Simulation.
static void assertNoSwallowedErrors()
Asserts that there have not been any errors reported in the destructor.
double elapsed() const
Get the elapsed time in seconds.
void start()
Start the timer.
OGS_EXPORT_SYMBOL double currentTime() const
OGS_EXPORT_SYMBOL bool executeSimulation()
OGS_EXPORT_SYMBOL std::optional< ApplicationsLib::TestDefinition > getTestDefinition() const
std::unique_ptr< ProjectData > project_data
std::optional< ApplicationsLib::TestDefinition > test_definition
OGS_EXPORT_SYMBOL MeshLib::Mesh & getMesh(std::string const &name)
OGS_EXPORT_SYMBOL double endTime() const
OGS_EXPORT_SYMBOL ~Simulation()
OGS_EXPORT_SYMBOL void initializeDataStructures(std::string const &project, std::vector< std::string > const &xml_patch_file_names, bool reference_path_is_set, std::string const &reference_path, bool nonfatal, std::string const &outdir, std::string const &mesh_dir, std::string const &script_dir, bool write_prj)
OGS_EXPORT_SYMBOL bool executeTimeStep()
vtkSmartPointer< vtkMPIController > controller
OGS_EXPORT_SYMBOL void outputLastTimeStep() const
OGS_EXPORT_SYMBOL Simulation(int argc, char *argv[])
void prepareProjectFile(std::stringstream &prj_stream, const std::string &filepath, const std::vector< std::string > &patch_files, bool write_prj, const std::string &out_directory)
Applies includes and patch files to project file.
std::string const & getProjectDirectory()
Returns the directory where the prj file resides.
std::string extractPath(std::string const &pathname)
ConfigTree makeConfigTree(const std::string &filepath, const bool be_ruthless, const std::string &toplevel_tag, std::stringstream &prj_stream)
void removeFiles(std::vector< std::string > const &files)
void Initialize(BaseLib::ConfigTree const &scripts_config, std::string const &path)