From 83f4485d43de7844463828d7a74d9c5b4f558ab7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= <dennis.glaeser@iws.uni-stuttgart.de>
Date: Thu, 15 Nov 2018 11:33:54 +0100
Subject: [PATCH] [mpfa][iv] make base class implementation-independent

Not providing an overload for a function in the base class within
the interaction volume implementation would have led to an infinite
loop. We now throw if any of the functions are not overloaded.
---
 .../mpfa/interactionvolumebase.hh             | 31 ++++++++-----------
 .../mpfa/omethod/interactionvolume.hh         |  2 +-
 .../mpfa/omethod/staticinteractionvolume.hh   |  2 +-
 3 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/dumux/discretization/cellcentered/mpfa/interactionvolumebase.hh b/dumux/discretization/cellcentered/mpfa/interactionvolumebase.hh
index fc14cadc8a..423c0381ed 100644
--- a/dumux/discretization/cellcentered/mpfa/interactionvolumebase.hh
+++ b/dumux/discretization/cellcentered/mpfa/interactionvolumebase.hh
@@ -59,16 +59,11 @@ namespace Dumux
  * \brief Base class for the interaction volumes of mpfa methods. It defines
  *        the interface and actual implementations should derive from this class.
  *
- * \tparam Impl The actual implementation of the interaction volume
  * \tparam T The traits class to be used
  */
-template< class Impl, class T >
+template< class T >
 class CCMpfaInteractionVolumeBase
 {
-    // Curiously recurring template pattern
-    Impl& asImp() { return static_cast<Impl&>(*this); }
-    const Impl& asImp() const { return static_cast<const Impl&>(*this); }
-
     using GridView = typename T::GridView;
     using Element = typename GridView::template Codim<0>::Entity;
 
@@ -86,50 +81,50 @@ public:
     void setUpLocalScope(const typename Traits::IndexSet& indexSet,
                          const Problem& problem,
                          const FVElementGeometry& fvGeometry)
-    { asImp().setUpLocalScope(); }
+    { DUNE_THROW(Dune::NotImplemented, "Interaction volume does not provide a setUpLocalScope() function"); }
 
     //! returns the number of "primary" scvfs of this interaction volume
     std::size_t numFaces() const
-    { return asImp().numFaces(); }
+    { DUNE_THROW(Dune::NotImplemented, "Interaction volume does not provide a numFaces() function"); }
 
     //! returns the number of intermediate unknowns within this interaction volume
     std::size_t numUnknowns() const
-    { return asImp().numUnknowns(); }
+    { DUNE_THROW(Dune::NotImplemented, "Interaction volume does not provide a numUnknowns() function"); }
 
     //! returns the number of (in this context) known solution values within this interaction volume
     std::size_t numKnowns() const
-    { return asImp().numKnowns(); }
+    { DUNE_THROW(Dune::NotImplemented, "Interaction volume does not provide a numKnowns() function"); }
 
     //! returns the number of scvs embedded in this interaction volume
     std::size_t numScvs() const
-    { return asImp().numScvs(); }
+    { DUNE_THROW(Dune::NotImplemented, "Interaction volume does not provide a numScvs() function"); }
 
     //! Returns a reference to the container with the local face data. The actual type of
     //! the container depends on the interaction volume implementation. At this point we throw
     //! an exception and force the implementation to overload this function.
     const std::vector<typename Traits::LocalFaceData>& localFaceData() const
-    { DUNE_THROW(Dune::NotImplemented, "Interaction volume implementation does not provide a localFaceData() funtion"); }
+    { DUNE_THROW(Dune::NotImplemented, "Interaction volume does not provide a localFaceData() function"); }
 
     //! returns the cell-stencil of this interaction volume
     const NodalStencilType& stencil() const
-    { return asImp().stencil(); }
+    { DUNE_THROW(Dune::NotImplemented, "Interaction volume does not provide a stencil() function"); }
 
     //! returns the local scvf entity corresponding to a given iv-local scvf idx
     const LocalScvfType& localScvf(LocalIndexType ivLocalScvfIdx) const
-    { return asImp().localScvf(ivLocalScvfIdx); }
+    { DUNE_THROW(Dune::NotImplemented, "Interaction volume does not provide a localScvf() function"); }
 
     //! returns the local scv entity corresponding to a given iv-local scv idx
     const LocalScvType& localScv(LocalIndexType ivLocalScvIdx) const
-    { return asImp().localScv(ivLocalScvIdx); }
+    { DUNE_THROW(Dune::NotImplemented, "Interaction volume does not provide a localScv() function"); }
 
     //! returns the element in which the scv with the given local idx is embedded in
     const Element& element(LocalIndexType ivLocalScvIdx) const
-    { return asImp().element(); }
+    { DUNE_THROW(Dune::NotImplemented, "Interaction volume does not provide an element() function"); }
 
     //! returns the number of interaction volumes living around a vertex
     template< class NodalIndexSet >
     static std::size_t numIVAtVertex(const NodalIndexSet& nodalIndexSet)
-    { return Impl::numIVAtVertex(nodalIndexSet); }
+    { DUNE_THROW(Dune::NotImplemented, "Interaction volume does not provide a numIVAtVertex() function"); }
 
     //! adds the iv index sets living around a vertex to a given container
     //! and stores the the corresponding index in a map for each scvf
@@ -141,7 +136,7 @@ public:
                                ScvfIndexMap& scvfIndexMap,
                                const NodalIndexSet& nodalIndexSet,
                                const FlipScvfIndexSet& flipScvfIndexSet)
-    { Impl::addIVIndexSets(ivIndexSetContainer, scvfIndexMap, nodalIndexSet, flipScvfIndexSet); }
+    { DUNE_THROW(Dune::NotImplemented, "Interaction volume does not provide an addIVIndexSets() function"); }
 };
 
 } // end namespace Dumux
diff --git a/dumux/discretization/cellcentered/mpfa/omethod/interactionvolume.hh b/dumux/discretization/cellcentered/mpfa/omethod/interactionvolume.hh
index d5fa3020cf..97c05b84b0 100644
--- a/dumux/discretization/cellcentered/mpfa/omethod/interactionvolume.hh
+++ b/dumux/discretization/cellcentered/mpfa/omethod/interactionvolume.hh
@@ -102,7 +102,7 @@ public:
  */
 template< class Traits >
 class CCMpfaOInteractionVolume
-      : public CCMpfaInteractionVolumeBase< CCMpfaOInteractionVolume<Traits>, Traits >
+: public CCMpfaInteractionVolumeBase< Traits >
 {
     using GridView = typename Traits::GridView;
     using Element = typename GridView::template Codim<0>::Entity;
diff --git a/dumux/discretization/cellcentered/mpfa/omethod/staticinteractionvolume.hh b/dumux/discretization/cellcentered/mpfa/omethod/staticinteractionvolume.hh
index dec48f6ba8..04250ea70b 100644
--- a/dumux/discretization/cellcentered/mpfa/omethod/staticinteractionvolume.hh
+++ b/dumux/discretization/cellcentered/mpfa/omethod/staticinteractionvolume.hh
@@ -111,7 +111,7 @@ public:
  */
 template< class Traits >
 class CCMpfaOStaticInteractionVolume
-      : public CCMpfaInteractionVolumeBase< CCMpfaOStaticInteractionVolume<Traits>, Traits >
+: public CCMpfaInteractionVolumeBase< Traits >
 {
     using GridView = typename Traits::GridView;
     using Element = typename GridView::template Codim<0>::Entity;
-- 
GitLab