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