From 03352cd9aaa5524e8869c44478636d28d363c789 Mon Sep 17 00:00:00 2001
From: Christoph Grueninger <christoph.grueninger@iws.uni-stuttgart.de>
Date: Tue, 11 Feb 2014 07:43:08 +0000
Subject: [PATCH] Rename leafView() / levelView() view for Dune 2.3.

Dune 2.3 deprecated the old names and introduced
leafGridView() / levelGridView().
(reviewed by fetzer)


git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@12445 2fb0f335-1f38-0410-981e-8018bf24f1b0
---
 dumux/common/start.hh                         |  4 +++
 .../decoupled/common/variableclassadaptive.hh |  8 +++++
 dumux/io/interfacemeshcreator.hh              |  7 +++-
 test/decoupled/1p/resultevaluation3d.hh       | 12 +++++--
 test/decoupled/1p/test_diffusion.cc           | 22 +++++++++++++
 test/decoupled/1p/test_diffusion3d.cc         | 26 +++++++++++++++
 test/decoupled/2p2c/test_multiphysics2p2c.cc  |  4 +++
 test/geomechanics/el2p/test_el2p.cc           |  7 +++-
 test/implicit/2p2c/injectionproblem.hh        |  5 +++
 test/implicit/co2/heterogeneousproblem.hh     |  5 +++
 .../co2/heterogeneousspatialparameters.hh     | 32 +++++++++++++++++--
 test/implicit/co2ni/heterogeneousproblemni.hh |  6 ++++
 test/implicit/mpnc/test_boxmpnckinetic.cc     |  9 ++++--
 13 files changed, 137 insertions(+), 10 deletions(-)

diff --git a/dumux/common/start.hh b/dumux/common/start.hh
index 50dfe0a233..2a885517dc 100644
--- a/dumux/common/start.hh
+++ b/dumux/common/start.hh
@@ -529,7 +529,11 @@ int start_(int argc,
 
     // instantiate and run the concrete problem
     TimeManager timeManager;
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+    Problem problem(timeManager, GridCreator::grid().leafGridView());
+#else
     Problem problem(timeManager, GridCreator::grid().leafView());
+#endif
     timeManager.init(problem, restartTime, dt, tEnd, restart);
     timeManager.run();
     // print dumux end message
diff --git a/dumux/decoupled/common/variableclassadaptive.hh b/dumux/decoupled/common/variableclassadaptive.hh
index 9682c30ac8..74952f6303 100644
--- a/dumux/decoupled/common/variableclassadaptive.hh
+++ b/dumux/decoupled/common/variableclassadaptive.hh
@@ -99,7 +99,11 @@ public:
         for (int level = grid_.maxLevel(); level >= 0; level--)
         {
             //get grid view on level grid
+#if DUNE_VERSION_NEWER(DUNE_GRID, 2, 3)
+            LevelGridView levelView = grid_.levelGridView(level);
+#else
             LevelGridView levelView = grid_.levelView(level);
+#endif
             for (LevelIterator eIt = levelView.template begin<0>(); eIt != levelView.template end<0>(); ++eIt)
             {
                 //get your map entry
@@ -153,7 +157,11 @@ public:
 
         for (int level = 0; level <= grid_.maxLevel(); level++)
         {
+#if DUNE_VERSION_NEWER(DUNE_GRID, 2, 3)
+            LevelGridView levelView = grid_.levelGridView(level);
+#else
             LevelGridView levelView = grid_.levelView(level);
+#endif
             for (LevelIterator eIt = levelView.template begin<0>(); eIt != levelView.template end<0>(); ++eIt)
             {
                 // only treat non-ghosts, ghost data is communicated afterwards
diff --git a/dumux/io/interfacemeshcreator.hh b/dumux/io/interfacemeshcreator.hh
index b137c96008..89423b44b7 100644
--- a/dumux/io/interfacemeshcreator.hh
+++ b/dumux/io/interfacemeshcreator.hh
@@ -1,7 +1,8 @@
 #ifndef DUMUX_INTERFACEMESHCREATOR_HH
 #define DUMUX_INTERFACEMESHCREATOR_HH
 
-#include<dune/grid/common/gridfactory.hh>
+#include <dune/common/version.hh>
+#include <dune/grid/common/gridfactory.hh>
 #include <dune/grid/io/file/dgfparser/dgfs.hh>
 
 namespace Dumux
@@ -28,7 +29,11 @@ public:
         typedef typename HelperGridView::Traits::template Codim<0>::Entity HelperElement;
         typedef typename HelperElement::Geometry HelperGeometry;
 
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        HelperElementIterator helperElementIterator = helperGrid.leafGridView().template begin<0>();
+#else
         HelperElementIterator helperElementIterator = helperGrid.leafView().template begin<0>();
+#endif
         const HelperElement& helperElement = *helperElementIterator;
         const HelperGeometry& helperGeometry = helperElement.geometry();
 
diff --git a/test/decoupled/1p/resultevaluation3d.hh b/test/decoupled/1p/resultevaluation3d.hh
index b5531c5a07..3c55ab4390 100644
--- a/test/decoupled/1p/resultevaluation3d.hh
+++ b/test/decoupled/1p/resultevaluation3d.hh
@@ -17,8 +17,6 @@
  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
  *****************************************************************************/
 
-#include <dumux/decoupled/common/onemodelproblem.hh>
-
 /*!
  * \file
  *
@@ -28,6 +26,9 @@
 #ifndef DUMUX_BENCHMARKRESULT_HH
 #define DUMUX_BENCHMARKRESULT_HH
 
+#include <dune/common/version.hh>
+#include <dumux/decoupled/common/onemodelproblem.hh>
+
 namespace Dumux
 {
 
@@ -106,15 +107,20 @@ public:
 #if DUNE_VERSION_NEWER(DUNE_GRID, 2, 3)
         typedef typename Geometry::JacobianInverseTransposed JacobianInverseTransposed;
         typedef typename Dune::ReferenceElements<ct, dim> ReferenceElements;
+        const GV& gridview(grid.levelGridView(grid.maxLevel()));
+        const IS& indexset(gridview.indexSet());
+        EM elementmapper(gridview);
+        FM facemapper(gridview);
+        SolutionType& exactSol(grid.levelGridView(grid.maxLevel()));
 #else
         typedef typename Geometry::Jacobian JacobianInverseTransposed;
         typedef typename Dune::GenericReferenceElements<ct, dim> ReferenceElements;
-#endif
         const GV& gridview(grid.levelView(grid.maxLevel()));
         const IS& indexset(gridview.indexSet());
         EM elementmapper(gridview);
         FM facemapper(gridview);
         SolutionType& exactSol(grid.levelView(grid.maxLevel()));
+#endif
 
         uMean = 0;
         double domainVolume = 0;
diff --git a/test/decoupled/1p/test_diffusion.cc b/test/decoupled/1p/test_diffusion.cc
index 8ff63507cf..c88ccac2f6 100644
--- a/test/decoupled/1p/test_diffusion.cc
+++ b/test/decoupled/1p/test_diffusion.cc
@@ -91,7 +91,11 @@ int main(int argc, char** argv)
         bool consecutiveNumbering = true;
 
         typedef GET_PROP_TYPE(TTAG(FVVelocity2PTestProblem), Problem) FVProblem;
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        FVProblem fvProblem(grid->leafGridView(), delta);
+#else
         FVProblem fvProblem(grid->leafView(), delta);
+#endif
         fvProblem.setName("fvdiffusion");
         timer.reset();
         fvProblem.init();
@@ -99,27 +103,45 @@ int main(int argc, char** argv)
         double fvTime = timer.elapsed();
         fvProblem.writeOutput();
         Dumux::ResultEvaluation fvResult;
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        fvResult.evaluate(grid->leafGridView(), fvProblem, consecutiveNumbering);
+
+        typedef GET_PROP_TYPE(TTAG(FVMPFAOVelocity2PTestProblem), Problem) MPFAOProblem;
+        MPFAOProblem mpfaProblem(grid->leafGridView(), delta);
+#else
         fvResult.evaluate(grid->leafView(), fvProblem, consecutiveNumbering);
 
         typedef GET_PROP_TYPE(TTAG(FVMPFAOVelocity2PTestProblem), Problem) MPFAOProblem;
         MPFAOProblem mpfaProblem(grid->leafView(), delta);
+#endif
         mpfaProblem.setName("fvmpfaodiffusion");
         timer.reset();
         mpfaProblem.init();
         double mpfaTime = timer.elapsed();
         mpfaProblem.writeOutput();
         Dumux::ResultEvaluation mpfaResult;
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        mpfaResult.evaluate(grid->leafGridView(), mpfaProblem, consecutiveNumbering);
+
+        typedef GET_PROP_TYPE(TTAG(MimeticPressure2PTestProblem), Problem) MimeticProblem;
+        MimeticProblem mimeticProblem(grid->leafGridView(), delta);
+#else
         mpfaResult.evaluate(grid->leafView(), mpfaProblem, consecutiveNumbering);
 
         typedef GET_PROP_TYPE(TTAG(MimeticPressure2PTestProblem), Problem) MimeticProblem;
         MimeticProblem mimeticProblem(grid->leafView(), delta);
+#endif
         mimeticProblem.setName("mimeticdiffusion");
         timer.reset();
         mimeticProblem.init();
         double mimeticTime = timer.elapsed();
         mimeticProblem.writeOutput();
         Dumux::ResultEvaluation mimeticResult;
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        mimeticResult.evaluate(grid->leafGridView(), mimeticProblem, consecutiveNumbering);
+#else
         mimeticResult.evaluate(grid->leafView(), mimeticProblem, consecutiveNumbering);
+#endif
 
         std::cout.setf(std::ios_base::scientific, std::ios_base::floatfield);
         std::cout.precision(2);
diff --git a/test/decoupled/1p/test_diffusion3d.cc b/test/decoupled/1p/test_diffusion3d.cc
index fe5a7cf986..9f18e98a2b 100644
--- a/test/decoupled/1p/test_diffusion3d.cc
+++ b/test/decoupled/1p/test_diffusion3d.cc
@@ -132,7 +132,11 @@ int main(int argc, char** argv)
         typedef GET_PROP_TYPE(FVTypeTag, Problem) FVProblem;
         typedef GET_PROP(FVTypeTag, ParameterTree) FVParameterTree;
         Dune::ParameterTreeParser::readINITree(parameterFileName, FVParameterTree::tree());
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        FVProblem *fvProblem = new FVProblem(grid->leafGridView());
+#else
         FVProblem *fvProblem = new FVProblem(grid->leafView());
+#endif
         std::string fvOutput("test_diffusion3d_fv");
         fvOutput += outputName;
         if (numRefine > 0)
@@ -148,7 +152,11 @@ int main(int argc, char** argv)
         double fvTime = timer.elapsed();
         fvProblem->writeOutput();
         Dumux::ResultEvaluation fvResult;
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        fvResult.evaluate(grid->leafGridView(), *fvProblem, consecutiveNumbering);
+#else
         fvResult.evaluate(grid->leafView(), *fvProblem, consecutiveNumbering);
+#endif
 
         delete fvProblem;
 
@@ -157,7 +165,12 @@ int main(int argc, char** argv)
         typedef GET_PROP_TYPE(MPFALTypeTag, Problem) MPFALProblem;
         typedef GET_PROP(MPFALTypeTag, ParameterTree) MPFALParameterTree;
         Dune::ParameterTreeParser::readINITree(parameterFileName, MPFALParameterTree::tree());
+
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        MPFALProblem *mpfaProblem = new MPFALProblem(grid->leafGridView());
+#else
         MPFALProblem *mpfaProblem = new MPFALProblem(grid->leafView());
+#endif
         std::string fvmpfaOutput("test_diffusion3d_fvmpfal");
         fvmpfaOutput += outputName;
         if (numRefine > 0)
@@ -172,7 +185,11 @@ int main(int argc, char** argv)
         double mpfaTime = timer.elapsed();
         mpfaProblem->writeOutput();
         Dumux::ResultEvaluation mpfaResult;
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        mpfaResult.evaluate(grid->leafGridView(), *mpfaProblem, consecutiveNumbering);
+#else
         mpfaResult.evaluate(grid->leafView(), *mpfaProblem, consecutiveNumbering);
+#endif
 
         delete mpfaProblem;
 
@@ -181,7 +198,12 @@ int main(int argc, char** argv)
         typedef GET_PROP_TYPE(MimeticTypeTag, Problem) MimeticProblem;
         typedef GET_PROP(MimeticTypeTag, ParameterTree) MimeticParameterTree;
         Dune::ParameterTreeParser::readINITree(parameterFileName, MimeticParameterTree::tree());
+
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        MimeticProblem *mimeticProblem = new MimeticProblem(grid->leafGridView());
+#else
         MimeticProblem *mimeticProblem = new MimeticProblem(grid->leafView());
+#endif
         std::string mimeticOutput("test_diffusion3d_mimetic");
         mimeticOutput += outputName;
         if (numRefine > 0)
@@ -196,7 +218,11 @@ int main(int argc, char** argv)
         double mimeticTime = timer.elapsed();
         mimeticProblem->writeOutput();
         Dumux::ResultEvaluation mimeticResult;
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        mimeticResult.evaluate(grid->leafGridView(), *mimeticProblem, consecutiveNumbering);
+#else
         mimeticResult.evaluate(grid->leafView(), *mimeticProblem, consecutiveNumbering);
+#endif
 
         delete mimeticProblem;
 
diff --git a/test/decoupled/2p2c/test_multiphysics2p2c.cc b/test/decoupled/2p2c/test_multiphysics2p2c.cc
index 0c2cd1fe3a..de8f0b852f 100644
--- a/test/decoupled/2p2c/test_multiphysics2p2c.cc
+++ b/test/decoupled/2p2c/test_multiphysics2p2c.cc
@@ -104,7 +104,11 @@ int main(int argc, char** argv)
         // instantiate and run the concrete problem
         ////////////////////////////////////////////////////////////
         TimeManager timeManager;
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        Problem problem(timeManager, grid.leafGridView(), L, H);
+#else
         Problem problem(timeManager, grid.leafView(), L, H);
+#endif
 
         // initialize the simulation
         timeManager.init(problem, startTime, firstDt, tEnd, restart);
diff --git a/test/geomechanics/el2p/test_el2p.cc b/test/geomechanics/el2p/test_el2p.cc
index 7ba5d398b4..cb14a896da 100644
--- a/test/geomechanics/el2p/test_el2p.cc
+++ b/test/geomechanics/el2p/test_el2p.cc
@@ -28,9 +28,10 @@
 // Check if DUNE-PDELab has been patched for our needs.
 #ifdef DUNE_PDELAB_IS_PATCHED_FOR_DUMUX
 
-#include "el2pproblem.hh"
 #include <dune/common/precision.hh>
+#include <dune/common/version.hh>
 #include <dumux/common/start.hh>
+#include "el2pproblem.hh"
 
 int main(int argc, char** argv) {
     try {
@@ -68,7 +69,11 @@ int main(int argc, char** argv) {
         TimeManager timeManager;
 
         // instantiate problem
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        Problem problem(timeManager, gridPtr->leafGridView(), tInitEnd);
+#else
         Problem problem(timeManager, gridPtr->leafView(),tInitEnd);
+#endif
 
         // set the initial approximated hydrostatic pressure distribution
         // based on an averaged brine density
diff --git a/test/implicit/2p2c/injectionproblem.hh b/test/implicit/2p2c/injectionproblem.hh
index 8794828d5b..8134b0bfa6 100644
--- a/test/implicit/2p2c/injectionproblem.hh
+++ b/test/implicit/2p2c/injectionproblem.hh
@@ -24,6 +24,7 @@
 #ifndef DUMUX_INJECTION_PROBLEM_HH
 #define DUMUX_INJECTION_PROBLEM_HH
 
+#include <dune/common/version.hh>
 #include <dune/grid/io/file/dgfparser/dgfs.hh>
 
 #include <dumux/implicit/2p2c/2p2cmodel.hh>
@@ -157,7 +158,11 @@ public:
      */
     InjectionProblem(TimeManager &timeManager,
                      const GridView &gridView)
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        : ParentType(timeManager, GridCreator::grid().leafGridView())
+#else
         : ParentType(timeManager, GridCreator::grid().leafView())
+#endif
     {
         try
         {
diff --git a/test/implicit/co2/heterogeneousproblem.hh b/test/implicit/co2/heterogeneousproblem.hh
index 29c0ee3d6a..ef15b84017 100644
--- a/test/implicit/co2/heterogeneousproblem.hh
+++ b/test/implicit/co2/heterogeneousproblem.hh
@@ -24,6 +24,7 @@
 #ifndef DUMUX_HETEROGENEOUS_PROBLEM_HH
 #define DUMUX_HETEROGENEOUS_PROBLEM_HH
 
+#include <dune/common/version.hh>
 
 #if HAVE_ALUGRID
 #include <dune/grid/alugrid/2d/alugrid.hh>
@@ -193,7 +194,11 @@ public:
      */
     HeterogeneousProblem(TimeManager &timeManager,
                      const GridView &gridView)
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        : ParentType(timeManager, GridCreator::grid().leafGridView()),
+#else
         : ParentType(timeManager, GridCreator::grid().leafView()),
+#endif
           //Boundary Id Setup:
           injectionTop_(1),
           injectionBottom_(2),
diff --git a/test/implicit/co2/heterogeneousspatialparameters.hh b/test/implicit/co2/heterogeneousspatialparameters.hh
index 29a53a79e7..6b13fd82eb 100644
--- a/test/implicit/co2/heterogeneousspatialparameters.hh
+++ b/test/implicit/co2/heterogeneousspatialparameters.hh
@@ -26,6 +26,8 @@
 #ifndef DUMUX_HETEROGENEOUS_SPATIAL_PARAMS_HH
 #define DUMUX_HETEROGENEOUS_SPATIAL_PARAMS_HH
 
+#include <dune/common/version.hh>
+
 #include <dumux/material/spatialparams/implicitspatialparams.hh>
 #include <dumux/material/fluidmatrixinteractions/2p/linearmaterial.hh>
 #include <dumux/material/fluidmatrixinteractions/2p/regularizedbrookscorey.hh>
@@ -143,6 +145,19 @@ public:
     void setParams(GridPointer *gridPtr)
     {
         gridPtr_ = gridPtr;
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        int numElements = (*gridPtr_)->leafGridView().size(0);
+        paramIdx_.resize(numElements);
+
+        ElementIterator eIt = (*gridPtr_)->leafGridView().template begin<0>();
+        const ElementIterator eEndIt = (*gridPtr_)->leafGridView().template end<0>();
+        for (; eIt != eEndIt; ++eIt)
+        {
+            int eIdx = (*gridPtr_)->leafGridView().indexSet().index(*eIt);
+            int param = (*gridPtr_).parameters(*eIt)[0];
+            paramIdx_[eIdx] = param;
+        }
+#else
         int numElements = (*gridPtr_)->leafView().size(0);
         paramIdx_.resize(numElements);
 
@@ -154,6 +169,7 @@ public:
             int param = (*gridPtr_).parameters(*eIt)[0];
             paramIdx_[eIdx] = param;
         }
+#endif
 
     }
 
@@ -169,7 +185,13 @@ public:
                                        const FVElementGeometry &fvGeometry,
                                        int scvIdx) const
     {
-        int eIdx = (*gridPtr_)->leafView().indexSet().index(element); //Get the global index of the element
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        //Get the global index of the element
+        int eIdx = (*gridPtr_)->leafGridView().indexSet().index(element);
+#else
+        //Get the global index of the element
+        int eIdx = (*gridPtr_)->leafView().indexSet().index(element);
+#endif
 
         if (paramIdx_[eIdx] == barrierTop_)
             return barrierTopK_;
@@ -191,7 +213,13 @@ public:
                     const FVElementGeometry &fvGeometry,
                     int scvIdx) const
     {
-        int eIdx = (*gridPtr_)->leafView().indexSet().index(element); //Get the global index of the element
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        //Get the global index of the element
+        int eIdx = (*gridPtr_)->leafGridView().indexSet().index(element);
+#else
+        //Get the global index of the element
+        int eIdx = (*gridPtr_)->leafView().indexSet().index(element);
+#endif
 
         if (paramIdx_[eIdx] == barrierTop_)
             return barrierTopPorosity_;
diff --git a/test/implicit/co2ni/heterogeneousproblemni.hh b/test/implicit/co2ni/heterogeneousproblemni.hh
index e1db70dd92..c9b47495c3 100644
--- a/test/implicit/co2ni/heterogeneousproblemni.hh
+++ b/test/implicit/co2ni/heterogeneousproblemni.hh
@@ -24,6 +24,8 @@
 #ifndef DUMUX_HETEROGENEOUS_NI_PROBLEM_NI_HH
 #define DUMUX_HETEROGENEOUS_NI_PROBLEM_NI_HH
 
+#include <dune/common/version.hh>
+
 #if HAVE_ALUGRID
 #include <dune/grid/alugrid/2d/alugrid.hh>
 #else
@@ -183,7 +185,11 @@ public:
      */
     HeterogeneousNIProblem(TimeManager &timeManager,
                      const GridView &gridView)
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+        : ParentType(timeManager, GridCreator::grid().leafGridView()),
+#else
         : ParentType(timeManager, GridCreator::grid().leafView()),
+#endif
           //Boundary Id Setup:
           injectionTop_ (1),
           injectionBottom_(2),
diff --git a/test/implicit/mpnc/test_boxmpnckinetic.cc b/test/implicit/mpnc/test_boxmpnckinetic.cc
index 94f0447d70..6b566e6233 100644
--- a/test/implicit/mpnc/test_boxmpnckinetic.cc
+++ b/test/implicit/mpnc/test_boxmpnckinetic.cc
@@ -18,12 +18,11 @@
  *****************************************************************************/
 #include "config.h"
 
-#include "evaporationatmosphereproblem.hh"
+#include <dune/common/version.hh>
 
 #include <dumux/common/start.hh>
-
 #include <dumux/io/interfacemeshcreator.hh>
-
+#include "evaporationatmosphereproblem.hh"
 
 /*!
  * \brief Print a usage string for simulations.
@@ -283,8 +282,12 @@ int start_(int argc,
     TimeManager timeManager;
 
     // instantiate coupled problem
+#if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 3)
+    Problem problem(timeManager, gridPtr->leafGridView());
+#else
     Problem problem(timeManager,
                     gridPtr->leafView());
+#endif
 
     Dumux::Parameters::print<TypeTag>();
 
-- 
GitLab