From 70cdf13d60e47af403b945218075b2ebf9d0d1b4 Mon Sep 17 00:00:00 2001
From: Bernd Flemisch <bernd@iws.uni-stuttgart.de>
Date: Thu, 4 Jan 2018 12:13:06 +0100
Subject: [PATCH] avoid deprecation warnings when using Dune 2.6

Use the `DUNE_VERSION*` macros to distinguish between Dune >= 2.6
and < 2.6. Employ the correspondingly correct types, constructors
and function calls for Mappers and ReferenceElements.
---
 dumux/common/intersectionmapper.hh            | 11 ++++++--
 dumux/discretization/box/boxgeometryhelper.hh | 13 ++++++++++
 dumux/discretization/box/fvelementgeometry.hh |  5 ++++
 dumux/discretization/box/fvgridgeometry.hh    |  8 ++++++
 .../cellcentered/mpfa/fvelementgeometry.hh    |  9 +++++++
 .../cellcentered/mpfa/fvgridgeometry.hh       |  8 ++++++
 .../cellcentered/mpfa/helper.hh               |  4 +++
 .../freeflow/staggeredgeometryhelper.hh       |  4 +++
 .../diffusion/cellcentered/velocity.hh        | 12 ++++++---
 .../diffusion/cellcentered/velocity.hh        |  8 ++++--
 .../diffusion/mimetic/croperator.hh           | 15 +++++++++--
 .../sequential/diffusion/mimetic/pressure.hh  | 12 +++++----
 .../diffusion/mimetic/pressureadaptive.hh     | 12 +++++----
 .../diffusion/mpfa/lmethod/2dpressure.hh      | 16 +++++++++---
 .../mpfa/lmethod/2dpressureadaptive.hh        | 16 +++++++++---
 .../mpfa/lmethod/2dpressurevelocity.hh        |  8 ++++--
 .../lmethod/2dpressurevelocityadaptive.hh     |  8 ++++--
 .../diffusion/mpfa/lmethod/2dvelocity.hh      | 16 ++++++++----
 .../mpfa/lmethod/2dvelocityadaptive.hh        |  3 ---
 .../lmethod/3dinteractionvolumecontainer.hh   | 15 ++++++++---
 .../3dinteractionvolumecontaineradaptive.hh   | 21 +++++++++++++---
 .../diffusion/mpfa/lmethod/3dpressure.hh      |  3 ---
 .../mpfa/lmethod/3dpressureadaptive.hh        |  3 ---
 .../mpfa/lmethod/3dpressurevelocity.hh        |  8 ++++--
 .../lmethod/3dpressurevelocityadaptive.hh     |  3 ---
 .../diffusion/mpfa/lmethod/3dvelocity.hh      |  1 -
 .../mpfa/lmethod/3dvelocityadaptive.hh        |  3 ---
 .../diffusion/mpfa/omethod/2dpressure.hh      | 16 +++++++++---
 .../mpfa/omethod/2dpressurevelocity.hh        |  8 ++++--
 .../diffusion/mpfa/omethod/2dvelocity.hh      | 16 ++++++++----
 .../impes/gridadaptionindicatorlocalflux.hh   | 10 +++++---
 .../2p2c/sequential/fv3dpressureadaptive.hh   |  8 ++++--
 ...fal3dinteractionvolumecontaineradaptive.hh |  3 ---
 dumux/porousmediumflow/velocityoutput.hh      |  5 ++++
 .../1p/sequential/resultevaluation3d.hh       | 25 +++++++++++++++++++
 35 files changed, 255 insertions(+), 81 deletions(-)

diff --git a/dumux/common/intersectionmapper.hh b/dumux/common/intersectionmapper.hh
index 73e87d3140..c04dc57384 100644
--- a/dumux/common/intersectionmapper.hh
+++ b/dumux/common/intersectionmapper.hh
@@ -201,8 +201,15 @@ class IntersectionMapper
 
 public:
     IntersectionMapper(const GridView& gridview)
-    : gridView_(gridview), elementMapper_(gridView_), size_(gridView_.size(1)),
-      intersectionMapGlobal_(gridView_.size(0)), intersectionMapLocal_(gridView_.size(0))
+    : gridView_(gridview)
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    , elementMapper_(gridView_, Dune::mcmgElementLayout())
+#else
+    , elementMapper_(gridView_)
+#endif
+    , size_(gridView_.size(1))
+    , intersectionMapGlobal_(gridView_.size(0))
+    , intersectionMapLocal_(gridView_.size(0))
     {
         const auto element = *gridView_.template begin<0>();
 
diff --git a/dumux/discretization/box/boxgeometryhelper.hh b/dumux/discretization/box/boxgeometryhelper.hh
index 9f97fe0ab6..0f2792ef40 100644
--- a/dumux/discretization/box/boxgeometryhelper.hh
+++ b/dumux/discretization/box/boxgeometryhelper.hh
@@ -25,6 +25,7 @@
 #define DUMUX_DISCRETIZATION_BOX_GEOMETRY_HELPER_HH
 
 #include <array>
+#include <dune/common/version.hh>
 #include <dune/geometry/multilineargeometry.hh>
 #include <dune/geometry/referenceelements.hh>
 
@@ -139,7 +140,11 @@ public:
     : elementGeometry_(geometry), corners_(geometry.corners())
     {
         // extract the corners of the sub control volumes
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        const auto referenceElement = ReferenceElements::general(geometry.type());
+#else
         const auto& referenceElement = ReferenceElements::general(geometry.type());
+#endif
 
         // the element center
         p[0] = geometry.center();
@@ -354,7 +359,11 @@ public:
     : elementGeometry_(geometry), corners_(geometry.corners())
     {
         // extract the corners of the sub control volumes
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        const auto referenceElement = ReferenceElements::general(geometry.type());
+#else
         const auto& referenceElement = ReferenceElements::general(geometry.type());
+#endif
 
         // the element center
         p[0] = geometry.center();
@@ -499,7 +508,11 @@ public:
                                              unsigned int indexInIntersection) const
     {
         // extract the corners of the sub control volumes
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        const auto referenceElement = FaceReferenceElements::general(geometry.type());
+#else
         const auto& referenceElement = FaceReferenceElements::general(geometry.type());
+#endif
 
         GlobalPosition pi[9];
         auto corners = geometry.corners();
diff --git a/dumux/discretization/box/fvelementgeometry.hh b/dumux/discretization/box/fvelementgeometry.hh
index 52f4f93428..e0639746b5 100644
--- a/dumux/discretization/box/fvelementgeometry.hh
+++ b/dumux/discretization/box/fvelementgeometry.hh
@@ -25,6 +25,7 @@
 #ifndef DUMUX_DISCRETIZATION_BOX_FV_ELEMENT_GEOMETRY_HH
 #define DUMUX_DISCRETIZATION_BOX_FV_ELEMENT_GEOMETRY_HH
 
+#include <dune/common/version.hh>
 #include <dune/geometry/referenceelements.hh>
 #include <dune/localfunctions/lagrange/pqkfactory.hh>
 
@@ -278,7 +279,11 @@ private:
 
         // get the element geometry
         auto elementGeometry = element.geometry();
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        const auto referenceElement = ReferenceElements::general(elementGeometry.type());
+#else
         const auto& referenceElement = ReferenceElements::general(elementGeometry.type());
+#endif
 
         // get the sub control volume geometries of this element
         GeometryHelper geometryHelper(elementGeometry);
diff --git a/dumux/discretization/box/fvgridgeometry.hh b/dumux/discretization/box/fvgridgeometry.hh
index 9a33eaa1bd..e3b457bebe 100644
--- a/dumux/discretization/box/fvgridgeometry.hh
+++ b/dumux/discretization/box/fvgridgeometry.hh
@@ -126,7 +126,11 @@ public:
 
             // get the element geometry
             auto elementGeometry = element.geometry();
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+            const auto referenceElement = ReferenceElements::general(elementGeometry.type());
+#else
             const auto& referenceElement = ReferenceElements::general(elementGeometry.type());
+#endif
 
             // instantiate the geometry helper
             GeometryHelper geometryHelper(elementGeometry);
@@ -303,7 +307,11 @@ public:
             numScvf_ += element.subEntities(dim-1);
 
             const auto elementGeometry = element.geometry();
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+            const auto referenceElement = ReferenceElements::general(elementGeometry.type());
+#else
             const auto& referenceElement = ReferenceElements::general(elementGeometry.type());
+#endif
 
             // store the sub control volume face indices on the domain boundary
             for (const auto& intersection : intersections(this->gridView(), element))
diff --git a/dumux/discretization/cellcentered/mpfa/fvelementgeometry.hh b/dumux/discretization/cellcentered/mpfa/fvelementgeometry.hh
index fc4cdb07a1..f3fbca5647 100644
--- a/dumux/discretization/cellcentered/mpfa/fvelementgeometry.hh
+++ b/dumux/discretization/cellcentered/mpfa/fvelementgeometry.hh
@@ -26,6 +26,7 @@
 #ifndef DUMUX_DISCRETIZATION_CCMPFA_FV_ELEMENT_GEOMETRY_HH
 #define DUMUX_DISCRETIZATION_CCMPFA_FV_ELEMENT_GEOMETRY_HH
 
+#include <dune/common/version.hh>
 #include <dune/common/exceptions.hh>
 #include <dune/common/iteratorrange.hh>
 #include <dune/geometry/referenceelements.hh>
@@ -375,7 +376,11 @@ private:
             const auto& e = useNeighbor ? is.outside() : element;
             const auto indexInElement = useNeighbor ? is.indexInOutside() : is.indexInInside();
             const auto eg = e.geometry();
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+            const auto refElement = ReferenceElements::general(eg.type());
+#else
             const auto& refElement = ReferenceElements::general(eg.type());
+#endif
 
             // Set up a container with all relevant positions for scvf corner computation
             const auto numCorners = is.geometry().corners();
@@ -455,7 +460,11 @@ private:
             const auto& e = useNeighbor ? is.outside() : element;
             const auto indexInElement = useNeighbor ? is.indexInOutside() : is.indexInInside();
             const auto eg = e.geometry();
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+            const auto refElement = ReferenceElements::general(eg.type());
+#else
             const auto& refElement = ReferenceElements::general(eg.type());
+#endif
 
             // Set up a container with all relevant positions for scvf corner computation
             const auto numCorners = is.geometry().corners();
diff --git a/dumux/discretization/cellcentered/mpfa/fvgridgeometry.hh b/dumux/discretization/cellcentered/mpfa/fvgridgeometry.hh
index 6570faf63e..c46f7d686f 100644
--- a/dumux/discretization/cellcentered/mpfa/fvgridgeometry.hh
+++ b/dumux/discretization/cellcentered/mpfa/fvgridgeometry.hh
@@ -219,7 +219,11 @@ public:
                 const auto& e = useNeighbor ? is.outside() : element;
                 const auto indexInElement = useNeighbor ? is.indexInOutside() : indexInInside;
                 const auto eg = e.geometry();
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                const auto refElement = ReferenceElements::general(eg.type());
+#else
                 const auto& refElement = ReferenceElements::general(eg.type());
+#endif
 
                 // Set up a container with all relevant positions for scvf corner computation
                 const auto numCorners = is.geometry().corners();
@@ -569,7 +573,11 @@ public:
                 const auto& e = useNeighbor ? is.outside() : element;
                 const auto indexInElement = useNeighbor ? is.indexInOutside() : indexInInside;
                 const auto eg = e.geometry();
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                const auto refElement = ReferenceElements::general(eg.type());
+#else
                 const auto& refElement = ReferenceElements::general(eg.type());
+#endif
 
                 // evaluate if vertices on this intersection use primary/secondary IVs
                 const bool isBranchingPoint = dim < dimWorld ? outsideIndices[indexInInside].size() > 1 : false;
diff --git a/dumux/discretization/cellcentered/mpfa/helper.hh b/dumux/discretization/cellcentered/mpfa/helper.hh
index 9532272f50..a5d6e7fc82 100644
--- a/dumux/discretization/cellcentered/mpfa/helper.hh
+++ b/dumux/discretization/cellcentered/mpfa/helper.hh
@@ -624,7 +624,11 @@ public:
             {
                 if (!is.neighbor() && !is.boundary())
                 {
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                    const auto refElement = ReferenceElements::general(element.geometry().type());
+#else
                     const auto& refElement = ReferenceElements::general(element.geometry().type());
+#endif
                     for (int isVertex = 0; isVertex < is.geometry().corners(); ++isVertex)
                     {
                         const auto vIdxLocal = refElement.subEntity(is.indexInInside(), 1, isVertex, dim);
diff --git a/dumux/discretization/staggered/freeflow/staggeredgeometryhelper.hh b/dumux/discretization/staggered/freeflow/staggeredgeometryhelper.hh
index 891f3e0d5d..72d3f4119f 100644
--- a/dumux/discretization/staggered/freeflow/staggeredgeometryhelper.hh
+++ b/dumux/discretization/staggered/freeflow/staggeredgeometryhelper.hh
@@ -293,7 +293,11 @@ private:
 
     void setPairInfo_(const int isIdx, const Element& element, const bool isParallel)
     {
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        const auto referenceElement = ReferenceElements::general(element_.geometry().type());
+#else
         const auto& referenceElement = ReferenceElements::general(element_.geometry().type());
+#endif
 
         // iterate over facets sub-entities
         for(int i = 0; i < numFacetSubEntities; ++i)
diff --git a/dumux/porousmediumflow/1p/sequential/diffusion/cellcentered/velocity.hh b/dumux/porousmediumflow/1p/sequential/diffusion/cellcentered/velocity.hh
index 7db21b8c1d..e046a33ec4 100644
--- a/dumux/porousmediumflow/1p/sequential/diffusion/cellcentered/velocity.hh
+++ b/dumux/porousmediumflow/1p/sequential/diffusion/cellcentered/velocity.hh
@@ -19,7 +19,8 @@
 #ifndef DUMUX_FVVELOCITY1P_HH
 #define DUMUX_FVVELOCITY1P_HH
 
-#include<dumux/porousmediumflow/1p/sequential/properties.hh>
+#include <dune/common/version.hh>
+#include <dumux/porousmediumflow/1p/sequential/properties.hh>
 
 /*!
  * \file
@@ -123,9 +124,12 @@ public:
             const typename Element::Geometry& geometry = element.geometry();
             // get corresponding reference element
             using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-            const Dune::ReferenceElement< Scalar , dim > & refElement =
-                    ReferenceElements::general( geometry.type() );
-            const int numberOfFaces=refElement.size(1);
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+            const auto refElement = ReferenceElements::general(geometry.type());
+#else
+            const auto& refElement = ReferenceElements::general(geometry.type());
+#endif
+            const int numberOfFaces = refElement.size(1);
 
             std::vector<Scalar> flux(numberOfFaces,0);
 
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/cellcentered/velocity.hh b/dumux/porousmediumflow/2p/sequential/diffusion/cellcentered/velocity.hh
index 3bcd0105b5..620fc97483 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/cellcentered/velocity.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/cellcentered/velocity.hh
@@ -24,6 +24,7 @@
 #ifndef DUMUX_FVVELOCITY2P_HH
 #define DUMUX_FVVELOCITY2P_HH
 
+#include <dune/common/version.hh>
 #include <dune/common/float_cmp.hh>
 #include <dune/grid/common/gridenums.hh>
 #include <dumux/porousmediumflow/2p/sequential/diffusion/properties.hh>
@@ -201,8 +202,11 @@ public:
                 const typename Element::Geometry& geometry = element.geometry();
                 // get corresponding reference element
                 using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-                const Dune::ReferenceElement< Scalar , dim > & refElement =
-                        ReferenceElements::general( geometry.type() );
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                const auto refElement = ReferenceElements::general(geometry.type());
+#else
+                const auto& refElement = ReferenceElements::general(geometry.type());
+#endif
                 const int numberOfFaces=refElement.size(1);
 
                 std::vector<Scalar> fluxW(numberOfFaces,0);
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/croperator.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/croperator.hh
index 6d36ea85be..baa92746d4 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/croperator.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/croperator.hh
@@ -83,7 +83,11 @@ class CROperatorAssemblerTwoP
     using coliterator = typename MatrixType::ColIterator;
     using BCBlockType = std::array<BoundaryConditions::Flags, 1>;     // componentwise boundary conditions
     using SatType = Dune::BlockVector< Dune::FieldVector<double, 1> >;
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    using FaceMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
+#else
     using FaceMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView, FaceLayout>;
+#endif
 
     using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
     enum
@@ -101,8 +105,15 @@ public:
     using RepresentationType = MatrixType;
 
     CROperatorAssemblerTwoP (const GridView& gridview)
-    : gridView_(gridview), faceMapper_(gridView_), size_(faceMapper_.size()),
-      A_(size_, size_, nnz(), RepresentationType::random)
+    : gridView_(gridview)
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    , faceMapper_(gridView_, Dune::mcmgLayout(Dune::Codim<dim - 1>()))
+#else
+    , faceMapper_(gridView_)
+#endif
+    , size_(faceMapper_.size())
+    , A_(size_, size_, nnz()
+    , RepresentationType::random)
     {}
 
     //! initialize the CR operator assembler
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/pressure.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/pressure.hh
index d4fe5f641d..c3ea9d82ed 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/pressure.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/pressure.hh
@@ -24,6 +24,8 @@
 #ifndef DUMUX_MIMETICPRESSURE2P_HH
 #define DUMUX_MIMETICPRESSURE2P_HH
 
+#include <dune/common/version.hh>
+
 // dumux environment
 #include <dumux/porousmediumflow/sequential/mimetic/properties.hh>
 #include <dumux/porousmediumflow/sequential/cellcentered/pressure.hh>
@@ -116,9 +118,6 @@ template<class TypeTag> class MimeticPressure2P
 
     using DimVector = Dune::FieldVector<Scalar, dim>;
 
-    using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
-
     //! initializes the matrix to store the system of equations
     void initializeMatrix();
 
@@ -292,8 +291,11 @@ public:
                 const typename Element::Geometry& geometry = element.geometry();
                 // get corresponding reference element
                 using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-                const Dune::ReferenceElement< Scalar , dim > & refElement =
-                        ReferenceElements::general( geometry.type() );
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                const auto refElement = ReferenceElements::general(geometry.type());
+#else
+                const auto& refElement = ReferenceElements::general(geometry.type());
+#endif
                 const int numberOfFaces=refElement.size(1);
 
                 std::vector<Scalar> fluxW(numberOfFaces,0);
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/pressureadaptive.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/pressureadaptive.hh
index 652e6fb907..55dda8279b 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/pressureadaptive.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mimetic/pressureadaptive.hh
@@ -24,6 +24,8 @@
 #ifndef DUMUX_MIMETICPRESSURE2PADAPTIVE_HH
 #define DUMUX_MIMETICPRESSURE2PADAPTIVE_HH
 
+#include <dune/common/version.hh>
+
 // dumux environment
 #include <dumux/porousmediumflow/sequential/mimetic/properties.hh>
 #include <dumux/porousmediumflow/sequential/cellcentered/pressure.hh>
@@ -117,9 +119,6 @@ template<class TypeTag> class MimeticPressure2PAdaptive
     using Matrix = typename GET_PROP_TYPE(TypeTag, PressureCoefficientMatrix);
     using Vector = typename GET_PROP_TYPE(TypeTag, PressureRHSVector);
 
-    using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
-
     //! initializes the matrix to store the system of equations
     void initializeMatrix();
 
@@ -307,8 +306,11 @@ public:
                 const typename Element::Geometry& geometry = element.geometry();
                 // get corresponding reference element
                 using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-                const Dune::ReferenceElement< Scalar , dim > & refElement =
-                        ReferenceElements::general( geometry.type() );
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                const auto refElement = ReferenceElements::general(geometry.type());
+#else
+                const auto& refElement = ReferenceElements::general(geometry.type());
+#endif
                 const int numberOfFaces=refElement.size(1);
 
                 std::vector<Scalar> fluxW(numberOfFaces,0);
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressure.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressure.hh
index 9809f16218..94707f6f2b 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressure.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressure.hh
@@ -22,6 +22,8 @@
 #ifndef DUMUX_FVMPFAL2DPRESSURE2P_HH
 #define DUMUX_FVMPFAL2DPRESSURE2P_HH
 
+#include <dune/common/version.hh>
+
 // dumux environment
 #include <dumux/porousmediumflow/sequential/cellcentered/pressure.hh>
 #include <dumux/porousmediumflow/sequential/cellcentered/mpfa/linteractionvolume.hh>
@@ -82,7 +84,6 @@ class FvMpfaL2dPressure2p: public FVPressure<TypeTag>
     using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
 
     using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
 
     using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
     using MaterialLaw = typename SpatialParams::MaterialLaw;
@@ -732,7 +733,11 @@ void FvMpfaL2dPressure2p<TypeTag>::storeInteractionVolumeInfo()
 
             // get the intersection node /bar^{x_3} between 'intersection12'
             // and 'intersection14', denoted as 'corner1234'
-            const ReferenceElement& referenceElement = ReferenceElements::general(element.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+            const auto referenceElement = ReferenceElements::general(element.geometry().type());
+#else
+            const auto& referenceElement = ReferenceElements::general(element.geometry().type());
+#endif
 
             GlobalPosition corner1234(0);
 
@@ -1634,8 +1639,11 @@ void FvMpfaL2dPressure2p<TypeTag>::assemble()
                         {
                             int boundaryFaceIdx = interactionVolume.getIndexOnElement(elemIdx, fIdx);
 
-                            const ReferenceElement& referenceElement = ReferenceElements::general(
-                                    element.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                            const auto referenceElement = ReferenceElements::general(element.geometry().type());
+#else
+                            const auto& referenceElement = ReferenceElements::general(element.geometry().type());
+#endif
 
                             const LocalPosition& localPos = referenceElement.position(boundaryFaceIdx, 1);
 
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressureadaptive.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressureadaptive.hh
index f520afc38b..63da4411f6 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressureadaptive.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressureadaptive.hh
@@ -22,6 +22,8 @@
 #ifndef DUMUX_FVMPFAL2DPRESSURE2P_ADAPTIVE_HH
 #define DUMUX_FVMPFAL2DPRESSURE2P_ADAPTIVE_HH
 
+#include <dune/common/version.hh>
+
 // dumux environment
 #include <dumux/porousmediumflow/sequential/cellcentered/pressure.hh>
 #include <dumux/porousmediumflow/sequential/cellcentered/mpfa/linteractionvolume.hh>
@@ -85,7 +87,6 @@ class FvMpfaL2dPressure2pAdaptive: public FVPressure<TypeTag>
     using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
 
     using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
 
     using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
     using MaterialLaw = typename SpatialParams::MaterialLaw;
@@ -777,7 +778,11 @@ void FvMpfaL2dPressure2pAdaptive<TypeTag>::storeInteractionVolumeInfo()
         // get index
         int eIdxGlobal1 = problem_.variables().index(element);
 
-        const ReferenceElement& referenceElement = ReferenceElements::general(element.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        const auto referenceElement = ReferenceElements::general(element.geometry().type());
+#else
+        const auto& referenceElement = ReferenceElements::general(element.geometry().type());
+#endif
 
         const auto isEndIt12 = problem_.gridView().iend(element);
         for (auto isIt12 = problem_.gridView().ibegin(element); isIt12 != isEndIt12; ++isIt12)
@@ -2351,8 +2356,11 @@ void FvMpfaL2dPressure2pAdaptive<TypeTag>::assemble()
                         {
                             int boundaryFaceIdx = interactionVolume.getIndexOnElement(elemIdx, fIdx);
 
-                            const ReferenceElement& referenceElement = ReferenceElements::general(
-                                    element.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                            const auto referenceElement = ReferenceElements::general(element.geometry().type());
+#else
+                            const auto& referenceElement = ReferenceElements::general(element.geometry().type());
+#endif
 
                             const LocalPosition& localPos = referenceElement.position(boundaryFaceIdx, 1);
 
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressurevelocity.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressurevelocity.hh
index ae5d9dfdfa..7b5ce26930 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressurevelocity.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressurevelocity.hh
@@ -22,6 +22,7 @@
 #ifndef DUMUX_MPFAL2DPRESSUREVELOCITY2P_HH
 #define DUMUX_MPFAL2DPRESSUREVELOCITY2P_HH
 
+#include <dune/common/version.hh>
 #include <dune/common/float_cmp.hh>
 
 #include "2dpressure.hh"
@@ -61,7 +62,6 @@ template<class TypeTag> class FvMpfaL2dPressureVelocity2p: public FvMpfaL2dPress
     using PrimaryVariables = typename SolutionTypes::PrimaryVariables;
 
     using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
 
     using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
     using MaterialLaw = typename SpatialParams::MaterialLaw;
@@ -304,7 +304,11 @@ void FvMpfaL2dPressureVelocity2p<TypeTag>::calculateVelocity(const Intersection&
 
     CellData& cellDataJ = problem_.variables().cellData(eIdxGlobalJ);
 
-    const ReferenceElement& referenceElement = ReferenceElements::general(elementI.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    const auto referenceElement = ReferenceElements::general(elementI.geometry().type());
+#else
+    const auto& referenceElement = ReferenceElements::general(elementI.geometry().type());
+#endif
 
     int indexInInside = intersection.indexInInside();
     int indexInOutside = intersection.indexInOutside();
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressurevelocityadaptive.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressurevelocityadaptive.hh
index dd14516011..b9859bd3e1 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressurevelocityadaptive.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dpressurevelocityadaptive.hh
@@ -22,6 +22,7 @@
 #ifndef DUMUX_MPFAL2DPRESSUREVELOCITIES2P_ADAPTIVE_HH
 #define DUMUX_MPFAL2DPRESSUREVELOCITIES2P_ADAPTIVE_HH
 
+#include <dune/common/version.hh>
 #include <dune/common/float_cmp.hh>
 
 #include "2dpressureadaptive.hh"
@@ -63,7 +64,6 @@ template<class TypeTag> class FvMpfaL2dPressureVelocity2pAdaptive: public FvMpfa
     using PrimaryVariables = typename SolutionTypes::PrimaryVariables;
 
     using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
 
     using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
     using MaterialLaw = typename SpatialParams::MaterialLaw;
@@ -342,7 +342,11 @@ void FvMpfaL2dPressureVelocity2pAdaptive<TypeTag>::calculateVelocity(const Inter
 
     CellData& cellDataJ = problem_.variables().cellData(eIdxGlobalJ);
 
-    const ReferenceElement& referenceElement = ReferenceElements::general(elementI.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    const auto referenceElement = ReferenceElements::general(elementI.geometry().type());
+#else
+    const auto& referenceElement = ReferenceElements::general(elementI.geometry().type());
+#endif
 
     int indexInInside = intersection.indexInInside();
     int indexInOutside = intersection.indexInOutside();
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dvelocity.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dvelocity.hh
index acd72b616c..998e88be0b 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dvelocity.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dvelocity.hh
@@ -24,6 +24,7 @@
 #ifndef DUMUX_FVMPFAL2DVELOCITY2P_HH
 #define DUMUX_FVMPFAL2DVELOCITY2P_HH
 
+#include <dune/common/version.hh>
 #include <dune/grid/common/gridenums.hh>
 #include <dumux/porousmediumflow/2p/sequential/diffusion/properties.hh>
 #include <dumux/porousmediumflow/sequential/cellcentered/mpfa/properties.hh>
@@ -66,7 +67,6 @@ template<class TypeTag> class FvMpfaL2dVelocity2p
     using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
 
     using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
 
     using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
     using MaterialLaw = typename SpatialParams::MaterialLaw;
@@ -754,8 +754,11 @@ void FvMpfaL2dVelocity2p<TypeTag>::calculateBoundaryInteractionVolumeVelocity(In
                 {
                     int boundaryFaceIdx = interactionVolume.getIndexOnElement(elemIdx, fIdx);
 
-                    const ReferenceElement& referenceElement = ReferenceElements::general(
-                            element.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                    const auto referenceElement = ReferenceElements::general(element.geometry().type());
+#else
+                    const auto& referenceElement = ReferenceElements::general(element.geometry().type());
+#endif
 
                     const LocalPosition& localPos = referenceElement.position(boundaryFaceIdx, 1);
 
@@ -864,8 +867,11 @@ void FvMpfaL2dVelocity2p<TypeTag>::calculateBoundaryInteractionVolumeVelocity(In
                 {
                     int boundaryFaceIdx = interactionVolume.getIndexOnElement(elemIdx, fIdx);
 
-                    const ReferenceElement& referenceElement = ReferenceElements::general(
-                            element.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                    const auto referenceElement = ReferenceElements::general(element.geometry().type());
+#else
+                    const auto& referenceElement = ReferenceElements::general(element.geometry().type());
+#endif
 
                     const LocalPosition& localPos = referenceElement.position(boundaryFaceIdx, 1);
 
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dvelocityadaptive.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dvelocityadaptive.hh
index 6d2247ab38..90ef25484f 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dvelocityadaptive.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/2dvelocityadaptive.hh
@@ -62,9 +62,6 @@ template<class TypeTag> class FvMpfaL2dVelocity2pAdaptive : public FvMpfaL2dVelo
     using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
     using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
 
-    using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
-
     using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
     using MaterialLaw = typename SpatialParams::MaterialLaw;
 
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dinteractionvolumecontainer.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dinteractionvolumecontainer.hh
index 93496b563a..d075810f44 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dinteractionvolumecontainer.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dinteractionvolumecontainer.hh
@@ -24,6 +24,8 @@
 #ifndef DUMUX_FVMPFAL3D_INTERACTIONVOLUMECONTAINER_HH
 #define DUMUX_FVMPFAL3D_INTERACTIONVOLUMECONTAINER_HH
 
+#include <dune/common/version.hh>
+
 // dumux environment
 #include <dumux/porousmediumflow/sequential/pressureproperties.hh>
 #include <dumux/porousmediumflow/sequential/cellcentered/mpfa/properties.hh>
@@ -61,7 +63,6 @@ class FvMpfaL3dInteractionVolumeContainer
     using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
 
     using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
 
     using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
 
@@ -380,7 +381,11 @@ void FvMpfaL3dInteractionVolumeContainer<TypeTag>::storeIntersectionInfo(const E
 
     const ElementGeometry& geometry = element.geometry();
 
-    const ReferenceElement& referenceElement = ReferenceElements::general(geometry.type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    const auto referenceElement = ReferenceElements::general(geometry.type());
+#else
+    const auto& referenceElement = ReferenceElements::general(geometry.type());
+#endif
 
     int levelI = element.level();
 
@@ -1356,7 +1361,11 @@ void FvMpfaL3dInteractionVolumeContainer<TypeTag>::storeInnerInteractionVolume(I
         const ElementGeometry& geometry1 = element1.geometry();
         const ElementGeometry& geometry8 = element8.geometry();
 
-        const ReferenceElement& referenceElement = ReferenceElements::general(geometry1.type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        const auto referenceElement = ReferenceElements::general(geometry1.type());
+#else
+        const auto& referenceElement = ReferenceElements::general(geometry1.type());
+#endif
 
         DimVector edgeCoord(geometry1.global(referenceElement.position(9, dim - 1)));
         interactionVolume.setEdgePosition(edgeCoord, 2);
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dinteractionvolumecontaineradaptive.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dinteractionvolumecontaineradaptive.hh
index 0691163ebc..7a802f5f19 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dinteractionvolumecontaineradaptive.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dinteractionvolumecontaineradaptive.hh
@@ -24,6 +24,8 @@
 #ifndef DUMUX_FVMPFAL3D_INTERACTIONVOLUMECONTAINER_ADAPTIVE_HH
 #define DUMUX_FVMPFAL3D_INTERACTIONVOLUMECONTAINER_ADAPTIVE_HH
 
+#include <dune/common/version.hh>
+
 // dumux environment
 #include <dumux/porousmediumflow/sequential/pressureproperties.hh>
 #include <dumux/porousmediumflow/sequential/cellcentered/mpfa/properties.hh>
@@ -58,7 +60,6 @@ class FvMpfaL3dInteractionVolumeContainerAdaptive: public FvMpfaL3dInteractionVo
     using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
 
     using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
 
     using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
 
@@ -189,7 +190,11 @@ void FvMpfaL3dInteractionVolumeContainerAdaptive<TypeTag>::storeInnerInteraction
 
             const ElementGeometry& geometry = element.geometry();
 
-            const ReferenceElement& referenceElement = ReferenceElements::general(geometry.type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+            const auto referenceElement = ReferenceElements::general(geometry.type());
+#else
+            const auto& referenceElement = ReferenceElements::general(geometry.type());
+#endif
 
             switch (idx)
             {
@@ -350,7 +355,11 @@ void FvMpfaL3dInteractionVolumeContainerAdaptive<TypeTag>::storeHangingNodeInter
 
         const ElementGeometry& geometry = element.geometry();
 
-        const ReferenceElement& referenceElement = ReferenceElements::general(geometry.type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        const auto referenceElement = ReferenceElements::general(geometry.type());
+#else
+        const auto& referenceElement = ReferenceElements::general(geometry.type());
+#endif
 
         switch (idx)
         {
@@ -1122,7 +1131,11 @@ void FvMpfaL3dInteractionVolumeContainerAdaptive<TypeTag>::storeHangingNodeInter
 
                 const ElementGeometry& geometry = element5.geometry();
 
-                const ReferenceElement& referenceElement = ReferenceElements::general(geometry.type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                const auto referenceElement = ReferenceElements::general(geometry.type());
+#else
+                const auto& referenceElement = ReferenceElements::general(geometry.type());
+#endif
 
                 int oldSubVolumElemIdx = IndexTranslator::getOldElemIdxFromNewFaceIdxto0(zeroFaceIdx, 4);
                 int oldEdgeIdx = IndexTranslator::getOldEdgeIdxFromNewFaceIdxto0(zeroFaceIdx, 1);
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressure.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressure.hh
index aa2b5b0e6f..7ae3e9514a 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressure.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressure.hh
@@ -84,9 +84,6 @@ class FvMpfaL3dPressure2p: public FVPressure<TypeTag>
     using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
     using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
 
-    using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
-
     using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
     using MaterialLaw = typename SpatialParams::MaterialLaw;
 
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressureadaptive.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressureadaptive.hh
index 972d3119f0..38ed04730e 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressureadaptive.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressureadaptive.hh
@@ -88,9 +88,6 @@ class FvMpfaL3dPressure2pAdaptive: public FvMpfaL3dPressure2p<TypeTag>
     using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
     using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
 
-    using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
-
     using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
     using MaterialLaw = typename SpatialParams::MaterialLaw;
 
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressurevelocity.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressurevelocity.hh
index 02100c3a9e..f7b58f2dc8 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressurevelocity.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressurevelocity.hh
@@ -24,6 +24,7 @@
 #ifndef DUMUX_FVMPFAL2PFABOUND3DVELOCITIES2P_HH
 #define DUMUX_FVMPFAL2PFABOUND3DVELOCITIES2P_HH
 
+#include <dune/common/version.hh>
 #include <dune/common/float_cmp.hh>
 #include "3dpressure.hh"
 #include "3dvelocity.hh"
@@ -81,7 +82,6 @@ template<class TypeTag> class FvMpfaL3dPressureVelocity2p: public FvMpfaL3dPress
     using MaterialLaw = typename SpatialParams::MaterialLaw;
 
     using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
 
     using InteractionVolume = typename GET_PROP_TYPE(TypeTag, MPFAInteractionVolume);
     using Intersection = typename GridView::Intersection;
@@ -305,7 +305,11 @@ void FvMpfaL3dPressureVelocity2p<TypeTag>::calculateVelocity(const Intersection&
 
     CellData& cellDataJ = problem_.variables().cellData(eIdxGlobalJ);
 
-    const ReferenceElement& referenceElement = ReferenceElements::general(elementI.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    const auto referenceElement = ReferenceElements::general(elementI.geometry().type());
+#else
+    const auto& referenceElement = ReferenceElements::general(elementI.geometry().type());
+#endif
 
     int indexInInside = intersection.indexInInside();
     int indexInOutside = intersection.indexInOutside();
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressurevelocityadaptive.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressurevelocityadaptive.hh
index a858c74b44..1a57242a98 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressurevelocityadaptive.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dpressurevelocityadaptive.hh
@@ -81,9 +81,6 @@ template<class TypeTag> class FvMpfaL3dPressureVelocity2pAdaptive: public FvMpfa
     using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
     using MaterialLaw = typename SpatialParams::MaterialLaw;
 
-    using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
-
     using InteractionVolume = typename GET_PROP_TYPE(TypeTag, MPFAInteractionVolume);
     using Intersection = typename GridView::Intersection;
 
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dvelocity.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dvelocity.hh
index 31f20732b2..40b12f8204 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dvelocity.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dvelocity.hh
@@ -63,7 +63,6 @@ template<class TypeTag> class FvMpfaL3dVelocity2p
     using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
 
     using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
 
     using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
     using MaterialLaw = typename SpatialParams::MaterialLaw;
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dvelocityadaptive.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dvelocityadaptive.hh
index b262a71b73..345bff3614 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dvelocityadaptive.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/lmethod/3dvelocityadaptive.hh
@@ -64,9 +64,6 @@ template<class TypeTag> class FvMpfaL3dVelocity2pAdaptive: public FvMpfaL3dVeloc
     using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
     using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
 
-    using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
-
     using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
     using MaterialLaw = typename SpatialParams::MaterialLaw;
 
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/omethod/2dpressure.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/omethod/2dpressure.hh
index 82991be6ec..80985a9902 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/omethod/2dpressure.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/omethod/2dpressure.hh
@@ -22,6 +22,8 @@
 #ifndef DUMUX_FVMPFAO2DPRESSURE2P_HH
 #define DUMUX_FVMPFAO2DPRESSURE2P_HH
 
+#include <dune/common/version.hh>
+
 // dumux environment
 #include <dumux/porousmediumflow/sequential/cellcentered/pressure.hh>
 #include <dumux/porousmediumflow/sequential/cellcentered/mpfa/ointeractionvolume.hh>
@@ -78,7 +80,6 @@ class FvMpfaO2dPressure2p: public FVPressure<TypeTag>
     using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
 
     using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
 
     using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
     using MaterialLaw = typename SpatialParams::MaterialLaw;
@@ -730,7 +731,11 @@ void FvMpfaO2dPressure2p<TypeTag>::storeInteractionVolumeInfo()
             // get the intersection node /bar^{x_3} between 'isIt12' and 'isIt14', denoted as 'corner1234'
             // initialization of corner1234
 
-            const ReferenceElement& referenceElement = ReferenceElements::general(element.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+            const auto referenceElement = ReferenceElements::general(element.geometry().type());
+#else
+            const auto& referenceElement = ReferenceElements::general(element.geometry().type());
+#endif
 
             GlobalPosition corner1234(0);
 
@@ -1731,8 +1736,11 @@ void FvMpfaO2dPressure2p<TypeTag>::assemble()
                         {
                             int boundaryFaceIdx = interactionVolume.getIndexOnElement(elemIdx, fIdx);
 
-                            const ReferenceElement& referenceElement = ReferenceElements::general(
-                                    element.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                            const auto referenceElement = ReferenceElements::general(element.geometry().type());
+#else
+                            const auto& referenceElement = ReferenceElements::general(element.geometry().type());
+#endif
 
                             const LocalPosition& localPos = referenceElement.position(boundaryFaceIdx, 1);
 
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/omethod/2dpressurevelocity.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/omethod/2dpressurevelocity.hh
index 1ddea79dd0..f8ac3bb18f 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/omethod/2dpressurevelocity.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/omethod/2dpressurevelocity.hh
@@ -22,6 +22,7 @@
 #ifndef DUMUX_MPFAO2DPRESSUREVELOCITIES2P_HH
 #define DUMUX_MPFAO2DPRESSUREVELOCITIES2P_HH
 
+#include <dune/common/version.hh>
 #include <dune/common/float_cmp.hh>
 #include "2dpressure.hh"
 #include "2dvelocity.hh"
@@ -69,7 +70,6 @@ template<class TypeTag> class FvMpfaO2dPressureVelocity2p: public FvMpfaO2dPress
     using Intersection = typename GridView::Intersection;
 
     using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
 
     using InteractionVolume = FVMPFAOInteractionVolume<TypeTag>;
 
@@ -303,7 +303,11 @@ void FvMpfaO2dPressureVelocity2p<TypeTag>::calculateVelocity(const Intersection&
 
     CellData& cellDataJ = problem_.variables().cellData(eIdxGlobalJ);
 
-    const ReferenceElement& referenceElement = ReferenceElements::general(elementI.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    const auto referenceElement = ReferenceElements::general(elementI.geometry().type());
+#else
+    const auto& referenceElement = ReferenceElements::general(elementI.geometry().type());
+#endif
 
     int indexInInside = intersection.indexInInside();
     int indexInOutside = intersection.indexInOutside();
diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/omethod/2dvelocity.hh b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/omethod/2dvelocity.hh
index eb4cb9a2d6..f36b890bee 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/omethod/2dvelocity.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/mpfa/omethod/2dvelocity.hh
@@ -24,6 +24,7 @@
 #ifndef DUMUX_FVMPFAO2DVELOCITY2P_HH
 #define DUMUX_FVMPFAO2DVELOCITY2P_HH
 
+#include <dune/common/version.hh>
 #include <dune/grid/common/gridenums.hh>
 #include <dumux/porousmediumflow/2p/sequential/diffusion/properties.hh>
 #include <dumux/porousmediumflow/sequential/cellcentered/mpfa/properties.hh>
@@ -65,7 +66,6 @@ template<class TypeTag> class FvMpfaO2dVelocity2P
     using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
 
     using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
 
     using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams);
     using MaterialLaw = typename SpatialParams::MaterialLaw;
@@ -587,8 +587,11 @@ void FvMpfaO2dVelocity2P<TypeTag>::calculateBoundaryInteractionVolumeVelocity(In
                 {
                     int boundaryFaceIdx = interactionVolume.getIndexOnElement(elemIdx, fIdx);
 
-                    const ReferenceElement& referenceElement = ReferenceElements::general(
-                            element.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                    const auto referenceElement = ReferenceElements::general(element.geometry().type());
+#else
+                    const auto& referenceElement = ReferenceElements::general(element.geometry().type());
+#endif
 
                     const LocalPosition& localPos = referenceElement.position(boundaryFaceIdx, 1);
 
@@ -697,8 +700,11 @@ void FvMpfaO2dVelocity2P<TypeTag>::calculateBoundaryInteractionVolumeVelocity(In
                 {
                     int boundaryFaceIdx = interactionVolume.getIndexOnElement(elemIdx, fIdx);
 
-                    const ReferenceElement& referenceElement = ReferenceElements::general(
-                            element.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+                    const auto referenceElement = ReferenceElements::general(element.geometry().type());
+#else
+                    const auto& referenceElement = ReferenceElements::general(element.geometry().type());
+#endif
 
                     const LocalPosition& localPos = referenceElement.position(boundaryFaceIdx, 1);
 
diff --git a/dumux/porousmediumflow/2p/sequential/impes/gridadaptionindicatorlocalflux.hh b/dumux/porousmediumflow/2p/sequential/impes/gridadaptionindicatorlocalflux.hh
index 79d2fa839b..2557018bb9 100644
--- a/dumux/porousmediumflow/2p/sequential/impes/gridadaptionindicatorlocalflux.hh
+++ b/dumux/porousmediumflow/2p/sequential/impes/gridadaptionindicatorlocalflux.hh
@@ -24,6 +24,8 @@
 #ifndef DUMUX_GRIDADAPTIONINDICATOR2PLOCALFLUX_HH
 #define DUMUX_GRIDADAPTIONINDICATOR2PLOCALFLUX_HH
 
+#include <dune/common/version.hh>
+
 #include <dumux/porousmediumflow/sequential/impetproperties.hh>
 #include <dumux/porousmediumflow/2p/sequential/properties.hh>
 
@@ -75,7 +77,6 @@ private:
         numPhases = GET_PROP_VALUE(TypeTag, NumPhases)
     };
 
-    using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
     using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
     using DimVector = Dune::FieldVector<Scalar, dim>;
     using DimMatrix = Dune::FieldMatrix<Scalar, dim, dim>;
@@ -191,8 +192,11 @@ public:
             const typename Element::Geometry& geometry = element.geometry();
             // get corresponding reference element
             using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-            const Dune::ReferenceElement< Scalar , dim > & refElement =
-                    ReferenceElements::general( geometry.type() );
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+            const auto refElement = ReferenceElements::general(geometry.type());
+#else
+            const auto& refElement = ReferenceElements::general(geometry.type());
+#endif
             const int numberOfFaces=refElement.size(1);
 
             std::vector<Scalar> flux(numberOfFaces,0);
diff --git a/dumux/porousmediumflow/2p2c/sequential/fv3dpressureadaptive.hh b/dumux/porousmediumflow/2p2c/sequential/fv3dpressureadaptive.hh
index 4b34485e70..2e3950b630 100644
--- a/dumux/porousmediumflow/2p2c/sequential/fv3dpressureadaptive.hh
+++ b/dumux/porousmediumflow/2p2c/sequential/fv3dpressureadaptive.hh
@@ -20,6 +20,7 @@
 #define DUMUX_FV3DPRESSURE2P2C_ADAPTIVE_HH
 
 // dune environent:
+#include <dune/common/version.hh>
 #include <dune/istl/bvector.hh>
 #include <dune/istl/operators.hh>
 #include <dune/istl/solvers.hh>
@@ -125,7 +126,6 @@ template<class TypeTag> class FV3dPressure2P2CAdaptive
     using Vertex = typename GridView::Traits::template Codim<dim>::Entity;
     using Element = typename GridView::Traits::template Codim<0>::Entity;
     using ReferenceElementContainer = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
 
     using Grid = typename GridView::Grid;
     using Intersection = typename GridView::Intersection;
@@ -1430,7 +1430,11 @@ int FV3dPressure2P2CAdaptive<TypeTag>::computeTransmissibilities(const Intersect
     int localFace24 = face24->indexInInside();
     int localFace26 = face26->indexInInside();
 
-    const ReferenceElement& referenceElement = ReferenceElementContainer::general(neighbor.geometry().type());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    const auto referenceElement = ReferenceElementContainer::general(neighbor.geometry().type());
+#else
+    const auto& referenceElement = ReferenceElementContainer::general(neighbor.geometry().type());
+#endif
     //find 'x'5 = edgeCoord1226
     int edge1226;
     // search through edges of face 12
diff --git a/dumux/porousmediumflow/2p2c/sequential/fvmpfal3dinteractionvolumecontaineradaptive.hh b/dumux/porousmediumflow/2p2c/sequential/fvmpfal3dinteractionvolumecontaineradaptive.hh
index 25813496be..8e6b068b7c 100644
--- a/dumux/porousmediumflow/2p2c/sequential/fvmpfal3dinteractionvolumecontaineradaptive.hh
+++ b/dumux/porousmediumflow/2p2c/sequential/fvmpfal3dinteractionvolumecontaineradaptive.hh
@@ -56,9 +56,6 @@ class FvMpfaL3d2P2CInteractionVolumeContainerAdaptive : public FvMpfaL3dInteract
 
     using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
 
-    using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
-    using ReferenceElement = Dune::ReferenceElement<Scalar, dim>;
-
     using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
 
     using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes);
diff --git a/dumux/porousmediumflow/velocityoutput.hh b/dumux/porousmediumflow/velocityoutput.hh
index a91d33d477..8443c62105 100644
--- a/dumux/porousmediumflow/velocityoutput.hh
+++ b/dumux/porousmediumflow/velocityoutput.hh
@@ -24,6 +24,7 @@
 #ifndef DUMUX_POROUSMEDIUMFLOW_VELOCITYOUTPUT_HH
 #define DUMUX_POROUSMEDIUMFLOW_VELOCITYOUTPUT_HH
 
+#include <dune/common/version.hh>
 #include <dune/common/fvector.hh>
 #include <dune/istl/bvector.hh>
 #include <dune/geometry/referenceelements.hh>
@@ -184,7 +185,11 @@ public:
         }
 
         // get the transposed Jacobian of the element mapping
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        const auto referenceElement = ReferenceElements::general(geomType);
+#else
         const auto& referenceElement = ReferenceElements::general(geomType);
+#endif
         const auto& localPos = referenceElement.position(0, 0);
         const auto jacobianT2 = geometry.jacobianTransposed(localPos);
 
diff --git a/test/porousmediumflow/1p/sequential/resultevaluation3d.hh b/test/porousmediumflow/1p/sequential/resultevaluation3d.hh
index 1595aed2d7..adf46f0b9b 100644
--- a/test/porousmediumflow/1p/sequential/resultevaluation3d.hh
+++ b/test/porousmediumflow/1p/sequential/resultevaluation3d.hh
@@ -86,8 +86,12 @@ public:
         using Geometry = typename Entity::Geometry;
         using GV = typename Grid::LevelGridView;
         using IS = typename GV::IndexSet;
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        using Mapper = Dune::MultipleCodimMultipleGeomTypeMapper<GV>;
+#else
         using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GV, Dune::MCMGElementLayout>;
         using FaceMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GV, FaceLayout>;
+#endif
         using ct = typename Grid::ctype;
 
         enum{dim = Grid::dimension};
@@ -96,8 +100,13 @@ public:
         using ReferenceElements = Dune::ReferenceElements<ct, dim>;
         const GV& gridview(grid.levelGridView(grid.maxLevel()));
         const IS& indexset(gridview.indexSet());
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        Mapper elementMapper(gridview, Dune::mcmgElementLayout());
+        Mapper faceMapper(gridview, Dune::mcmgLayout(Dune::Codim<dim - 1>()));
+#else
         ElementMapper elementMapper(gridview);
         FaceMapper faceMapper(gridview);
+#endif
         SolutionType& exactSol(grid.levelGridView(grid.maxLevel()));
 
         uMean = 0;
@@ -423,12 +432,20 @@ public:
         enum {dim=Grid::dimension};
         using Element = typename Grid::template Codim<0>::Entity;
         using Geometry = typename Element::Geometry;
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
+#else
         using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGElementLayout>;
+#endif
         using SolVector = Dune::BlockVector<Dune::FieldVector<Scalar, 1> >;
         using JacobianInverseTransposed = typename Geometry::JacobianInverseTransposed;
         using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
 
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        ElementMapper elementMapper(gridView, Dune::mcmgElementLayout());
+#else
         ElementMapper elementMapper(gridView);
+#endif
         SolVector exactSol(gridView.size(0));
 
 
@@ -709,11 +726,19 @@ public:
         enum {dim=Grid::dimension, maxIntersections = 12};
         using Element = typename Grid::template Codim<0>::Entity;
         using Geometry = typename Element::Geometry;
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
+#else
         using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGElementLayout>;
+#endif
         using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
         using ReferenceFaces = Dune::ReferenceElements<Scalar, dim-1>;
 
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        ElementMapper elementMapper(gridView, Dune::mcmgElementLayout());
+#else
         ElementMapper elementMapper(gridView);
+#endif
 
         uMinExact = 1e100;
         uMaxExact = -1e100;
-- 
GitLab