6#include <spdlog/spdlog.h>
24 controller(vtkSmartPointer<vtkMPIController>::New()),
30 vtkMPIController::SetGlobalController(
controller);
35 std::string
const& project,
36 std::vector<std::string>
const& xml_patch_file_names,
37 bool const reference_path_is_set, std::string
const& reference_path,
38 bool const nonfatal, std::string
const& outdir, std::string
const& mesh_dir,
39 std::string
const& script_dir,
bool const write_prj)
41 INFO(
"Reading project file {}.",
42 std::filesystem::relative(project).
string());
43 DBUG(
"Project file: {}.", std::filesystem::absolute(project).
string());
45 std::stringstream prj_stream;
49 project, !nonfatal,
"OpenGeoSysProject", prj_stream);
51 if (!reference_path_is_set)
53 project_config.ignoreConfigParameter(
"test_definition");
59 project_config.getConfigSubtree(
"test_definition"), reference_path,
64 "No tests were constructed from the test definitions, "
65 "but reference solutions path was given.");
68 INFO(
"Cleanup possible output files before running ogs.");
73 if (
auto t = project_config.getConfigSubtreeOptional(
"insitu"))
77 t->getConfigSubtree(
"scripts"),
82 project_config.ignoreConfigParameter(
"insitu");
85 project_data = std::make_unique<ProjectData>(project_config, outdir,
86 mesh_dir, script_dir);
88 INFO(
"Initialize processes.");
95 checkAndInvalidate(project_config);
99 auto time_value = time_loop.currentTime()();
100 INFO(
"Time step #0 started. Time: {}. Step size: 0.", time_value);
104 time_loop.initialize();
105 INFO(
"Time step #0 took {:g} s.", init_timer.
elapsed());
111 return time_loop.currentTime()();
117 return time_loop.endTime()();
123 if (time_loop.currentTime() < time_loop.endTime())
125 auto const result = time_loop.executeTimeStep();
126 time_loop.calculateNextTimeStep();
151 INFO(
"Solve processes.");
153 while (time_loop.currentTime() < time_loop.endTime())
155 time_loop.executeTimeStep();
156 if (!time_loop.calculateNextTimeStep())
162 return time_loop.successful_time_step;
168 time_loop.outputLastTimeStep();
185#if defined(USE_PETSC)
195 auto const end_time = std::chrono::system_clock::now();
197 DBUG(
"No test definition was found. No tests will be executed.");
198 INFO(
"OGS completed on {:s}.", time_str);
203 INFO(
"##########################################");
204 INFO(
"# Running tests #");
205 INFO(
"##########################################");
208 auto const end_time = std::chrono::system_clock::now();
212 INFO(
"OGS completed on {:s}.", time_str);
216 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
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)
ApplicationsLib::LinearSolverLibrarySetup linear_solver_library_setup
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)