15#include <spdlog/spdlog.h>
29 : linear_solver_library_setup(argc, argv),
31 controller(vtkSmartPointer<vtkMPIController>::New()),
33 test_definition{std::nullopt}
37 vtkMPIController::SetGlobalController(
controller);
41 MPI_Comm_rank(PETSC_COMM_WORLD, &mpi_rank);
42 spdlog::set_pattern(fmt::format(
"[{}] %^%l:%$ %v", mpi_rank));
48 std::string
const& project,
49 std::vector<std::string>
const& xml_patch_file_names,
50 bool const reference_path_is_set, std::string
const& reference_path,
51 bool const nonfatal, std::string
const& outdir, std::string
const& mesh_dir,
52 std::string
const& script_dir,
bool const write_prj)
54 INFO(
"Reading project file {}.",
55 std::filesystem::absolute(project).
string());
57 std::stringstream prj_stream;
61 project, !nonfatal,
"OpenGeoSysProject", prj_stream);
63 if (!reference_path_is_set)
65 project_config.ignoreConfigParameter(
"test_definition");
71 project_config.getConfigSubtree(
"test_definition"), reference_path,
76 "No tests were constructed from the test definitions, "
77 "but reference solutions path was given.");
80 INFO(
"Cleanup possible output files before running ogs.");
85 if (
auto t = project_config.getConfigSubtreeOptional(
"insitu"))
89 t->getConfigSubtree(
"scripts"),
94 project_config.ignoreConfigParameter(
"insitu");
97 project_data = std::make_unique<ProjectData>(project_config,
99 outdir, mesh_dir, script_dir);
101 INFO(
"Initialize processes.");
108 checkAndInvalidate(project_config);
112 time_loop.initialize();
118 return time_loop.currentTime()();
124 return time_loop.endTime()();
130 if (time_loop.currentTime() < time_loop.endTime())
132 auto const result = time_loop.executeTimeStep();
133 if (time_loop.calculateNextTimeStep())
135 time_loop.outputLastTimeStep();
149 INFO(
"Solve processes.");
151 while (time_loop.currentTime() < time_loop.endTime())
153 time_loop.executeTimeStep();
154 if (!time_loop.calculateNextTimeStep())
160 return time_loop.successful_time_step;
166 time_loop.outputLastTimeStep();
183#if defined(USE_PETSC)
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Mesh class.
Declaration of class Simulation.
static void assertNoSwallowedErrors()
Asserts that there have not been any errors reported in the destructor.
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)