From 6b4dc071dd4e23f02b3605a109b8d1c73ef04c7e 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())
---
 dumux/common/intersectionmapper.hh                |  6 ++++++
 dumux/implicit/problem.hh                         | 14 ++++++++++++++
 dumux/implicit/propertydefaults.hh                | 15 +++++++++++++++
 dumux/io/vtkmultiwriter.hh                        | 13 ++++++++++++-
 dumux/material/spatialparams/gstatrandomfield.hh  |  8 ++++++++
 dumux/porousmediumflow/sequential/properties.hh   | 10 ++++++++++
 .../porousmediumflow/sequential/variableclass.hh  |  7 +++++++
 test/geomechanics/el2p/el2pproblem.hh             |  6 ++++++
 8 files changed, 78 insertions(+), 1 deletion(-)

diff --git a/dumux/common/intersectionmapper.hh b/dumux/common/intersectionmapper.hh
index 8b46290774..04cd619237 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 intersection mappers.
@@ -185,7 +187,11 @@ class IntersectionMapper
     enum {dim=Grid::dimension};
     typedef typename Grid::template Codim<0>::Entity Element;
     typedef typename GridView::Intersection Intersection;
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
+#else
     typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, Dune::MCMGElementLayout> ElementMapper;
+#endif
 
 public:
     IntersectionMapper(const GridView& gridview)
diff --git a/dumux/implicit/problem.hh b/dumux/implicit/problem.hh
index 85063b59d4..fbd14884fb 100644
--- a/dumux/implicit/problem.hh
+++ b/dumux/implicit/problem.hh
@@ -31,6 +31,8 @@
 #include <dumux/implicit/adaptive/gridadapt.hh>
 #include <dumux/common/boundingboxtree.hh>
 
+#include <dune/common/version.hh>
+
 namespace Dumux
 {
 /*!
@@ -98,6 +100,17 @@ public:
      * \param timeManager The TimeManager which is used by the simulation
      * \param gridView The simulation's idea about physical space
      */
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    ImplicitProblem(TimeManager &timeManager, const GridView &gridView)
+        : gridView_(gridView)
+        , bBoxMin_(std::numeric_limits<double>::max())
+        , bBoxMax_(-std::numeric_limits<double>::max())
+        , elementMapper_(gridView, Dune::mcmgElementLayout())
+        , vertexMapper_(gridView, Dune::mcmgVertexLayout())
+        , timeManager_(&timeManager)
+        , newtonMethod_(asImp_())
+        , newtonCtl_(asImp_())
+#else
     ImplicitProblem(TimeManager &timeManager, const GridView &gridView)
         : gridView_(gridView)
         , bBoxMin_(std::numeric_limits<double>::max())
@@ -107,6 +120,7 @@ public:
         , timeManager_(&timeManager)
         , newtonMethod_(asImp_())
         , newtonCtl_(asImp_())
+#endif
     {
         // 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 59d5c41f6d..dfd0645fe9 100644
--- a/dumux/implicit/propertydefaults.hh
+++ b/dumux/implicit/propertydefaults.hh
@@ -55,6 +55,8 @@
 #include "assembler.hh"
 #include "localjacobian.hh"
 
+#include <dune/common/version.hh>
+
 namespace Dumux {
 
 // forward declarations
@@ -88,16 +90,29 @@ SET_TYPE_PROP(ImplicitBase, NewtonController, NewtonController<TypeTag>);
 SET_TYPE_PROP(ImplicitBase, NewtonConvergenceWriter, NewtonConvergenceWriter<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 5f82b0a38f..307541166d 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
@@ -61,12 +63,21 @@ class VtkMultiWriter
 
 public:
     typedef Dune::VTKWriter<GridView> VtkWriter;
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
     VtkMultiWriter(const GridView &gridView,
                    const std::string &simName = "",
                    std::string multiFileName = "")
         : gridView_(gridView)
+        , elementMapper_(gridView, Dune::mcmgElementLayout())
+        , vertexMapper_(gridView, Dune::mcmgVertexLayout())
+#else
+    VtkMultiWriter(const GridView &gridView,
+                   const std::string &simName = "",
+                std::string multiFileName = "")
+        : gridView_(gridView)
         , elementMapper_(gridView)
         , vertexMapper_(gridView)
+#endif
     {
         simName_ = (simName.empty())?"sim":simName;
         multiFileName_ = multiFileName;
@@ -489,4 +500,4 @@ private:
 };
 }
 
-#endif
\ No newline at end of file
+#endif
diff --git a/dumux/material/spatialparams/gstatrandomfield.hh b/dumux/material/spatialparams/gstatrandomfield.hh
index c7dbe5e552..9d208ed2b1 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
 {
 
@@ -65,9 +67,15 @@ public:
      *
      * \param gridView the used gridView
      */
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    GstatRandomField(const GridView& gridView)
+    : gridView_(gridView), elementMapper_(gridView, Dune::mcmgElementLayout()),
+      data_(gridView.size(0)) {}
+#else
     GstatRandomField(const GridView& gridView)
     : gridView_(gridView), elementMapper_(gridView),
       data_(gridView.size(0)) {}
+#endif
 
       /*!
        * \brief Creates a new field with random variables, if desired.
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..449064c8cf 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>
 
@@ -76,9 +78,14 @@ public:
     /**
      *  @param gridView a DUNE gridview object corresponding to diffusion and transport equation
      */
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    VariableClass(const GridView& gridView) :
+        gridView_(gridView), elementMapper_(gridView, Dune::mcmgElementLayout()), vertexMapper_(gridView, Dune::mcmgVertexLayout())
+#else
     VariableClass(const GridView& gridView) :
         gridView_(gridView), elementMapper_(gridView), vertexMapper_(gridView)
     {}
+#endif
 
 
     //! Initializes the variable class
diff --git a/test/geomechanics/el2p/el2pproblem.hh b/test/geomechanics/el2p/el2pproblem.hh
index ae4f7fe3fe..7b859abe35 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,11 @@ public:
      *
      * \param gridView The grid view
      */
+#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6)
+    InitialPressSat(const GridView & gridView) : BaseT(gridView) , gridView_(gridView), vertexMapper_(gridView, Dune::mcmgVertexLayout())
+#else
     InitialPressSat(const GridView & gridView) : BaseT(gridView) , gridView_(gridView), vertexMapper_(gridView)
+#endif
     {
         // resize the pressure field vector with the number of vertices
         pInit_.resize(gridView.size(GridView::dimension));
-- 
GitLab