Skip to content
Snippets Groups Projects
Commit 57379fd8 authored by Tom Fischer's avatar Tom Fischer
Browse files

[Material] Check if max of MaterialIDs corresponds to number of porous media definitions.

parent 1a2835b0
No related branches found
No related tags found
No related merge requests found
...@@ -86,6 +86,28 @@ PorousMediaProperties createPorousMediaProperties( ...@@ -86,6 +86,28 @@ PorousMediaProperties createPorousMediaProperties(
std::copy(mesh_material_ids->cbegin(), mesh_material_ids->cend(), std::copy(mesh_material_ids->cbegin(), mesh_material_ids->cend(),
material_ids.begin()); material_ids.begin());
} }
int const max_material_id =
*std::max_element(material_ids.cbegin(), material_ids.cend());
if (max_material_id > mat_ids.size() - 1)
OGS_FATAL(
"The maximum value of MaterialIDs in mesh is %d. As the "
"given number of porous media definitions in the project "
"file is %d, the maximum value of MaterialIDs in mesh must be %d "
"(index starts with zero).",
max_material_id, mat_ids.size(), max_material_id - 1);
if (max_material_id < mat_ids.size() - 1)
WARN(
"There are %d porous medium definitions in the project file but "
"only %d different values in the MaterialIDs vector/data_array in "
"the mesh.",
mat_ids.size(), max_material_id - 1);
if (mat_ids.back() != static_cast<int>(mat_ids.size()) - 1)
OGS_FATAL(
"The ids in the porous media definitions in the project file have "
"to be sequential, starting with the id zero.");
return PorousMediaProperties{std::move(porosity_models), return PorousMediaProperties{std::move(porosity_models),
std::move(intrinsic_permeability_models), std::move(intrinsic_permeability_models),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment