From 9afdbefd9be9017c5ae013365a6326b8e5db8315 Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <dmitri.naumov@ufz.de>
Date: Thu, 12 Jan 2023 20:51:55 +0100
Subject: [PATCH] [MatL] Stricter solid. const. rel. selection

Multiple constitutive relations and no material ids should not be valid.
---
 .../SolidModels/SelectSolidConstitutiveRelation.h        | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/MaterialLib/SolidModels/SelectSolidConstitutiveRelation.h b/MaterialLib/SolidModels/SelectSolidConstitutiveRelation.h
index 923cd4d7805..b297de434cc 100644
--- a/MaterialLib/SolidModels/SelectSolidConstitutiveRelation.h
+++ b/MaterialLib/SolidModels/SelectSolidConstitutiveRelation.h
@@ -33,6 +33,15 @@ auto& selectSolidConstitutiveRelation(
     MeshLib::PropertyVector<int> const* const material_ids,
     std::size_t const element_id)
 {
+    // Multiple constitutive relations and no material ids should not be valid.
+    if (constitutive_relations.size() > 1 && material_ids == nullptr)
+    {
+        OGS_FATAL(
+            "There are {} constitutive relations provided in the project file "
+            "but no MaterialIDs could be found in the mesh.",
+            constitutive_relations.size());
+    }
+
     int material_id;
     if (constitutive_relations.size() == 1 || material_ids == nullptr)
     {
-- 
GitLab