15#include <spdlog/spdlog.h>
31 : linear_solver_library_setup(argc, argv),
33 controller(vtkSmartPointer<vtkMPIController>::New()),
35 test_definition{std::nullopt}
39 vtkMPIController::SetGlobalController(
controller);
44 std::string
const& project,
45 std::vector<std::string>
const& xml_patch_file_names,
46 bool const reference_path_is_set, std::string
const& reference_path,
47 bool const nonfatal, std::string
const& outdir, std::string
const& mesh_dir,
48 std::string
const& script_dir,
bool const write_prj)
50 INFO(
"Reading project file {}.",
51 std::filesystem::relative(project).
string());
52 DBUG(
"Project file: {}.", std::filesystem::absolute(project).
string());
54 std::stringstream prj_stream;
58 project, !nonfatal,
"OpenGeoSysProject", prj_stream);
60 if (!reference_path_is_set)
62 project_config.ignoreConfigParameter(
"test_definition");
68 project_config.getConfigSubtree(
"test_definition"), reference_path,
73 "No tests were constructed from the test definitions, "
74 "but reference solutions path was given.");
77 INFO(
"Cleanup possible output files before running ogs.");
82 if (
auto t = project_config.getConfigSubtreeOptional(
"insitu"))
86 t->getConfigSubtree(
"scripts"),
91 project_config.ignoreConfigParameter(
"insitu");
94 project_data = std::make_unique<ProjectData>(project_config,
96 outdir, mesh_dir, script_dir);
98 INFO(
"Initialize processes.");
105 checkAndInvalidate(project_config);
109 auto time_value = time_loop.currentTime()();
110 INFO(
"Time step #0 started. Time: {}. Step size: 0.", time_value);
114 time_loop.initialize();
115 INFO(
"Time step #0 took {:g} s.", init_timer.
elapsed());
121 return time_loop.currentTime()();
127 return time_loop.endTime()();
133 if (time_loop.currentTime() < time_loop.endTime())
135 auto const result = time_loop.executeTimeStep();
136 if (time_loop.calculateNextTimeStep())
138 time_loop.outputLastTimeStep();
159 INFO(
"Solve processes.");
161 while (time_loop.currentTime() < time_loop.endTime())
163 time_loop.executeTimeStep();
164 if (!time_loop.calculateNextTimeStep())
170 return time_loop.successful_time_step;
176 time_loop.outputLastTimeStep();
193#if defined(USE_PETSC)
199 std::optional<ApplicationsLib::TestDefinition>& test_definition)
203 auto const end_time = std::chrono::system_clock::now();
205 DBUG(
"No test definition was found. No tests will be executed.");
206 INFO(
"OGS completed on {:s}.", time_str);
211 INFO(
"##########################################");
212 INFO(
"# Running tests #");
213 INFO(
"##########################################");
216 auto const end_time = std::chrono::system_clock::now();
220 INFO(
"OGS completed on {:s}.", time_str);
224 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)
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
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[])
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)
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)