OGS
CreateMaterialSpatialDistributionMap.cpp
Go to the documentation of this file.
1 
12 
14 #include "MeshLib/Mesh.h"
15 
16 namespace MaterialPropertyLib
17 {
18 std::unique_ptr<MaterialSpatialDistributionMap>
20  std::map<int, std::shared_ptr<Medium>> const& media,
21  MeshLib::Mesh const& mesh)
22 {
23  auto const material_ids = materialIDs(mesh);
24 
25  int const max_material_id =
26  !material_ids
27  ? 0
28  : *std::max_element(begin(*material_ids), end(*material_ids));
29 
30  if (max_material_id > static_cast<int>(media.size() - 1))
31  {
32  WARN(
33  "The maximum value of MaterialIDs in mesh is {:d}. As the given "
34  "number of porous media definitions in the project file is {:d}, "
35  "the maximum value of MaterialIDs in mesh must be {:d} (index "
36  "starts with zero).",
37  max_material_id, media.size(), max_material_id - 1);
38  }
39 
40  if (max_material_id < static_cast<int>(media.size() - 1))
41  {
42  WARN(
43  "There are {:d} porous medium definitions in the project file but "
44  "only {:d} different values in the MaterialIDs vector/data_array "
45  "in the mesh.",
46  media.size(), max_material_id - 1);
47  }
48  return std::make_unique<MaterialSpatialDistributionMap>(media,
49  material_ids);
50 }
51 } // namespace MaterialPropertyLib
void WARN(char const *fmt, Args const &... args)
Definition: Logging.h:37
Definition of the Mesh class.
std::unique_ptr< MaterialSpatialDistributionMap > createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium >> const &media, MeshLib::Mesh const &mesh)
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:258