From 81e6f26f168da9d8b1b508a46aaee5c279820303 Mon Sep 17 00:00:00 2001
From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de>
Date: Wed, 26 Jul 2017 15:36:56 +0200
Subject: [PATCH] Fix deprecation warning for Dune MCMG Mapper

* Dune > 2.5 uses a new interface and only required GridView as template
  argument for the mapper type
* for the constructor, an additional argument is now required:
  elementMapper_(gridView, Dune::mcmgElementLayout())
  vertexMapper_(gridView, Dune::mcmgVertexLayout())

(cherry picked from commit 6b4dc071dd4e23f02b3605a109b8d1c73ef04c7e)
---
 dumux/common/intersectionmapper.hh                |  8 +++++++-
 dumux/implicit/problem.hh                         |  8 ++++++++
 dumux/implicit/propertydefaults.hh                | 15 +++++++++++++++
 dumux/io/vtkmultiwriter.hh                        | 12 ++++++++++++
 dumux/material/spatialparams/gstatrandomfield.hh  | 13 ++++++++++++-
 dumux/porousmediumflow/sequential/properties.hh   | 10 ++++++++++
 .../porousmediumflow/sequential/variableclass.hh  | 12 ++++++++++--
 test/geomechanics/el2p/el2pproblem.hh             | 11 ++++++++++-
 8 files changed, 84 insertions(+), 5 deletions(-)

diff --git a/dumux/common/intersectionmapper.hh b/dumux/common/intersectionmapper.hh
index dcee8ab505..fadbd0422f 100644
--- a/dumux/common/intersectionmapper.hh
+++ b/dumux/common/intersectionmapper.hh
@@ -24,6 +24,8 @@
 #include <dune/grid/common/mcmgmapper.hh>
 #include <dune/grid/common/rangegenerators.hh>
 
+#include <dune/common/version.hh>
+
 /*!
  * \file
  * \brief defines an intersection mapper for mapping of global DOFs assigned
@@ -44,7 +46,11 @@ class IntersectionMapper
     enum {dim=Grid::dimension};
     typedef typename Grid::template Codim<0>::Entity Element;
     typedef typename GridView::Intersection Intersection;
-    typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGElementLayout> ElementMapper;
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
+#else
+    using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGElementLayout>;
+#endif
 
 public:
     IntersectionMapper(const GridView& gridview)
diff --git a/dumux/implicit/problem.hh b/dumux/implicit/problem.hh
index 81e9c32659..d940ba1e14 100644
--- a/dumux/implicit/problem.hh
+++ b/dumux/implicit/problem.hh
@@ -30,6 +30,8 @@
 #include <dumux/implicit/adaptive/gridadapt.hh>
 #include <dumux/common/boundingboxtree.hh>
 
+#include <dune/common/version.hh>
+
 namespace Dumux
 {
 /*!
@@ -103,11 +105,17 @@ public:
         : gridView_(gridView)
         , bBoxMin_(std::numeric_limits<double>::max())
         , bBoxMax_(-std::numeric_limits<double>::max())
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        , elementMapper_(gridView, Dune::mcmgElementLayout())
+        , vertexMapper_(gridView, Dune::mcmgVertexLayout())
+#else
         , elementMapper_(gridView)
         , vertexMapper_(gridView)
+#endif
         , timeManager_(&timeManager)
         , newtonMethod_(asImp_())
         , newtonCtl_(asImp_())
+
     {
         // calculate the bounding box of the local partition of the grid view
         for (const auto& vertex : vertices(gridView)) {
diff --git a/dumux/implicit/propertydefaults.hh b/dumux/implicit/propertydefaults.hh
index 8cc5e846ac..b83e553f49 100644
--- a/dumux/implicit/propertydefaults.hh
+++ b/dumux/implicit/propertydefaults.hh
@@ -41,6 +41,8 @@
 #include "localjacobian.hh"
 #include "volumevariables.hh"
 
+#include <dune/common/version.hh>
+
 namespace Dumux {
 
 // forward declarations
@@ -71,16 +73,29 @@ SET_TYPE_PROP(ImplicitBase, NewtonMethod, NewtonMethod<TypeTag>);
 SET_TYPE_PROP(ImplicitBase, NewtonController, NewtonController<TypeTag>);
 
 //! Mapper for the grid view's vertices.
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+SET_TYPE_PROP(ImplicitBase,
+              VertexMapper,
+              Dune::MultipleCodimMultipleGeomTypeMapper<typename GET_PROP_TYPE(TypeTag, GridView)>);
+#else
 SET_TYPE_PROP(ImplicitBase,
               VertexMapper,
               Dune::MultipleCodimMultipleGeomTypeMapper<typename GET_PROP_TYPE(TypeTag, GridView),
                                                         Dune::MCMGVertexLayout>);
+#endif
+
 
 //! Mapper for the grid view's elements.
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+SET_TYPE_PROP(ImplicitBase,
+              ElementMapper,
+              Dune::MultipleCodimMultipleGeomTypeMapper<typename GET_PROP_TYPE(TypeTag, GridView)>);
+#else
 SET_TYPE_PROP(ImplicitBase,
               ElementMapper,
               Dune::MultipleCodimMultipleGeomTypeMapper<typename GET_PROP_TYPE(TypeTag, GridView),
                                                         Dune::MCMGElementLayout>);
+#endif
 
 //! Set the BaseModel to ImplicitModel
 SET_TYPE_PROP(ImplicitBase, BaseModel, ImplicitModel<TypeTag>);
diff --git a/dumux/io/vtkmultiwriter.hh b/dumux/io/vtkmultiwriter.hh
index cb7597643f..c7e6744195 100644
--- a/dumux/io/vtkmultiwriter.hh
+++ b/dumux/io/vtkmultiwriter.hh
@@ -38,6 +38,8 @@
 
 #include <dumux/common/valgrind.hh>
 
+#include <dune/common/version.hh>
+
 #if HAVE_MPI
 #include <mpi.h>
 #endif
@@ -56,8 +58,13 @@ class VtkMultiWriter
 {
     enum { dim = GridView::dimension };
 
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView> VertexMapper;
+    typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView> ElementMapper;
+#else
     typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGVertexLayout> VertexMapper;
     typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGElementLayout> ElementMapper;
+#endif
 
 public:
     typedef Dune::VTKWriter<GridView> VtkWriter;
@@ -65,8 +72,13 @@ public:
                    const std::string &simName = "",
                    std::string multiFileName = "")
         : gridView_(gridView)
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        , elementMapper_(gridView, Dune::mcmgElementLayout())
+        , vertexMapper_(gridView, Dune::mcmgVertexLayout())
+#else
         , elementMapper_(gridView)
         , vertexMapper_(gridView)
+#endif
     {
         simName_ = (simName.empty())?"sim":simName;
         multiFileName_ = multiFileName;
diff --git a/dumux/material/spatialparams/gstatrandomfield.hh b/dumux/material/spatialparams/gstatrandomfield.hh
index c7dbe5e552..fbe0924f75 100644
--- a/dumux/material/spatialparams/gstatrandomfield.hh
+++ b/dumux/material/spatialparams/gstatrandomfield.hh
@@ -30,6 +30,8 @@
 #include <dune/grid/common/mcmgmapper.hh>
 #include <dune/grid/io/file/vtk.hh>
 
+#include <dune/common/version.hh>
+
 namespace Dumux
 {
 
@@ -54,7 +56,11 @@ class GstatRandomField
 
     using DataVector = std::vector<Scalar>;
     using Element = typename GridView::Traits::template Codim<0>::Entity;
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
+#else
     using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGElementLayout>;
+#endif
 
 public:
     // Add field types if you want to implement e.g. tensor permeabilities.
@@ -66,7 +72,12 @@ public:
      * \param gridView the used gridView
      */
     GstatRandomField(const GridView& gridView)
-    : gridView_(gridView), elementMapper_(gridView),
+    : gridView_(gridView),
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+      elementMapper_(gridView, Dune::mcmgElementLayout()),
+#else
+      elementMapper_(gridView),
+#endif
       data_(gridView.size(0)) {}
 
       /*!
diff --git a/dumux/porousmediumflow/sequential/properties.hh b/dumux/porousmediumflow/sequential/properties.hh
index 09cfaa0a7a..205cdaf30c 100644
--- a/dumux/porousmediumflow/sequential/properties.hh
+++ b/dumux/porousmediumflow/sequential/properties.hh
@@ -24,6 +24,8 @@
 #include <dumux/porousmediumflow/sequential/gridadaptproperties.hh>
 #include <dumux/porousmediumflow/sequential/gridadaptinitializationindicatordefault.hh>
 
+#include <dune/common/version.hh>
+
 /*!
  * \ingroup Sequential
  * \ingroup IMPETProperties
@@ -136,12 +138,20 @@ public:
     /*!
      * \brief Mapper for the grid view's vertices.
      */
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    using VertexMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
+#else
     typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGVertexLayout> VertexMapper;
+#endif
 
     /*!
      * \brief Mapper for the grid view's elements.
      */
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
+#else
     typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGElementLayout> ElementMapper;
+#endif
 
     /*!
      * \brief The type of a solution at a fixed time.
diff --git a/dumux/porousmediumflow/sequential/variableclass.hh b/dumux/porousmediumflow/sequential/variableclass.hh
index 25a1e17554..289b1659fd 100644
--- a/dumux/porousmediumflow/sequential/variableclass.hh
+++ b/dumux/porousmediumflow/sequential/variableclass.hh
@@ -21,6 +21,8 @@
 
 #include "properties.hh"
 
+#include <dune/common/version.hh>
+
 // for  parallelization
 //#include <dumux/parallel/elementhandles.hh>
 
@@ -77,10 +79,16 @@ public:
      *  @param gridView a DUNE gridview object corresponding to diffusion and transport equation
      */
     VariableClass(const GridView& gridView) :
-        gridView_(gridView), elementMapper_(gridView), vertexMapper_(gridView)
+        gridView_(gridView),
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+        elementMapper_(gridView, Dune::mcmgElementLayout()),
+        vertexMapper_(gridView, Dune::mcmgVertexLayout())
+#else
+        elementMapper_(gridView),
+        vertexMapper_(gridView)
+#endif
     {}
 
-
     //! Initializes the variable class
     /*! Method initializes the cellData vector.
      * Should be called from problem init()
diff --git a/test/geomechanics/el2p/el2pproblem.hh b/test/geomechanics/el2p/el2pproblem.hh
index ae4f7fe3fe..f87399f2e4 100644
--- a/test/geomechanics/el2p/el2pproblem.hh
+++ b/test/geomechanics/el2p/el2pproblem.hh
@@ -34,6 +34,8 @@
 #include "el2pco2tables.hh"
 #include "el2pspatialparams.hh"
 
+#include <dune/common/version.hh>
+
 namespace Dumux
 {
 template<class TypeTag>
@@ -764,7 +766,14 @@ public:
      *
      * \param gridView The grid view
      */
-    InitialPressSat(const GridView & gridView) : BaseT(gridView) , gridView_(gridView), vertexMapper_(gridView)
+    InitialPressSat(const GridView & gridView)
+    : BaseT(gridView)
+    , gridView_(gridView)
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    , vertexMapper_(gridView, Dune::mcmgVertexLayout())
+#else
+    , vertexMapper_(gridView)
+#endif
     {
         // resize the pressure field vector with the number of vertices
         pInit_.resize(gridView.size(GridView::dimension));
-- 
GitLab