From 0acb855f8492c1499cd5dac9a10aa82257b6da94 Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Fri, 1 Jul 2022 23:03:31 +0200
Subject: [PATCH] [box] Reuse geometry traits from the geometry helper

---
 dumux/discretization/box/subcontrolvolume.hh  | 25 ++-------------
 .../box/subcontrolvolumeface.hh               | 27 ++--------------
 .../boxdfm/subcontrolvolume.hh                | 29 +++--------------
 .../boxdfm/subcontrolvolumeface.hh            | 31 +++----------------
 4 files changed, 14 insertions(+), 98 deletions(-)

diff --git a/dumux/discretization/box/subcontrolvolume.hh b/dumux/discretization/box/subcontrolvolume.hh
index 7b4de0db44..f7b8930baf 100644
--- a/dumux/discretization/box/subcontrolvolume.hh
+++ b/dumux/discretization/box/subcontrolvolume.hh
@@ -48,31 +48,12 @@ struct BoxDefaultScvGeometryTraits
     static const int dim = Grid::dimension;
     static const int dimWorld = Grid::dimensionworld;
 
-    template <class ct>
-    struct ScvMLGTraits : public Dune::MultiLinearGeometryTraits<ct>
-    {
-        // we use static vectors to store the corners as we know
-        // the number of corners in advance (2^(dim) corners (1<<(dim))
-        template< int mydim, int cdim >
-        struct CornerStorage
-        {
-            using Type = std::array< Dune::FieldVector< ct, cdim >, (1<<(dim)) >;
-        };
-
-        // we know all scvfs will have the same geometry type
-        template< int mydim >
-        struct hasSingleGeometryType
-        {
-            static const bool v = true;
-            static const unsigned int topologyId = Dune::GeometryTypes::cube(mydim).id();
-        };
-    };
-
     using GridIndexType = typename IndexTraits<GridView>::GridIndex;
     using LocalIndexType = typename IndexTraits<GridView>::LocalIndex;
     using Scalar = typename Grid::ctype;
-    using Geometry = Dune::MultiLinearGeometry<Scalar, dim, dimWorld, ScvMLGTraits<Scalar>>;
-    using CornerStorage = typename ScvMLGTraits<Scalar>::template CornerStorage<dim, dimWorld>::Type;
+    using GeometryTraits = BoxMLGeometryTraits<Scalar>;
+    using Geometry = Dune::MultiLinearGeometry<Scalar, dim, dimWorld, GeometryTraits>;
+    using CornerStorage = typename GeometryTraits::template CornerStorage<dim, dimWorld>::Type;
     using GlobalPosition = typename CornerStorage::value_type;
 };
 
diff --git a/dumux/discretization/box/subcontrolvolumeface.hh b/dumux/discretization/box/subcontrolvolumeface.hh
index 6ca7d2672e..21776f1356 100644
--- a/dumux/discretization/box/subcontrolvolumeface.hh
+++ b/dumux/discretization/box/subcontrolvolumeface.hh
@@ -48,33 +48,12 @@ struct BoxDefaultScvfGeometryTraits
     using Grid = typename GridView::Grid;
     static constexpr int dim = Grid::dimension;
     static constexpr int dimWorld = Grid::dimensionworld;
-
-    // we use geometry traits that use static corner vectors to and a fixed geometry type
-    template <class ct>
-    struct ScvfMLGTraits : public Dune::MultiLinearGeometryTraits<ct>
-    {
-        // we use static vectors to store the corners as we know
-        // the number of corners in advance (2^(dim-1) corners (1<<(dim-1))
-        template< int mydim, int cdim >
-        struct CornerStorage
-        {
-            using Type = std::array< Dune::FieldVector< ct, cdim >, (1<<(dim-1)) >;
-        };
-
-        // we know all scvfs will have the same geometry type
-        template< int mydim >
-        struct hasSingleGeometryType
-        {
-            static const bool v = true;
-            static const unsigned int topologyId = Dune::GeometryTypes::cube(mydim).id();
-        };
-    };
-
     using GridIndexType = typename IndexTraits<GridView>::GridIndex;
     using LocalIndexType = typename IndexTraits<GridView>::LocalIndex;
     using Scalar = typename Grid::ctype;
-    using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, ScvfMLGTraits<Scalar>>;
-    using CornerStorage = typename ScvfMLGTraits<Scalar>::template CornerStorage<dim-1, dimWorld>::Type;
+    using GeometryTraits = BoxMLGeometryTraits<Scalar>;
+    using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, GeometryTraits>;
+    using CornerStorage = typename GeometryTraits::template CornerStorage<dim-1, dimWorld>::Type;
     using GlobalPosition = typename CornerStorage::value_type;
     using BoundaryFlag = Dumux::BoundaryFlag<Grid>;
 };
diff --git a/dumux/porousmediumflow/boxdfm/subcontrolvolume.hh b/dumux/porousmediumflow/boxdfm/subcontrolvolume.hh
index e128f43cd6..ae345314c6 100644
--- a/dumux/porousmediumflow/boxdfm/subcontrolvolume.hh
+++ b/dumux/porousmediumflow/boxdfm/subcontrolvolume.hh
@@ -30,7 +30,7 @@
 #include <dune/geometry/multilineargeometry.hh>
 
 #include <dumux/discretization/subcontrolvolumebase.hh>
-#include <dumux/discretization/box/boxgeometryhelper.hh>
+#include <dumux/porousmediumflow/boxdfm/geometryhelper.hh>
 #include <dumux/common/math.hh>
 
 namespace Dumux {
@@ -52,33 +52,12 @@ struct BoxDfmDefaultScvGeometryTraits
 
     static const int dim = Grid::dimension;
     static const int dimWorld = Grid::dimensionworld;
-
-    template <class ct>
-    struct ScvMLGTraits : public Dune::MultiLinearGeometryTraits<ct>
-    {
-        // we use static vectors to store the corners as we know
-        // the number of corners in advance (2^(dim) corners (1<<(dim))
-        // However, on fracture scvs the number might be smaller (use ReservedVector)
-        template< int mydim, int cdim >
-        struct CornerStorage
-        {
-            using Type = Dune::ReservedVector< Dune::FieldVector< ct, cdim >, (1<<(dim)) >;
-        };
-
-        // we know all scvfs will have the same geometry type
-        template< int mydim >
-        struct hasSingleGeometryType
-        {
-            static const bool v = true;
-            static const unsigned int topologyId = Dune::GeometryTypes::cube(mydim).id();
-        };
-    };
-
     using GridIndexType = typename Grid::LeafGridView::IndexSet::IndexType;
     using LocalIndexType = unsigned int;
     using Scalar = typename Grid::ctype;
-    using Geometry = Dune::MultiLinearGeometry<Scalar, dim, dimWorld, ScvMLGTraits<Scalar>>;
-    using CornerStorage = typename ScvMLGTraits<Scalar>::template CornerStorage<dim, dimWorld>::Type;
+    using GeometryTraits = BoxDfmMLGeometryTraits<Scalar>;
+    using Geometry = Dune::MultiLinearGeometry<Scalar, dim, dimWorld, GeometryTraits>;
+    using CornerStorage = typename GeometryTraits::template CornerStorage<dim, dimWorld>::Type;
     using GlobalPosition = typename CornerStorage::value_type;
 };
 
diff --git a/dumux/porousmediumflow/boxdfm/subcontrolvolumeface.hh b/dumux/porousmediumflow/boxdfm/subcontrolvolumeface.hh
index 75df575ab2..5c0e38cabd 100644
--- a/dumux/porousmediumflow/boxdfm/subcontrolvolumeface.hh
+++ b/dumux/porousmediumflow/boxdfm/subcontrolvolumeface.hh
@@ -29,11 +29,10 @@
 
 #include <dune/geometry/type.hh>
 #include <dune/geometry/multilineargeometry.hh>
-#include <dune/common/reservedvector.hh>
 
 #include <dumux/common/boundaryflag.hh>
 #include <dumux/discretization/subcontrolvolumefacebase.hh>
-#include <dumux/discretization/box/boxgeometryhelper.hh>
+#include <dumux/porousmediumflow/boxdfm/geometryhelper.hh>
 
 namespace Dumux {
 
@@ -53,34 +52,12 @@ struct BoxDfmDefaultScvfGeometryTraits
     using Grid = typename GridView::Grid;
     static constexpr int dim = Grid::dimension;
     static constexpr int dimWorld = Grid::dimensionworld;
-
-    // we use geometry traits that use static corner vectors to and a fixed geometry type
-    template <class ct>
-    struct ScvfMLGTraits : public Dune::MultiLinearGeometryTraits<ct>
-    {
-        // we use static vectors to store the corners as we know
-        // the number of corners in advance (2^(dim-1) corners (1<<(dim-1))
-        // However, on fracture scvs the number might be smaller (use ReservedVector)
-        template< int mydim, int cdim >
-        struct CornerStorage
-        {
-            using Type = Dune::ReservedVector< Dune::FieldVector< ct, cdim >, (1<<(dim-1)) >;
-        };
-
-        // we know all scvfs will have the same geometry type
-        template< int mydim >
-        struct hasSingleGeometryType
-        {
-            static const bool v = true;
-            static const unsigned int topologyId = Dune::GeometryTypes::cube(mydim).id();
-        };
-    };
-
     using GridIndexType = typename Grid::LeafGridView::IndexSet::IndexType;
     using LocalIndexType = unsigned int;
     using Scalar = typename Grid::ctype;
-    using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, ScvfMLGTraits<Scalar>>;
-    using CornerStorage = typename ScvfMLGTraits<Scalar>::template CornerStorage<dim-1, dimWorld>::Type;
+    using GeometryTraits = BoxDfmMLGeometryTraits<Scalar>;
+    using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, GeometryTraits>;
+    using CornerStorage = typename GeometryTraits::template CornerStorage<dim-1, dimWorld>::Type;
     using GlobalPosition = typename CornerStorage::value_type;
     using BoundaryFlag = Dumux::BoundaryFlag<Grid>;
 };
-- 
GitLab