From 9b5130a6788833264bf0aa1ee1508a0282937ec2 Mon Sep 17 00:00:00 2001
From: Martin Schneider <martin.schneider@iws.uni-stuttgart.de>
Date: Thu, 16 Mar 2023 16:22:42 +0100
Subject: [PATCH] [disc][geo] Allow to set geometry helper in traits

---
 dumux/discretization/basegridgeometry.hh            |  3 +++
 dumux/discretization/box/fvgridgeometry.hh          | 13 ++++++++++---
 .../facecentered/diamond/fvgridgeometry.hh          | 11 ++++++++++-
 dumux/discretization/pq1bubble/fvgridgeometry.hh    | 13 ++++++++++---
 dumux/multidomain/facet/box/fvgridgeometry.hh       | 11 ++++++++++-
 dumux/porousmediumflow/boxdfm/fvgridgeometry.hh     | 13 ++++++++++---
 6 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/dumux/discretization/basegridgeometry.hh b/dumux/discretization/basegridgeometry.hh
index e6be4b40ac..6032bf8fb8 100644
--- a/dumux/discretization/basegridgeometry.hh
+++ b/dumux/discretization/basegridgeometry.hh
@@ -37,6 +37,9 @@ namespace Dumux {
 namespace Detail {
 template<class T>
 using SpecifiesBaseGridGeometry = typename T::BasicGridGeometry;
+
+template<class T>
+using SpecifiesGeometryHelper = typename T::GeometryHelper;
 } // end namespace Detail
 
 /*!
diff --git a/dumux/discretization/box/fvgridgeometry.hh b/dumux/discretization/box/fvgridgeometry.hh
index c5e89d2884..2ec55d61ac 100644
--- a/dumux/discretization/box/fvgridgeometry.hh
+++ b/dumux/discretization/box/fvgridgeometry.hh
@@ -45,6 +45,15 @@
 
 namespace Dumux {
 
+namespace Detail {
+template<class GV, class T>
+using BoxGeometryHelper_t = Dune::Std::detected_or_t<
+    Dumux::BoxGeometryHelper<GV, GV::dimension, typename T::SubControlVolume, typename T::SubControlVolumeFace>,
+    SpecifiesGeometryHelper,
+    T
+>;
+} // end namespace Detail
+
 /*!
  * \ingroup BoxDiscretization
  * \brief The default traits for the box finite volume grid geometry
@@ -94,9 +103,7 @@ class BoxFVGridGeometry<Scalar, GV, true, Traits>
     static const int dim = GV::dimension;
     static const int dimWorld = GV::dimensionworld;
 
-    using GeometryHelper = BoxGeometryHelper<GV, dim,
-                                             typename Traits::SubControlVolume,
-                                             typename Traits::SubControlVolumeFace>;
+    using GeometryHelper = Detail::BoxGeometryHelper_t<GV, Traits>;
 
 public:
     //! export the discretization method this geometry belongs to
diff --git a/dumux/discretization/facecentered/diamond/fvgridgeometry.hh b/dumux/discretization/facecentered/diamond/fvgridgeometry.hh
index 3cc239b5e4..2acc7c907a 100644
--- a/dumux/discretization/facecentered/diamond/fvgridgeometry.hh
+++ b/dumux/discretization/facecentered/diamond/fvgridgeometry.hh
@@ -48,6 +48,15 @@
 
 namespace Dumux {
 
+namespace Detail {
+template<class GV, class T>
+using FaceCenteredDiamondGeometryHelper_t = Dune::Std::detected_or_t<
+    Dumux::DiamondGeometryHelper<GV, typename T::SubControlVolume, typename T::SubControlVolumeFace>,
+    SpecifiesGeometryHelper,
+    T
+>;
+} // end namespace Detail
+
 /*!
  * \ingroup DiamondDiscretization
  * \brief The default traits for the face-centered diamond finite volume grid geometry
@@ -80,7 +89,7 @@ class FaceCenteredDiamondFVGridGeometry
     using GridIndexType = typename IndexTraits<GV>::GridIndex;
     using LocalIndexType = typename IndexTraits<GV>::SmallLocalIndex;
     using Element = typename GV::template Codim<0>::Entity;
-    using GeometryHelper = DiamondGeometryHelper<GV, typename Traits::SubControlVolume, typename Traits::SubControlVolumeFace>;
+    using GeometryHelper = Detail::FaceCenteredDiamondGeometryHelper_t<GV, Traits>;
 
     using Scalar = typename GV::ctype;
 
diff --git a/dumux/discretization/pq1bubble/fvgridgeometry.hh b/dumux/discretization/pq1bubble/fvgridgeometry.hh
index caeb7a955d..b9fd991d4c 100644
--- a/dumux/discretization/pq1bubble/fvgridgeometry.hh
+++ b/dumux/discretization/pq1bubble/fvgridgeometry.hh
@@ -49,6 +49,15 @@
 
 namespace Dumux {
 
+namespace Detail {
+template<class GV, class T>
+using PQ1BubbleGeometryHelper_t = Dune::Std::detected_or_t<
+    Dumux::PQ1BubbleGeometryHelper<GV, typename T::SubControlVolume, typename T::SubControlVolumeFace>,
+    SpecifiesGeometryHelper,
+    T
+>;
+} // end namespace Detail
+
 template <class GridView>
 struct PQ1BubbleMapperTraits :public DefaultMapperTraits<GridView>
 {
@@ -106,9 +115,7 @@ class PQ1BubbleFVGridGeometry
     static const int dim = GV::dimension;
     static const int dimWorld = GV::dimensionworld;
 
-    using GeometryHelper = PQ1BubbleGeometryHelper<
-        GV, typename Traits::SubControlVolume, typename Traits::SubControlVolumeFace
-    >;
+    using GeometryHelper = Detail::PQ1BubbleGeometryHelper_t<GV, Traits>;
 
     static_assert(dim > 1, "Only implemented for dim > 1");
 
diff --git a/dumux/multidomain/facet/box/fvgridgeometry.hh b/dumux/multidomain/facet/box/fvgridgeometry.hh
index ea58484d8a..6716d1399b 100644
--- a/dumux/multidomain/facet/box/fvgridgeometry.hh
+++ b/dumux/multidomain/facet/box/fvgridgeometry.hh
@@ -46,6 +46,15 @@
 
 namespace Dumux {
 
+namespace Detail {
+template<class GV, class T>
+using BoxFacetCouplingGeometryHelper_t = Dune::Std::detected_or_t<
+    Dumux::BoxGeometryHelper<GV, GV::dimension, typename T::SubControlVolume, typename T::SubControlVolumeFace>,
+    SpecifiesGeometryHelper,
+    T
+>;
+} // end namespace Detail
+
 /*!
  * \ingroup FacetCoupling
  * \brief The default traits for the finite volume grid geometry
@@ -105,7 +114,7 @@ class BoxFacetCouplingFVGridGeometry<Scalar, GV, true, Traits>
     static const int dim = GV::dimension;
     static const int dimWorld = GV::dimensionworld;
 
-    using GeometryHelper = BoxGeometryHelper<GV, dim, typename Traits::SubControlVolume, typename Traits::SubControlVolumeFace>;
+    using GeometryHelper = Detail::BoxFacetCouplingGeometryHelper_t<GV, Traits>;
 
 public:
     //! export the discretization method this geometry belongs to
diff --git a/dumux/porousmediumflow/boxdfm/fvgridgeometry.hh b/dumux/porousmediumflow/boxdfm/fvgridgeometry.hh
index fc4f28f6b1..b7f6489386 100644
--- a/dumux/porousmediumflow/boxdfm/fvgridgeometry.hh
+++ b/dumux/porousmediumflow/boxdfm/fvgridgeometry.hh
@@ -49,6 +49,15 @@
 
 namespace Dumux {
 
+namespace Detail {
+template<class GV, class T>
+using BoxDfmGeometryHelper_t = Dune::Std::detected_or_t<
+    Dumux::BoxDfmGeometryHelper<GV, GV::dimension, typename T::SubControlVolume, typename T::SubControlVolumeFace>,
+    SpecifiesGeometryHelper,
+    T
+>;
+} // end namespace Detail
+
 /*!
  * \ingroup BoxDFMModel
  * \brief The default traits for the box finite volume grid geometry
@@ -109,9 +118,7 @@ class BoxDfmFVGridGeometry<Scalar, GV, true, Traits>
     static const int dimWorld = GV::dimensionworld;
     static_assert(dim == 2 || dim == 3, "The box-dfm GridGeometry is only implemented in 2 or 3 dimensions.");
 
-    using GeometryHelper = BoxDfmGeometryHelper<GV, dim,
-                                                typename Traits::SubControlVolume,
-                                                typename Traits::SubControlVolumeFace>;
+    using GeometryHelper = Detail::BoxDfmGeometryHelper_t<GV, Traits>;
 
 public:
     //! export the discretization method this geometry belongs to
-- 
GitLab