OGS
CreateMaterialSpatialDistributionMap.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
5
7#include "MeshLib/Mesh.h"
8
10{
12 std::map<int, std::shared_ptr<Medium>> const& media,
13 MeshLib::Mesh const& mesh)
14{
15 auto const material_ids = materialIDs(mesh);
16
17 int const max_material_id = !material_ids ? 0 : ranges::max(*material_ids);
18
19 if (!material_ids && media.size() > 1)
20 {
22 "More than one porous medium definition (namely {}) is present in "
23 "the project file, but no MaterialIDs are present in the bulk "
24 "mesh.",
25 media.size());
26 }
27
28 if (max_material_id > static_cast<int>(media.size() - 1))
29 {
30 WARN(
31 "The maximum value of MaterialIDs in mesh is {:d}. As the given "
32 "number of porous media definitions in the project file is {:d}, "
33 "the maximum value of MaterialIDs in mesh must be {:d} (index "
34 "starts with zero).",
35 max_material_id, media.size(), max_material_id - 1);
36 }
37
38 if (max_material_id < static_cast<int>(media.size() - 1))
39 {
40 WARN(
41 "There are {:d} porous medium definitions in the project file but "
42 "only {:d} different values in the MaterialIDs vector/data_array "
43 "in the mesh.",
44 media.size(), max_material_id - 1);
45 }
46 return {media, material_ids};
47}
48} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:19
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:34
MaterialSpatialDistributionMap createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium > > const &media, MeshLib::Mesh const &mesh)