From e384a8caacf6880bcb901a97f4e35025f3c8e9c9 Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Sat, 16 Oct 2021 15:27:32 +0200
Subject: [PATCH] [navierstokes] Make coupling manager accessible from the
 problem

---
 dumux/freeflow/navierstokes/problem.hh | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/dumux/freeflow/navierstokes/problem.hh b/dumux/freeflow/navierstokes/problem.hh
index 58c479254f..da18f9bfa9 100644
--- a/dumux/freeflow/navierstokes/problem.hh
+++ b/dumux/freeflow/navierstokes/problem.hh
@@ -536,6 +536,15 @@ public:
         return orientation;
     }
 
+    const CouplingManager& couplingManager() const
+    {
+        if constexpr (isCoupled_)
+            return *couplingManager_;
+        else
+            DUNE_THROW(Dune::InvalidStateException,
+                "Accessing coupling manager of an uncoupled problem is not possible."
+            );
+    }
 
 private:
     //! Returns a scalar permeability value at the coupling interface
@@ -675,9 +684,15 @@ public:
         DUNE_THROW(Dune::NotImplemented, "temperature() method not implemented by the actual problem");
     }
 
-protected:
     const CouplingManager& couplingManager() const
-    { return *couplingManager_; }
+    {
+        if constexpr (isCoupled_)
+            return *couplingManager_;
+        else
+            DUNE_THROW(Dune::InvalidStateException,
+                "Accessing coupling manager of an uncoupled problem is not possible."
+            );
+    }
 
 private:
     //! Returns the implementation of the problem (i.e. static polymorphism)
-- 
GitLab