OGS
CreatePorousMediaProperties.cpp
Go to the documentation of this file.
1
12
13#include "BaseLib/Algorithm.h"
14#include "BaseLib/ConfigTree.h"
15#include "MeshLib/Mesh.h"
17#include "Porosity/createPorosityModel.h"
18#include "Storage/createStorageModel.h"
19
20namespace MaterialLib
21{
22namespace PorousMedium
23{
25 MeshLib::Mesh& mesh, BaseLib::ConfigTree const& configs,
26 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
27{
28 DBUG("Create PorousMediaProperties.");
29
30 auto const& porous_medium_configs =
32 configs.getConfigSubtree("porous_medium");
33
34 std::vector<std::unique_ptr<MaterialLib::PorousMedium::Permeability>>
35 intrinsic_permeability_models;
36 std::vector<std::unique_ptr<MaterialLib::PorousMedium::Porosity>>
37 porosity_models;
38 std::vector<std::unique_ptr<MaterialLib::PorousMedium::Storage>>
39 storage_models;
40
41 std::vector<int> mat_ids;
42 for (auto const& porous_medium_config :
44 porous_medium_configs.getConfigSubtreeList("porous_medium"))
45 {
47 auto const id = porous_medium_config.getConfigAttribute<int>("id");
48 mat_ids.push_back(id);
49
50 auto const& porosity_config =
52 porous_medium_config.getConfigSubtree("porosity");
53 porosity_models.emplace_back(
54 MaterialLib::PorousMedium::createPorosityModel(porosity_config,
55 parameters));
56
57 // Configuration for the intrinsic permeability (only one scalar per
58 // element, i.e., the isotropic case is handled at the moment)
59 auto const& permeability_config =
61 porous_medium_config.getConfigSubtree("permeability");
62 intrinsic_permeability_models.emplace_back(
64 permeability_config, parameters));
65
66 // Configuration for the specific storage.
67 auto const& storage_config =
69 porous_medium_config.getConfigSubtree("storage");
70 storage_models.emplace_back(
71 MaterialLib::PorousMedium::createStorageModel(storage_config));
72 }
73
74 BaseLib::reorderVector(intrinsic_permeability_models, mat_ids);
75 BaseLib::reorderVector(porosity_models, mat_ids);
76 BaseLib::reorderVector(storage_models, mat_ids);
77
78 auto const material_ids = materialIDs(mesh);
79 int const max_material_id =
80 !material_ids
81 ? 0
82 : *std::max_element(begin(*material_ids), end(*material_ids));
83
84 if (!material_ids && mat_ids.size() > 1)
85 {
87 "More than one porous medium definition (namely {}) is present in "
88 "the project file, but no MaterialIDs are present in the bulk "
89 "mesh.",
90 mat_ids.size());
91 }
92
93 if (max_material_id > static_cast<int>(mat_ids.size() - 1))
94 {
96 "The maximum value of MaterialIDs in mesh is {:d}. As the "
97 "given number of porous media definitions in the project file is "
98 "{:d}, the maximum value of MaterialIDs in mesh must be {:d} "
99 "(index starts with zero).",
100 max_material_id, mat_ids.size(), max_material_id - 1);
101 }
102
103 if (max_material_id < static_cast<int>(mat_ids.size() - 1))
104 WARN(
105 "There are {:d} porous medium definitions in the project file but "
106 "only {:d} different values in the MaterialIDs vector/data_array "
107 "in the mesh.",
108 mat_ids.size(), max_material_id - 1);
109
110 if (mat_ids.back() != static_cast<int>(mat_ids.size()) - 1)
111 {
112 OGS_FATAL(
113 "The ids in the porous media definitions in the project file have "
114 "to be sequential, starting with the id zero.");
115 }
116
117 return PorousMediaProperties{std::move(porosity_models),
118 std::move(intrinsic_permeability_models),
119 std::move(storage_models), material_ids};
120}
121
122} // namespace PorousMedium
123} // namespace MaterialLib
#define OGS_FATAL(...)
Definition Error.h:26
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
Definition of the Mesh class.
T getConfigAttribute(std::string const &attr) const
ConfigTree getConfigSubtree(std::string const &root) const
void reorderVector(std::vector< ValueType > &v, std::vector< IndexType > const &order)
Definition Algorithm.h:198
std::unique_ptr< Permeability > createPermeabilityModel(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters)
PorousMediaProperties createPorousMediaProperties(MeshLib::Mesh &mesh, BaseLib::ConfigTree const &configs, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters)