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