6#include <spdlog/spdlog.h>
25 controller(vtkSmartPointer<vtkMPIController>::New()),
31 vtkMPIController::SetGlobalController(
controller);
36 std::string
const& project,
37 std::vector<std::string>
const& xml_patch_file_names,
38 bool const reference_path_is_set, std::string
const& reference_path,
39 bool const nonfatal, std::string
const& outdir, std::string
const& mesh_dir,
40 std::string
const& script_dir,
bool const write_prj)
42 INFO(
"Reading project file {}.",
43 std::filesystem::relative(project).
string());
44 DBUG(
"Project file: {}.", std::filesystem::absolute(project).
string());
46 std::stringstream prj_stream;
50 project, !nonfatal,
"OpenGeoSysProject", prj_stream);
52 if (!reference_path_is_set)
54 project_config.ignoreConfigParameter(
"test_definition");
60 project_config.getConfigSubtree(
"test_definition"), reference_path,
65 "No tests were constructed from the test definitions, "
66 "but reference solutions path was given.");
69 INFO(
"Cleanup possible output files before running ogs.");
74 if (
auto t = project_config.getConfigSubtreeOptional(
"insitu"))
78 t->getConfigSubtree(
"scripts"),
83 project_config.ignoreConfigParameter(
"insitu");
86 project_data = std::make_unique<ProjectData>(project_config, outdir,
87 mesh_dir, script_dir);
89 INFO(
"Initialize processes.");
96 checkAndInvalidate(project_config);
100 auto time_value = time_loop.currentTime()();
101 INFO(
"Time step #0 started. Time: {}. Step size: 0.", time_value);
105 time_loop.initialize();
106 INFO(
"Time step #0 took {:g} s.", init_timer.
elapsed());
112 return time_loop.currentTime()();
118 return time_loop.endTime()();
124 if (time_loop.currentTime() < time_loop.endTime())
126 auto const result = time_loop.executeTimeStep();
127 time_loop.calculateNextTimeStep();
152 INFO(
"Solve processes.");
154 while (time_loop.currentTime() < time_loop.endTime())
156 time_loop.executeTimeStep();
157 if (!time_loop.calculateNextTimeStep())
163 return time_loop.successful_time_step;
169 time_loop.outputLastTimeStep();
186#if defined(USE_PETSC)
196 auto const end_time = std::chrono::system_clock::now();
198 DBUG(
"No test definition was found. No tests will be executed.");
199 INFO(
"OGS completed on {:s}.", time_str);
204 INFO(
"##########################################");
205 INFO(
"# Running tests #");
206 INFO(
"##########################################");
209 auto const end_time = std::chrono::system_clock::now();
213 INFO(
"OGS completed on {:s}.", time_str);
217 ERR(
"OGS terminated on {:s}. One of the tests failed.", time_str);
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void signalHandler(int signum)
static std::atomic< int > gSignalThatStoppedMe
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
std::shared_ptr< ApplicationsLib::LinearSolverLibrarySetup > linear_solver_library_setup
OGS_EXPORT_SYMBOL bool executeSimulation()
OGS_EXPORT_SYMBOL std::optional< ApplicationsLib::TestDefinition > getTestDefinition() const
std::unique_ptr< ProjectData > project_data
static OGS_EXPORT_SYMBOL int runTestDefinitions(std::optional< ApplicationsLib::TestDefinition > &test_definition)
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[])
OGS_EXPORT_SYMBOL std::vector< std::string > getMeshNames() const
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 extractPath(std::string const &pathname)
ConfigTree makeConfigTree(const std::string &filepath, const bool be_ruthless, const std::string &toplevel_tag, std::stringstream &prj_stream)
std::string formatDate(std::chrono::time_point< std::chrono::system_clock > const &time)
void removeFiles(std::vector< std::string > const &files)
void Initialize(BaseLib::ConfigTree const &scripts_config, std::string const &path)