OGS
ProjectData.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "ProjectData.h"
5
6#include <pybind11/eval.h>
7#include <spdlog/fmt/ranges.h>
8
9#include <algorithm>
10#include <boost/algorithm/string/predicate.hpp>
11#include <cctype>
12#include <range/v3/algorithm/contains.hpp>
13#include <range/v3/range/conversion.hpp>
14#include <range/v3/view/adjacent_remove_if.hpp>
15#include <set>
16
17#include "BaseLib/Algorithm.h"
18#include "BaseLib/ConfigTree.h"
19#include "BaseLib/FileTools.h"
20#include "BaseLib/Logging.h"
21#include "BaseLib/StringTools.h"
22#include "GeoLib/GEOObjects.h"
25#include "GeoLib/Raster.h"
26#include "InfoLib/CMakeInfo.h"
30#if defined(USE_LIS)
32#elif defined(USE_PETSC)
34#else
36#endif
40#include "MeshLib/Mesh.h"
41#include "MeshLib/MeshEnums.h"
46#include "ParameterLib/Utils.h"
47
55 BaseLib::ConfigTree const& project_config,
56 std::vector<MeshToolsLib::InitialConditionDataSet>& data_initial_conditions,
57 std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes,
58 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
59{
60 auto const overwrite_mesh_data_config =
62 project_config.getConfigSubtreeOptional("overwrite_mesh_data");
63 if (!overwrite_mesh_data_config)
64 {
65 return;
66 }
67
68 for (auto const& [tag, config] :
69 overwrite_mesh_data_config->getAllChildren())
70 {
71 if (tag == "remove")
72 {
73 auto const field_name =
75 config->getConfigParameter<std::string>("field_name");
77 auto const mesh_name = config->getConfigParameter<std::string>(
78 "mesh", meshes[0]->getName());
79 auto& mesh = MeshLib::findMeshByName(meshes, mesh_name);
80 auto const mesh_item_type = MeshLib::string2MeshItemType(
82 config->getConfigParameter<std::string>("mesh_item_type"));
83
84 MeshLib::Properties& properties = mesh.getProperties();
85 if (properties.template hasPropertyVector<double>(field_name,
86 mesh_item_type))
87 {
88 DBUG("remove property: {}", field_name);
89 properties.removePropertyVector(field_name);
90 }
91 continue;
92 }
93
94 if (tag == "set" || tag == "take_original")
95 {
96 // The "take_original" element shares the parsing code below with
97 // "set", so its parameters are documented separately here.
102 auto const field_name =
104 config->getConfigParameter<std::string>("field_name");
106 auto const mesh_name = config->getConfigParameter<std::string>(
107 "mesh", meshes[0]->getName());
108 auto& mesh = MeshLib::findMeshByName(meshes, mesh_name);
109 auto const mesh_item_type = MeshLib::string2MeshItemType(
111 config->getConfigParameter<std::string>("mesh_item_type"));
112
113 // string2MeshItemType() also accepts 'edge' and 'face', but the
114 // overwrite only supports node, cell and integration-point data.
115 // Reject the unsupported types here so the user gets a clear error
116 // at project-file parsing time instead of a fatal later during the
117 // overwrite.
118 if (mesh_item_type != MeshLib::MeshItemType::Node &&
119 mesh_item_type != MeshLib::MeshItemType::Cell &&
121 {
122 OGS_FATAL(
123 "overwrite_mesh_data: <{:s}> with mesh_item_type '{:s}' is "
124 "not supported. Only 'node', 'cell' and "
125 "'integration_point' "
126 "can be overwritten.",
127 tag, MeshLib::toString(mesh_item_type));
128 }
129
130 // Genuine multi-rank PETSc partition: each rank holds only a local
131 // mesh slice. Material-id selection and node writes not implemented
132 // there. Single-thread wrapper (serial / 1 rank) covers whole mesh,
133 // so allowed.
134 auto const* const partitioned_mesh =
135 dynamic_cast<MeshLib::NodePartitionedMesh const*>(&mesh);
136 bool const is_partition =
137 partitioned_mesh && !partitioned_mesh->isForSingleThread();
138
139 if (is_partition && mesh_item_type == MeshLib::MeshItemType::Node)
140 {
141 OGS_FATAL(
142 "overwrite_mesh_data: <{:s}> modifying node data is not "
143 "implemented for partitioned (PETSc) meshes.",
144 tag);
145 }
146
147 auto const selected_material_ids_string =
149 config->getConfigParameter<std::string>("material_ids", "0");
150 auto const* const material_ids = MeshLib::materialIDs(mesh);
151
152 std::vector<std::size_t> element_ids_for_selected_materials;
153 if (material_ids == nullptr)
154 {
155 // The mesh has no MaterialIDs: treat it as a single material-0
156 // region rather than injecting a permanent MaterialIDs
157 // property (which would leak into the output and into any
158 // downstream code that branches on materialIDs() being
159 // present).
160 if (selected_material_ids_string != "0" &&
161 selected_material_ids_string != "*")
162 {
163 OGS_FATAL(
164 "overwrite_mesh_data: mesh '{:s}' has no MaterialIDs, "
165 "so material_ids='{:s}' cannot be resolved. Only '0' "
166 "or '*' are valid in this case.",
167 mesh_name, selected_material_ids_string);
168 }
169 element_ids_for_selected_materials =
170 ranges::views::iota(std::size_t{0},
171 mesh.getNumberOfElements()) |
172 ranges::to<std::vector>;
173 }
174 else
175 {
176 // Specific material subset: depends on material ids, cannot
177 // resolve against partition-local subset. "*" (whole mesh)
178 // exempt.
179 if (is_partition && selected_material_ids_string != "*")
180 {
181 OGS_FATAL(
182 "overwrite_mesh_data: <{:s}> material-id-based "
183 "selection (material_ids='{:s}') is not implemented "
184 "for "
185 "partitioned (PETSc) meshes.",
186 tag, selected_material_ids_string);
187 }
188 std::set<int> const selected_material_ids =
190 selected_material_ids_string, material_ids, ' ',
191 /*validate=*/true) |
192 ranges::to<std::set<int>>();
193 element_ids_for_selected_materials =
194 ranges::views::iota(std::size_t{0}, material_ids->size()) |
195 ranges::views::filter(
196 [&](std::size_t const i)
197 {
198 return selected_material_ids.contains(
199 (*material_ids)[i]);
200 }) |
201 ranges::to<std::vector>;
202 }
203
204 // For \c set, get parameter_name; for \c take_original, it's
205 // empty
206 auto const& parameter_name =
207 tag == "set"
209 ? config->getConfigParameterOptional<std::string>(
210 "parameter_name")
211 : std::optional<std::string>{};
212
213 if (tag == "set" && !parameter_name)
214 {
215 OGS_FATAL(
216 "\"set\" element requires a parameter_name attribute.");
217 }
218
219 auto const parameter =
220 !parameter_name || parameter_name->empty()
221 ? static_cast<ParameterLib::Parameter<double>*>(nullptr)
223 *parameter_name, parameters, 0, nullptr);
224 data_initial_conditions.emplace_back(
225 field_name,
226 std::move(element_ids_for_selected_materials),
227 nullptr,
228 &mesh,
229 parameter,
230 mesh_item_type);
231 continue;
232 }
233
234 OGS_FATAL(
235 "Unknown element <{:s}> in <overwrite_mesh_data>. Expected one of "
236 "<remove>, <set>, or <take_original>.",
237 tag);
238 }
239}
240
243
244// FileIO
249#include "ParameterLib/Utils.h"
251#include "ProcessLib/TimeLoop.h"
252
253#ifdef OGS_BUILD_PROCESS_COMPONENTTRANSPORT
256#endif
257#ifdef OGS_BUILD_PROCESS_STEADYSTATEDIFFUSION
259#endif
260#ifdef OGS_BUILD_PROCESS_HT
262#endif
263#ifdef OGS_BUILD_PROCESS_HEATCONDUCTION
265#endif
266#ifdef OGS_BUILD_PROCESS_HEATTRANSPORTBHE
268#endif
269#ifdef OGS_BUILD_PROCESS_WELLBORESIMULATOR
271#endif
272#ifdef OGS_BUILD_PROCESS_HYDROMECHANICS
274#endif
275#ifdef OGS_BUILD_PROCESS_LARGEDEFORMATION
277#endif
278#ifdef OGS_BUILD_PROCESS_LIE_M
280#endif
281#ifdef OGS_BUILD_PROCESS_LIE_HM
283#endif
284#ifdef OGS_BUILD_PROCESS_LIQUIDFLOW
286#endif
287#ifdef OGS_BUILD_PROCESS_THERMORICHARDSMECHANICS
289#endif
290
291#ifdef OGS_BUILD_PROCESS_PHASEFIELD
293#endif
294#ifdef OGS_BUILD_PROCESS_HMPHASEFIELD
296#endif
297#ifdef OGS_BUILD_PROCESS_RICHARDSCOMPONENTTRANSPORT
299#endif
300#ifdef OGS_BUILD_PROCESS_RICHARDSFLOW
302#endif
303#ifdef OGS_BUILD_PROCESS_RICHARDSMECHANICS
305#endif
306#ifdef OGS_BUILD_PROCESS_SMALLDEFORMATION
308#endif
309#ifdef OGS_BUILD_PROCESS_TH2M
311#endif
312#ifdef OGS_BUILD_PROCESS_THERMALTWOPHASEFLOWWITHPP
314#endif
315#ifdef OGS_BUILD_PROCESS_THERMOHYDROMECHANICS
317#endif
318#ifdef OGS_BUILD_PROCESS_THERMOMECHANICS
320#endif
321#ifdef OGS_BUILD_PROCESS_THERMORICHARDSFLOW
323#endif
324#ifdef OGS_BUILD_PROCESS_TWOPHASEFLOWWITHPP
326#endif
327
328namespace
329{
330void readGeometry(std::string const& fname, GeoLib::GEOObjects& geo_objects,
331 std::string const& dir_first, std::string const& dir_second)
332{
333 DBUG("Reading geometry file '{:s}'.", fname);
334 GeoLib::IO::BoostXmlGmlInterface gml_reader(geo_objects);
335 std::string geometry_file = BaseLib::joinPaths(dir_first, fname);
336 if (!BaseLib::IsFileExisting(geometry_file))
337 {
338 // Fallback to reading gml from prj-file directory
339 geometry_file = BaseLib::joinPaths(dir_second, fname);
340 WARN("File {:s} not found in {:s}! Trying reading from {:s}.", fname,
341 dir_first, dir_second);
342 if (!BaseLib::IsFileExisting(geometry_file))
343 {
344 OGS_FATAL("Could not read geometry file {:s} in {:s}.", fname,
345 dir_second);
346 }
347 }
348 gml_reader.readFile(geometry_file);
349}
350
351std::unique_ptr<MeshLib::Mesh> readSingleMesh(
352 BaseLib::ConfigTree const& mesh_config_parameter,
353 std::string const& directory)
354{
355 std::string const mesh_file = BaseLib::joinPaths(
356 directory, mesh_config_parameter.getValue<std::string>());
357 DBUG("Reading mesh file '{:s}'.", mesh_file);
358
359 auto mesh = std::unique_ptr<MeshLib::Mesh>(MeshLib::IO::readMeshFromFile(
360 mesh_file, true /* compute_element_neighbors */));
361 if (!mesh)
362 {
363 std::filesystem::path abspath{mesh_file};
364 try
365 {
366 abspath = std::filesystem::absolute(mesh_file);
367 }
368 catch (std::filesystem::filesystem_error const& e)
369 {
370 ERR("Determining the absolute path of '{}' failed: {}", mesh_file,
371 e.what());
372 }
373
374 OGS_FATAL("Could not read mesh from '{:s}' file. No mesh added.",
375 abspath.string());
376 }
377
378#ifdef DOXYGEN_DOCU_ONLY
380 mesh_config_parameter.getConfigAttributeOptional<bool>("axially_symmetric");
381#endif // DOXYGEN_DOCU_ONLY
382
383 if (auto const axially_symmetric =
385 mesh_config_parameter.getConfigAttributeOptional<bool>(
386 "axially_symmetric"))
387 {
388 mesh->setAxiallySymmetric(*axially_symmetric);
389 if (mesh->getDimension() == 3 && mesh->isAxiallySymmetric())
390 {
391 OGS_FATAL("3D mesh cannot be axially symmetric.");
392 }
393 }
394
395 return mesh;
396}
397
398std::vector<std::unique_ptr<MeshLib::Mesh>> readMeshes(
399 BaseLib::ConfigTree const& config, std::string const& directory)
400{
401 std::vector<std::unique_ptr<MeshLib::Mesh>> meshes;
402
403 GeoLib::GEOObjects geoObjects;
404
406 auto optional_meshes = config.getConfigSubtreeOptional("meshes");
407 if (optional_meshes)
408 {
409 DBUG("Reading multiple meshes.");
411 auto const configs = optional_meshes->getConfigParameterList("mesh");
412 std::transform(configs.begin(), configs.end(),
413 std::back_inserter(meshes),
414 [&directory](auto const& mesh_config)
415 { return readSingleMesh(mesh_config, directory); });
416 if (auto const geometry_file_name =
418 config.getConfigParameterOptional<std::string>("geometry"))
419 {
420 readGeometry(*geometry_file_name, geoObjects, directory,
421 config.projectDirectory().string());
422 }
423 }
424 else
425 { // Read single mesh with geometry.
426 meshes.push_back(
428 readSingleMesh(config.getConfigParameter("mesh"), directory));
429
430 auto const geometry_file_name =
432 config.getConfigParameter<std::string>("geometry");
433 readGeometry(geometry_file_name, geoObjects, directory,
434 config.projectDirectory().string());
435 }
436
437 if (!geoObjects.getPoints().empty() || !geoObjects.getPolylines().empty() ||
438 !geoObjects.getSurfaces().empty())
439 { // generate meshes from geometries
440 std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length_algorithm =
442 bool const multiple_nodes_allowed = false;
443 auto additional_meshes =
445 geoObjects, *meshes[0], std::move(search_length_algorithm),
446 multiple_nodes_allowed);
447
448 std::move(begin(additional_meshes), end(additional_meshes),
449 std::back_inserter(meshes));
450 }
451
452 if (auto const duplicates =
454 !duplicates.empty())
455 {
456 OGS_FATAL("Mesh names aren't unique. Duplicate mesh names are:\n- {}",
457 fmt::join(duplicates, "\n- "));
458 }
459
460 if (
462 config.getConfigParameterOptional<std::vector<int>>(
463 "zero_mesh_field_data_by_material_ids"))
464 {
465 OGS_FATAL(
466 "The project file tag <zero_mesh_field_data_by_material_ids> has "
467 "been removed. Use <overwrite_mesh_data> with a <set> (or "
468 "<take_original>) sub-element and a <material_ids> entry instead.");
469 }
470
472
473 return meshes;
474}
475
476std::vector<GeoLib::NamedRaster> readRasters(
477 BaseLib::ConfigTree const& config,
478 GeoLib::MinMaxPoints const& min_max_points)
479{
480 INFO("readRasters ...");
481 std::vector<GeoLib::NamedRaster> named_rasters;
482
484 auto optional_rasters = config.getConfigSubtreeOptional("rasters");
485 if (optional_rasters)
486 {
488 auto const configs = optional_rasters->getConfigSubtreeList("raster");
489 std::transform(
490 configs.begin(), configs.end(), std::back_inserter(named_rasters),
491 [&min_max_points](auto const& raster_config)
492 { return GeoLib::IO::readRaster(raster_config, min_max_points); });
493 }
494 INFO("readRasters done");
495 return named_rasters;
496}
497
498// for debugging raster reading implementation
499// void writeRasters(std::vector<GeoLib::NamedRaster> const& named_rasters,
500// std::string const& output_directory)
501//{
502// for (auto const& named_raster : named_rasters)
503// {
504// #if defined(USE_PETSC)
505// int my_mpi_rank;
506// MPI_Comm_rank(BaseLib::MPI::OGS_COMM_WORLD, &my_mpi_rank);
507// #endif
508// FileIO::AsciiRasterInterface::writeRasterAsASC(
509// named_raster.raster, output_directory + "/" +
510// named_raster.raster_name +
511// #if defined(USE_PETSC)
512// "_" + std::to_string(my_mpi_rank) +
513// #endif
514// ".asc");
515// }
516//}
517
518} // namespace
519
520ProjectData::ProjectData() = default;
521
523 std::string const& output_directory,
524 std::string const& mesh_directory,
525 [[maybe_unused]] std::string const& script_directory)
526 : _mesh_vec(readMeshes(project_config, mesh_directory)),
527 _named_rasters(readRasters(project_config,
528 GeoLib::AABB(_mesh_vec[0]->getNodes().begin(),
529 _mesh_vec[0]->getNodes().end())
530 .getMinMaxPoints()))
531{
532 // for debugging raster reading implementation
533 // writeRasters(_named_rasters, output_directory);
534 if (auto const python_script =
536 project_config.getConfigParameterOptional<std::string>("python_script"))
537 {
538 namespace py = pybind11;
539
540 // Append to python's module search path
541 auto py_path = py::module::import("sys").attr("path");
542 py_path.attr("append")(script_directory); // .prj or -s directory
543
544 auto const script_path =
545 BaseLib::joinPaths(script_directory, *python_script);
546
547 // Evaluate in scope of main module
548 py::object scope = py::module::import("__main__").attr("__dict__");
549 // add (global) variables
550 auto globals = py::dict(scope);
551 globals["ogs_prj_directory"] =
552 project_config.projectDirectory().string();
553 globals["ogs_mesh_directory"] = mesh_directory;
554 globals["ogs_script_directory"] = script_directory;
555 try
556 {
557 py::eval_file(script_path, scope);
558 }
559 catch (py::error_already_set const& e)
560 {
561 OGS_FATAL("Error evaluating python script {}: {}", script_path,
562 e.what());
563 }
564 }
565
567 parseCurves(project_config.getConfigSubtreeOptional("curves"));
568
569 auto parameter_names_for_transformation =
571 parseParameters(project_config.getConfigSubtree("parameters"));
572
573 _local_coordinate_system = ParameterLib::createCoordinateSystem(
575 project_config.getConfigSubtreeOptional("local_coordinate_system"),
576 _parameters);
577
578 for (auto& parameter : _parameters)
579 {
580 if (std::find(begin(parameter_names_for_transformation),
581 end(parameter_names_for_transformation),
582 parameter->name) !=
583 end(parameter_names_for_transformation))
584 {
585 if (!_local_coordinate_system)
586 {
587 OGS_FATAL(
588 "The parameter '{:s}' is using the local coordinate system "
589 "but no local coordinate system was provided.",
590 parameter->name);
591 }
592 parameter->setCoordinateSystem(*_local_coordinate_system);
593 }
594
595 parameter->initialize(_parameters);
596 }
597 std::vector<MeshToolsLib::InitialConditionDataSet> data_initial_conditions;
598 parseOverwriteMeshData(project_config, data_initial_conditions, _mesh_vec,
599 _parameters);
601
603 parseProcessVariables(project_config.getConfigSubtree("process_variables"));
604
606 parseMedia(project_config.getConfigSubtreeOptional("media"));
607
609 parseLinearSolvers(project_config.getConfigSubtree("linear_solvers"));
610
611 auto chemical_solver_interface = parseChemicalSolverInterface(
613 project_config.getConfigSubtreeOptional("chemical_system"),
614 output_directory);
615
617 parseProcesses(project_config.getConfigSubtree("processes"),
618 output_directory,
619 std::move(chemical_solver_interface));
620
622 parseNonlinearSolvers(project_config.getConfigSubtree("nonlinear_solvers"));
623
625 parseTimeLoop(project_config.getConfigSubtree("time_loop"),
626 output_directory);
627}
628
630 BaseLib::ConfigTree const& process_variables_config)
631{
632 DBUG("Parse process variables:");
633
634 std::set<std::string> names;
635
636 for (auto var_config
638 : process_variables_config.getConfigSubtreeList("process_variable"))
639 {
640 // Either the mesh name is given, or the first mesh's name will be
641 // taken. Taking the first mesh's value is deprecated.
642 auto const mesh_name =
644 var_config.getConfigParameter<std::string>("mesh",
645 _mesh_vec[0]->getName());
646
647 auto& mesh = MeshLib::findMeshByName(_mesh_vec, mesh_name);
648
649 auto pv = ProcessLib::ProcessVariable{var_config, mesh, _mesh_vec,
651 if (!names.insert(pv.getName()).second)
652 {
653 OGS_FATAL("A process variable with name `{:s}' already exists.",
654 pv.getName());
655 }
656
657 _process_variables.push_back(std::move(pv));
658 }
659}
660
661std::vector<std::string> ProjectData::parseParameters(
662 BaseLib::ConfigTree const& parameters_config)
663{
664 using namespace ProcessLib;
665
666 std::set<std::string> names;
667 std::vector<std::string> parameter_names_for_transformation;
668
669 DBUG("Reading parameters:");
670 for (auto parameter_config :
672 parameters_config.getConfigSubtreeList("parameter"))
673 {
674 auto p = ParameterLib::createParameter(parameter_config, _mesh_vec,
676 if (!names.insert(p->name).second)
677 {
678 OGS_FATAL("A parameter with name `{:s}' already exists.", p->name);
679 }
680
681 auto const use_local_coordinate_system =
683 parameter_config.getConfigParameterOptional<bool>(
684 "use_local_coordinate_system");
685 if (!!use_local_coordinate_system && *use_local_coordinate_system)
686 {
687 parameter_names_for_transformation.push_back(p->name);
688 }
689
690 _parameters.push_back(std::move(p));
691 }
692
693 _parameters.push_back(
696 _parameters.push_back(
699
700 return parameter_names_for_transformation;
701}
702
704 std::optional<BaseLib::ConfigTree> const& media_config)
705{
706 if (!media_config)
707 {
708 return;
709 }
710
711 DBUG("Reading media:");
712
713 if (_mesh_vec.empty() || _mesh_vec[0] == nullptr)
714 {
715 ERR("A mesh is required to define medium materials.");
716 return;
717 }
718
719 for (auto const& medium_config :
721 media_config->getConfigSubtreeList("medium"))
722 {
723 auto create_medium = [dim = _mesh_vec[0]->getDimension(),
724 &medium_config, this](int const id)
725 {
727 id, _mesh_vec[0]->getDimension(), medium_config, _parameters,
729 _curves);
730 };
731
732 auto const material_id_string =
734 medium_config.getConfigAttribute<std::string>("id", "0");
735
736 std::vector<int> const material_ids_of_this_medium =
737 MaterialLib::parseMaterialIdString(material_id_string,
738 materialIDs(*_mesh_vec[0]));
739
740 for (auto const& id : material_ids_of_this_medium)
741 {
743 id, _media, material_ids_of_this_medium, create_medium);
744 }
745 }
746
747 if (_media.empty())
748 {
749 OGS_FATAL("No entity is found inside <media>.");
750 }
751}
752
753std::unique_ptr<ChemistryLib::ChemicalSolverInterface>
755 std::optional<BaseLib::ConfigTree> const& config,
756 std::string const& output_directory)
757{
758 if (!config)
759 {
760 return nullptr;
761 }
762
763 std::unique_ptr<ChemistryLib::ChemicalSolverInterface>
764 chemical_solver_interface;
765#ifdef OGS_BUILD_PROCESS_COMPONENTTRANSPORT
766 INFO(
767 "Ready for initializing interface to a chemical solver for water "
768 "chemistry calculation.");
769
770 auto const chemical_solver =
772 config->getConfigAttribute<std::string>("chemical_solver");
773
774 if (boost::iequals(chemical_solver, "Phreeqc"))
775 {
776 INFO(
777 "Configuring phreeqc interface for water chemistry calculation "
778 "using file-based approach.");
779
780 chemical_solver_interface = ChemistryLib::createChemicalSolverInterface<
782 *config, output_directory);
783 }
784 else if (boost::iequals(chemical_solver, "PhreeqcKernel"))
785 {
786 OGS_FATAL(
787 "The chemical solver option of PhreeqcKernel is not accessible for "
788 "the time being. Please set 'Phreeqc'' as the chemical solver for "
789 "reactive transport modeling.");
790 }
791 else if (boost::iequals(chemical_solver, "SelfContained"))
792 {
793 INFO(
794 "Use self-contained chemical solver for water chemistry "
795 "calculation.");
796
797 chemical_solver_interface = ChemistryLib::createChemicalSolverInterface<
799 _mesh_vec, _linear_solvers, *config, output_directory);
800 }
801 else
802 {
803 OGS_FATAL(
804 "Unknown chemical solver. Please specify either Phreeqc or "
805 "PhreeqcKernel as the solver for water chemistry calculation "
806 "instead.");
807 }
808#else
809 (void)output_directory;
810
811 OGS_FATAL(
812 "Found the type of the process to be solved is not component transport "
813 "process. Please specify the process type to ComponentTransport. At "
814 "the present, water chemistry calculation is only available for "
815 "component transport process.");
816#endif
817 return chemical_solver_interface;
818}
819
821 BaseLib::ConfigTree const& processes_config,
822 std::string const& output_directory,
823 [[maybe_unused]] std::unique_ptr<ChemistryLib::ChemicalSolverInterface>&&
824 chemical_solver_interface)
825{
826 (void)output_directory; // to avoid compilation warning
827
828 DBUG("Reading processes:");
830 for (auto process_config : processes_config.getConfigSubtreeList("process"))
831 {
832 auto const type =
834 process_config.peekConfigParameter<std::string>("type");
835
836 auto const name =
838 process_config.getConfigParameter<std::string>("name");
839
840 [[maybe_unused]] auto const integration_order =
842 process_config.getConfigParameter<int>("integration_order");
843
844 std::unique_ptr<ProcessLib::Process> process;
845
846 auto jacobian_assembler = ProcessLib::createJacobianAssembler(
848 process_config.getConfigSubtreeOptional("jacobian_assembler"));
849
850#ifdef OGS_BUILD_PROCESS_STEADYSTATEDIFFUSION
851 if (type == "STEADY_STATE_DIFFUSION")
852 {
853 // The existence check of the in the configuration referenced
854 // process variables is checked in the physical process.
855 // TODO at the moment we have only one mesh, later there can be
856 // several meshes. Then we have to assign the referenced mesh
857 // here.
858 process =
860 name, *_mesh_vec[0], std::move(jacobian_assembler),
861 _process_variables, _parameters, integration_order,
862 process_config, _mesh_vec, _media);
863 }
864 else
865#endif
866#ifdef OGS_BUILD_PROCESS_LIQUIDFLOW
867 if (type == "LIQUID_FLOW")
868 {
870 name, *_mesh_vec[0], std::move(jacobian_assembler),
871 _process_variables, _parameters, integration_order,
872 process_config, _mesh_vec, _media);
873 }
874 else
875#endif
876#ifdef OGS_BUILD_PROCESS_TH2M
877 if (type == "TH2M")
878 {
879 switch (_mesh_vec[0]->getDimension())
880 {
881 case 2:
883 name, *_mesh_vec[0], std::move(jacobian_assembler),
885 _local_coordinate_system, integration_order,
886 process_config, _media);
887 break;
888 case 3:
890 name, *_mesh_vec[0], std::move(jacobian_assembler),
892 _local_coordinate_system, integration_order,
893 process_config, _media);
894 break;
895 default:
896 OGS_FATAL("TH2M process does not support given dimension");
897 }
898 }
899 else
900#endif
901#ifdef OGS_BUILD_PROCESS_HEATCONDUCTION
902 if (type == "HEAT_CONDUCTION")
903 {
905 name, *_mesh_vec[0], std::move(jacobian_assembler),
906 _process_variables, _parameters, integration_order,
907 process_config, _media);
908 }
909 else
910#endif
911#ifdef OGS_BUILD_PROCESS_HEATTRANSPORTBHE
912 if (type == "HEAT_TRANSPORT_BHE")
913 {
914 if (_mesh_vec[0]->getDimension() != 3)
915 {
916 OGS_FATAL(
917 "HEAT_TRANSPORT_BHE can only work with a 3-dimensional "
918 "mesh! ");
919 }
920
921 process =
923 name, *_mesh_vec[0], std::move(jacobian_assembler),
924 _process_variables, _parameters, integration_order,
925 process_config, _curves, _media);
926 }
927 else
928#endif
929#ifdef OGS_BUILD_PROCESS_WELLBORESIMULATOR
930 if (type == "WELLBORE_SIMULATOR")
931 {
932 if (_mesh_vec[0]->getDimension() != 1)
933 {
934 OGS_FATAL(
935 "WELLBORE_SIMULATOR can only work with a 1-dimensional "
936 "mesh!");
937 }
938
939 process =
941 name, *_mesh_vec[0], std::move(jacobian_assembler),
942 _process_variables, _parameters, integration_order,
943 process_config, _media);
944 }
945 else
946#endif
947#ifdef OGS_BUILD_PROCESS_HYDROMECHANICS
948 if (type == "HYDRO_MECHANICS")
949 {
950 if (
951 process_config.getConfigParameterOptional<int>("dimension"))
952 {
953 OGS_FATAL(
954 "The 'dimension' tag has been removed in the merge-request "
955 "!4766. The dimension is now taken from the main mesh and "
956 "the tag must be removed. There is a python script in the "
957 "merge-request description for automatic conversion.");
958 }
959 switch (_mesh_vec[0]->getDimension())
960 {
961 case 2:
962 process =
964 2>(name, *_mesh_vec[0],
965 std::move(jacobian_assembler),
967 _local_coordinate_system, integration_order,
968 process_config, _media);
969 break;
970 case 3:
971 process =
973 3>(name, *_mesh_vec[0],
974 std::move(jacobian_assembler),
976 _local_coordinate_system, integration_order,
977 process_config, _media);
978 break;
979 default:
980 OGS_FATAL(
981 "HYDRO_MECHANICS process does not support given "
982 "dimension");
983 }
984 }
985 else
986#endif
987#ifdef OGS_BUILD_PROCESS_LARGEDEFORMATION
988 if (type == "LARGE_DEFORMATION")
989 {
990 switch (_mesh_vec[0]->getDimension())
991 {
992 case 2:
995 name, *_mesh_vec[0], std::move(jacobian_assembler),
997 _local_coordinate_system, integration_order,
998 process_config, _media);
999 break;
1000 case 3:
1003 name, *_mesh_vec[0], std::move(jacobian_assembler),
1005 _local_coordinate_system, integration_order,
1006 process_config, _media);
1007 break;
1008 default:
1009 OGS_FATAL(
1010 "LARGE_DEFORMATION process does not support given "
1011 "dimension");
1012 }
1013 }
1014 else
1015#endif
1016#ifdef OGS_BUILD_PROCESS_LIE_HM
1017 if (type == "HYDRO_MECHANICS_WITH_LIE")
1018 {
1019 if (
1020 process_config.getConfigParameterOptional<int>("dimension"))
1021 {
1022 OGS_FATAL(
1023 "The 'dimension' tag has been removed in the merge-request "
1024 "!4766."
1025 "The dimension is now taken from the main mesh and the tag "
1026 "must be"
1027 "removed. There is a python script in the merge-request "
1028 "description"
1029 "for automatic conversion.");
1030 }
1031 switch (_mesh_vec[0]->getDimension())
1032 {
1033 case 2:
1036 name, *_mesh_vec[0], std::move(jacobian_assembler),
1038 _local_coordinate_system, integration_order,
1039 process_config, _media);
1040 break;
1041 case 3:
1044 name, *_mesh_vec[0], std::move(jacobian_assembler),
1046 _local_coordinate_system, integration_order,
1047 process_config, _media);
1048 break;
1049 default:
1050 OGS_FATAL(
1051 "HYDRO_MECHANICS_WITH_LIE process does not support "
1052 "given dimension");
1053 }
1054 }
1055 else
1056#endif
1057#ifdef OGS_BUILD_PROCESS_HT
1058 if (type == "HT")
1059 {
1061 name, *_mesh_vec[0], std::move(jacobian_assembler),
1062 _process_variables, _parameters, integration_order,
1063 process_config, _mesh_vec, _media);
1064 }
1065 else
1066#endif
1067#ifdef OGS_BUILD_PROCESS_COMPONENTTRANSPORT
1068 if (type == "ComponentTransport")
1069 {
1070 process =
1072 name, *_mesh_vec[0], std::move(jacobian_assembler),
1073 _process_variables, _parameters, integration_order,
1074 process_config, _mesh_vec, _media,
1075 std::move(chemical_solver_interface));
1076 }
1077 else
1078#endif
1079#ifdef OGS_BUILD_PROCESS_PHASEFIELD
1080 if (type == "PHASE_FIELD")
1081 {
1082 switch (_mesh_vec[0]->getDimension())
1083 {
1084 case 2:
1085 process =
1087 name, *_mesh_vec[0], std::move(jacobian_assembler),
1089 _local_coordinate_system, integration_order,
1090 process_config);
1091 break;
1092 case 3:
1093 process =
1095 name, *_mesh_vec[0], std::move(jacobian_assembler),
1097 _local_coordinate_system, integration_order,
1098 process_config);
1099 break;
1100 }
1101 }
1102 else
1103#endif
1104#ifdef OGS_BUILD_PROCESS_HMPHASEFIELD
1105 if (type == "HM_PHASE_FIELD")
1106 {
1107 switch (_mesh_vec[0]->getDimension())
1108 {
1109 case 2:
1110 process =
1112 name, *_mesh_vec[0], std::move(jacobian_assembler),
1114 _local_coordinate_system, integration_order,
1115 process_config, _media);
1116 break;
1117 case 3:
1118 process =
1120 name, *_mesh_vec[0], std::move(jacobian_assembler),
1122 _local_coordinate_system, integration_order,
1123 process_config, _media);
1124 break;
1125 }
1126 }
1127 else
1128#endif
1129#ifdef OGS_BUILD_PROCESS_RICHARDSCOMPONENTTRANSPORT
1130 if (type == "RichardsComponentTransport")
1131 {
1134 name, *_mesh_vec[0], std::move(jacobian_assembler),
1135 _process_variables, _parameters, integration_order,
1136 process_config, _media);
1137 }
1138 else
1139#endif
1140#ifdef OGS_BUILD_PROCESS_SMALLDEFORMATION
1141 if (type == "SMALL_DEFORMATION")
1142 {
1143 switch (_mesh_vec[0]->getDimension())
1144 {
1145 case 2:
1148 name, *_mesh_vec[0], std::move(jacobian_assembler),
1150 _local_coordinate_system, integration_order,
1151 process_config, _media);
1152 break;
1153 case 3:
1156 name, *_mesh_vec[0], std::move(jacobian_assembler),
1158 _local_coordinate_system, integration_order,
1159 process_config, _media);
1160 break;
1161 default:
1162 OGS_FATAL(
1163 "SMALL_DEFORMATION process does not support given "
1164 "dimension");
1165 }
1166 }
1167 else
1168#endif
1169#ifdef OGS_BUILD_PROCESS_LIE_M
1170 if (type == "SMALL_DEFORMATION_WITH_LIE")
1171 {
1172 if (
1173 process_config.getConfigParameterOptional<int>("dimension"))
1174 {
1175 OGS_FATAL(
1176 "The 'dimension' tag has been removed in the merge-request "
1177 "!4766."
1178 "The dimension is now taken from the main mesh and the tag "
1179 "must be"
1180 "removed. There is a python script in the merge-request "
1181 "description"
1182 "for automatic conversion.");
1183 }
1184 switch (_mesh_vec[0]->getDimension())
1185 {
1186 case 2:
1189 name, *_mesh_vec[0], std::move(jacobian_assembler),
1191 _local_coordinate_system, integration_order,
1192 process_config);
1193 break;
1194 case 3:
1197 name, *_mesh_vec[0], std::move(jacobian_assembler),
1199 _local_coordinate_system, integration_order,
1200 process_config);
1201 break;
1202 default:
1203 OGS_FATAL(
1204 "SMALL_DEFORMATION_WITH_LIE process does not support "
1205 "given dimension");
1206 }
1207 }
1208 else
1209#endif
1210#ifdef OGS_BUILD_PROCESS_THERMOHYDROMECHANICS
1211 if (type == "THERMO_HYDRO_MECHANICS")
1212 {
1213 if (
1214 process_config.getConfigParameterOptional<int>("dimension"))
1215 {
1216 OGS_FATAL(
1217 "The 'dimension' tag has been removed in the merge-request "
1218 "!4766."
1219 "The dimension is now taken from the main mesh and the tag "
1220 "must be"
1221 "removed. There is a python script in the merge-request "
1222 "description"
1223 "for automatic conversion.");
1224 }
1225 switch (_mesh_vec[0]->getDimension())
1226 {
1227 case 2:
1230 name, *_mesh_vec[0], std::move(jacobian_assembler),
1232 _local_coordinate_system, integration_order,
1233 process_config, _media);
1234 break;
1235 case 3:
1238 name, *_mesh_vec[0], std::move(jacobian_assembler),
1240 _local_coordinate_system, integration_order,
1241 process_config, _media);
1242 break;
1243 default:
1244 OGS_FATAL(
1245 "THERMO_HYDRO_MECHANICS process does not support given "
1246 "dimension");
1247 }
1248 }
1249 else
1250#endif
1251#ifdef OGS_BUILD_PROCESS_THERMOMECHANICS
1252 if (type == "THERMO_MECHANICS")
1253 {
1254 switch (_mesh_vec[0]->getDimension())
1255 {
1256 case 2:
1259 name, *_mesh_vec[0], std::move(jacobian_assembler),
1261 _local_coordinate_system, integration_order,
1262 process_config, _media);
1263 break;
1264 case 3:
1267 name, *_mesh_vec[0], std::move(jacobian_assembler),
1269 _local_coordinate_system, integration_order,
1270 process_config, _media);
1271 break;
1272 }
1273 }
1274 else
1275#endif
1276#ifdef OGS_BUILD_PROCESS_RICHARDSFLOW
1277 if (type == "RICHARDS_FLOW")
1278 {
1280 name, *_mesh_vec[0], std::move(jacobian_assembler),
1281 _process_variables, _parameters, integration_order,
1282 process_config, _media);
1283 }
1284 else
1285#endif
1286#ifdef OGS_BUILD_PROCESS_RICHARDSMECHANICS
1287 if (type == "RICHARDS_MECHANICS")
1288 {
1289 if (
1290 process_config.getConfigParameterOptional<int>("dimension"))
1291 {
1292 OGS_FATAL(
1293 "The 'dimension' tag has been removed in the merge-request "
1294 "!4766."
1295 "The dimension is now taken from the main mesh and the tag "
1296 "must be"
1297 "removed. There is a python script in the merge-request "
1298 "description"
1299 "for automatic conversion.");
1300 }
1301 switch (_mesh_vec[0]->getDimension())
1302 {
1303 case 2:
1306 name, *_mesh_vec[0], std::move(jacobian_assembler),
1308 _local_coordinate_system, integration_order,
1309 process_config, _media);
1310 break;
1311 case 3:
1314 name, *_mesh_vec[0], std::move(jacobian_assembler),
1316 _local_coordinate_system, integration_order,
1317 process_config, _media);
1318 break;
1319 }
1320 }
1321 else
1322#endif
1323#ifdef OGS_BUILD_PROCESS_THERMORICHARDSFLOW
1324 if (type == "THERMO_RICHARDS_FLOW")
1325 {
1326 process =
1328 name, *_mesh_vec[0], std::move(jacobian_assembler),
1329 _process_variables, _parameters, integration_order,
1330 process_config, _media);
1331 }
1332 else
1333#endif
1334#ifdef OGS_BUILD_PROCESS_THERMORICHARDSMECHANICS
1335 if (type == "THERMO_RICHARDS_MECHANICS")
1336 {
1337 switch (_mesh_vec[0]->getDimension())
1338 {
1339 case 2:
1342 name, *_mesh_vec[0], std::move(jacobian_assembler),
1344 _local_coordinate_system, integration_order,
1345 process_config, _media);
1346 break;
1347 case 3:
1350 name, *_mesh_vec[0], std::move(jacobian_assembler),
1352 _local_coordinate_system, integration_order,
1353 process_config, _media);
1354 break;
1355 }
1356 }
1357 else
1358#endif
1359
1360#ifdef OGS_BUILD_PROCESS_TWOPHASEFLOWWITHPP
1361 if (type == "TWOPHASE_FLOW_PP")
1362 {
1363 process =
1365 name, *_mesh_vec[0], std::move(jacobian_assembler),
1366 _process_variables, _parameters, integration_order,
1367 process_config, _media);
1368 }
1369 else
1370#endif
1371#ifdef OGS_BUILD_PROCESS_THERMALTWOPHASEFLOWWITHPP
1372 if (type == "THERMAL_TWOPHASE_WITH_PP")
1373 {
1376 name, *_mesh_vec[0], std::move(jacobian_assembler),
1377 _process_variables, _parameters, integration_order,
1378 process_config, _media);
1379 }
1380 else
1381#endif
1382 {
1383 OGS_FATAL("Unknown process type: {:s}", type);
1384 }
1385
1386 if (ranges::contains(_processes, name,
1387 [](std::unique_ptr<ProcessLib::Process> const& p)
1388 { return p->name; }))
1389 {
1390 OGS_FATAL("The process name '{:s}' is not unique.", name);
1391 }
1392 _processes.push_back(std::move(process));
1393 }
1394}
1395
1397 std::string const& output_directory)
1398{
1399 DBUG("Reading time loop configuration.");
1400
1401 bool const compensate_non_equilibrium_initial_residuum = std::any_of(
1402 std::begin(_process_variables),
1403 std::end(_process_variables),
1404 [](auto const& process_variable)
1405 { return process_variable.compensateNonEquilibriumInitialResiduum(); });
1406
1408 config, output_directory, _processes, _nonlinear_solvers, _mesh_vec,
1409 compensate_non_equilibrium_initial_residuum);
1410
1411 if (!_time_loop)
1412 {
1413 OGS_FATAL("Initialization of time loop failed.");
1414 }
1415}
1416
1418{
1419 DBUG("Reading linear solver configuration.");
1420
1422 for (auto conf : config.getConfigSubtreeList("linear_solver"))
1423 {
1425 auto const name = conf.getConfigParameter<std::string>("name");
1426 auto const linear_solver_parser =
1428 auto const solver_options =
1429 linear_solver_parser.parseNameAndOptions("", &conf);
1430
1433 name,
1434 std::make_unique<GlobalLinearSolver>(std::get<0>(solver_options),
1435 std::get<1>(solver_options)),
1436 "The linear solver name is not unique");
1437 }
1438}
1439
1441{
1442 DBUG("Reading non-linear solver configuration.");
1443
1445 for (auto conf : config.getConfigSubtreeList("nonlinear_solver"))
1446 {
1447 auto const ls_name =
1449 conf.getConfigParameter<std::string>("linear_solver");
1450 auto const& linear_solver = BaseLib::getOrError(
1451 _linear_solvers, ls_name,
1452 "A linear solver with the given name does not exist.");
1453
1455 auto const name = conf.getConfigParameter<std::string>("name");
1458 name,
1459 NumLib::createNonlinearSolver(*linear_solver, conf).first,
1460 "The nonlinear solver name is not unique");
1461 }
1462}
1463
1464void ProjectData::parseCurves(std::optional<BaseLib::ConfigTree> const& config)
1465{
1466 if (!config)
1467 {
1468 return;
1469 }
1470
1471 DBUG("Reading curves configuration.");
1472
1474 for (auto conf : config->getConfigSubtreeList("curve"))
1475 {
1477 auto const name = conf.getConfigParameter<std::string>("name");
1479 _curves,
1480 name,
1483 "The curve name is not unique.");
1484 }
1485}
1486
1487MeshLib::Mesh& ProjectData::getMesh(std::string const& mesh_name) const
1488{
1489 return MeshLib::findMeshByName(_mesh_vec, mesh_name);
1490}
1491
1492std::vector<std::string> ProjectData::getMeshNames() const
1493{
1494 return _mesh_vec | MeshLib::views::names | ranges::to<std::vector>;
1495}
Chemical-solver interface used in OGS operator-split reactive transport.
#define OGS_FATAL(...)
Definition Error.h:10
std::vector< std::size_t > getNodes(GeoLib::Point const &pnt, std::vector< MeshLib::Node * > const &nodes, MeshLib::PropertyVector< int > const &mat_ids, std::pair< int, int > const &mat_limits, std::pair< double, double > const &elevation_limits, MeshLib::Mesh const &mesh)
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:34
void parseOverwriteMeshData(BaseLib::ConfigTree const &project_config, std::vector< MeshToolsLib::InitialConditionDataSet > &data_initial_conditions, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters)
std::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
std::filesystem::path projectDirectory() const
std::optional< T > getConfigParameterOptional(std::string const &param) const
T getConfigParameter(std::string const &param) const
Range< SubtreeIterator > getConfigSubtreeList(std::string const &root) const
std::optional< T > getConfigAttributeOptional(std::string const &attr) const
Container class for geometric objects.
Definition GEOObjects.h:46
std::vector< PolylineVec * > const & getPolylines() const
Read access to polylines w/o using a name.
Definition GEOObjects.h:288
std::vector< PointVec * > const & getPoints() const
Read access to points w/o using a name.
Definition GEOObjects.h:286
std::vector< SurfaceVec * > const & getSurfaces() const
Read access to surfaces w/o using a name.
Definition GEOObjects.h:290
bool readFile(const std::string &fname) override
Reads an xml-file containing OGS geometry.
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
void removePropertyVector(std::string_view name)
Definition Properties.cpp:8
static PROCESSLIB_EXPORT const std::string constant_one_parameter_name
Definition Process.h:40
std::map< std::string, std::unique_ptr< GlobalLinearSolver > > _linear_solvers
std::optional< ParameterLib::CoordinateSystem > _local_coordinate_system
std::map< std::string, std::unique_ptr< NumLib::NonlinearSolverBase > > _nonlinear_solvers
MeshLib::Mesh & getMesh(std::string const &mesh_name) const
std::unique_ptr< ChemistryLib::ChemicalSolverInterface > parseChemicalSolverInterface(std::optional< BaseLib::ConfigTree > const &config, const std::string &output_directory)
void parseMedia(std::optional< BaseLib::ConfigTree > const &media_config)
Parses media configuration and saves them in an object.
void parseLinearSolvers(BaseLib::ConfigTree const &config)
void parseProcesses(BaseLib::ConfigTree const &processes_config, std::string const &output_directory, std::unique_ptr< ChemistryLib::ChemicalSolverInterface > &&chemical_solver_interface)
std::vector< std::unique_ptr< ParameterLib::ParameterBase > > _parameters
Buffer for each parameter config passed to the process.
std::vector< std::unique_ptr< ProcessLib::Process > > _processes
std::vector< GeoLib::NamedRaster > _named_rasters
void parseNonlinearSolvers(BaseLib::ConfigTree const &config)
std::vector< ProcessLib::ProcessVariable > _process_variables
void parseProcessVariables(BaseLib::ConfigTree const &process_variables_config)
std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > _curves
void parseCurves(std::optional< BaseLib::ConfigTree > const &config)
std::vector< std::unique_ptr< MeshLib::Mesh > > _mesh_vec
std::vector< std::string > getMeshNames() const
void parseTimeLoop(BaseLib::ConfigTree const &config, const std::string &output_directory)
Parses the time loop configuration.
std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > _media
std::vector< std::string > parseParameters(BaseLib::ConfigTree const &parameters_config)
std::unique_ptr< ProcessLib::TimeLoop > _time_loop
The time loop used to solve this project's processes.
std::vector< std::unique_ptr< MeshLib::Mesh > > readMeshes(std::vector< std::string > const &filenames)
std::vector< ranges::range_value_t< Range > > getDuplicates(Range &&range)
Definition Algorithm.h:178
void insertIfKeyUniqueElseError(Map &map, Key const &key, Value &&value, std::string const &error_message)
Definition Algorithm.h:98
bool IsFileExisting(const std::string &strFilename)
Returns true if given file exists.
Definition FileTools.cpp:23
std::string joinPaths(std::string const &pathA, std::string const &pathB)
OGS_NO_DANGLING Map::mapped_type & getOrError(Map &map, Key const &key, std::string const &error_message)
Definition Algorithm.h:112
std::unique_ptr< ChemicalSolverInterface > createChemicalSolverInterface(std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes, std::map< std::string, std::unique_ptr< GlobalLinearSolver > > const &linear_solvers, BaseLib::ConfigTree const &config, std::string const &output_directory)
std::vector< int > parseMaterialIdString(std::string const &material_id_string, MeshLib::PropertyVector< int > const *const material_ids, char const separator, bool const validate)
void createMediumForId(int const id, std::map< int, std::shared_ptr< T > > &media, std::vector< int > const &material_ids_of_this_medium, CreateMedium &&create_medium)
std::unique_ptr< Medium > createMedium(int const material_id, int const geometry_dimension, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > &parameters, ParameterLib::CoordinateSystem const *const local_coordinate_system, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
std::unique_ptr< CurveType > createPiecewiseLinearCurve(BaseLib::ConfigTree const &config)
std::unique_ptr< MeshGeoToolsLib::SearchLength > createSearchLengthAlgorithm(BaseLib::ConfigTree const &external_config, MeshLib::Mesh const &mesh)
std::vector< std::unique_ptr< MeshLib::Mesh > > constructAdditionalMeshesFromGeoObjects(GeoLib::GEOObjects const &geo_objects, MeshLib::Mesh const &mesh, std::unique_ptr< SearchLength > search_length_algorithm, bool const multiple_nodes_allowed)
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)
constexpr ranges::views::view_closure names
For an element of a range view return its name.
Definition Mesh.h:227
Mesh & findMeshByName(std::vector< std::unique_ptr< Mesh > > const &meshes, std::string_view const name)
Definition Mesh.cpp:356
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition Mesh.cpp:260
void setMeshSpaceDimension(std::vector< std::unique_ptr< Mesh > > const &meshes)
static constexpr char const * toString(const MeshItemType t)
Returns a char array for a specific MeshItemType.
Definition MeshEnums.h:26
MeshItemType string2MeshItemType(const std::string &s)
void overwriteMeshFieldDataByMaterialIDs(std::vector< InitialConditionDataSet > &data_initial_conditions)
std::pair< std::unique_ptr< NonlinearSolverBase >, NonlinearSolverTag > createNonlinearSolver(GlobalLinearSolver &linear_solver, BaseLib::ConfigTree const &config)
std::optional< ParameterLib::CoordinateSystem > createCoordinateSystem(std::optional< BaseLib::ConfigTree > const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters)
std::unique_ptr< ParameterBase > createParameter(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes, std::vector< GeoLib::NamedRaster > const &named_rasters, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
OGS_NO_DANGLING Parameter< ParameterDataType > & findParameter(std::string const &parameter_name, std::vector< std::unique_ptr< ParameterBase > > const &parameters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
std::unique_ptr< Process > createComponentTransportProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media, std::unique_ptr< ChemistryLib::ChemicalSolverInterface > &&chemical_solver_interface)
template std::unique_ptr< Process > createHMPhaseFieldProcess< 3 >(std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createHMPhaseFieldProcess< 2 >(std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createHTProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createHeatConductionProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createHeatTransportBHEProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createHydroMechanicsProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createHydroMechanicsProcess< 2 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createHydroMechanicsProcess< 3 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createSmallDeformationProcess< 2 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
template std::unique_ptr< Process > createSmallDeformationProcess< 3 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
template std::unique_ptr< Process > createLargeDeformationProcess< 2 >(std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createLargeDeformationProcess< 3 >(std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createLiquidFlowProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createPhaseFieldProcess< 2 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
template std::unique_ptr< Process > createPhaseFieldProcess< 3 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config)
std::unique_ptr< Process > createRichardsComponentTransportProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createRichardsFlowProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createRichardsMechanicsProcess< 3 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createRichardsMechanicsProcess< 2 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createSmallDeformationProcess< 3 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createSmallDeformationProcess< 2 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createSteadyStateDiffusion(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createTH2MProcess< 3 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createTH2MProcess< 2 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createThermalTwoPhaseFlowWithPPProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createThermoHydroMechanicsProcess< 2 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createThermoHydroMechanicsProcess< 3 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createThermoMechanicsProcess< 3 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createThermoMechanicsProcess< 2 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createThermoRichardsFlowProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createThermoRichardsMechanicsProcess< 3 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
template std::unique_ptr< Process > createThermoRichardsMechanicsProcess< 2 >(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, std::optional< ParameterLib::CoordinateSystem > const &local_coordinate_system, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createTwoPhaseFlowWithPPProcess(std::string const &name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< Process > createWellboreSimulatorProcess(std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
std::unique_ptr< TimeLoop > createTimeLoop(BaseLib::ConfigTree const &config, std::string const &output_directory, const std::vector< std::unique_ptr< Process > > &processes, const std::map< std::string, std::unique_ptr< NumLib::NonlinearSolverBase > > &nonlinear_solvers, std::vector< std::unique_ptr< MeshLib::Mesh > > &meshes, bool const compensate_non_equilibrium_initial_residuum)
Builds a TimeLoop from the given configuration.
std::unique_ptr< AbstractJacobianAssembler > createJacobianAssembler(std::optional< BaseLib::ConfigTree > const &config)
std::vector< GeoLib::NamedRaster > readRasters(BaseLib::ConfigTree const &config, GeoLib::MinMaxPoints const &min_max_points)
std::vector< std::unique_ptr< MeshLib::Mesh > > readMeshes(BaseLib::ConfigTree const &config, std::string const &directory)
void readGeometry(std::string const &fname, GeoLib::GEOObjects &geo_objects, std::string const &dir_first, std::string const &dir_second)
std::unique_ptr< MeshLib::Mesh > readSingleMesh(BaseLib::ConfigTree const &mesh_config_parameter, std::string const &directory)
Single, constant value parameter.
static PROCESSLIB_EXPORT const std::string zero_parameter_name