From cc394262e3331f1653477977e60ac38f65f8510c Mon Sep 17 00:00:00 2001
From: Bernd Flemisch <bernd@iws.uni-stuttgart.de>
Date: Tue, 10 Jul 2018 13:52:54 +0200
Subject: [PATCH] [io][restart] use restart functionality directly from main

---
 dumux/common/fvproblem.hh                       | 17 ++---------------
 .../2p/implicit/incompressible/problem.hh       | 10 ----------
 .../2p/implicit/incompressible/test_2p_fv.cc    |  9 ++++++++-
 .../2p2c/implicit/injectionproblem.hh           | 10 ----------
 .../2p2c/implicit/test_2p2c_fv.cc               |  9 ++++++++-
 5 files changed, 18 insertions(+), 37 deletions(-)

diff --git a/dumux/common/fvproblem.hh b/dumux/common/fvproblem.hh
index e812461f59..84c0e81802 100644
--- a/dumux/common/fvproblem.hh
+++ b/dumux/common/fvproblem.hh
@@ -476,22 +476,9 @@ public:
      * \brief Applies the initial solution for all degrees of freedom of the grid.
      * \param sol the initial solution vector
      */
-    void applyInitialSolution(SolutionVector& sol, Scalar restartTime = 0) const
-    {
-        if (restartTime > 0)
-        {
-            // set initial values for a restarted simulation
-            asImp_().applyRestartSolution(sol);
-        }
-        else
-        {
-            // set the initial values by forwarding to a specialized method
-            applyInitialSolutionImpl_(sol, std::integral_constant<bool, isBox>());
-        }
-    }
-
-    void applyRestartSolution(SolutionVector& sol) const
+    void applyInitialSolution(SolutionVector& sol) const
     {
+        // set the initial values by forwarding to a specialized method
         applyInitialSolutionImpl_(sol, std::integral_constant<bool, isBox>());
     }
 
diff --git a/test/porousmediumflow/2p/implicit/incompressible/problem.hh b/test/porousmediumflow/2p/implicit/incompressible/problem.hh
index 6336db9706..5d630ec595 100644
--- a/test/porousmediumflow/2p/implicit/incompressible/problem.hh
+++ b/test/porousmediumflow/2p/implicit/incompressible/problem.hh
@@ -29,8 +29,6 @@
 #include <dumux/discretization/cellcentered/tpfa/properties.hh>
 #include <dumux/discretization/cellcentered/mpfa/properties.hh>
 
-#include <dumux/io/restart.hh>
-
 #include <dumux/material/components/trichloroethene.hh>
 #include <dumux/material/components/simpleh2o.hh>
 #include <dumux/material/fluidsystems/1pliquid.hh>
@@ -232,14 +230,6 @@ public:
         return 293.15; // 10°C
     }
 
-    template <class SolutionVector>
-    void applyRestartSolution(SolutionVector& sol) const
-    {
-        using PvNames = typename GET_PROP_TYPE(TypeTag, PrimaryVariableNames);
-
-        Restart::loadSolutionFromVtkFile(this->fvGridGeometry(), PvNames::get(), sol);
-    }
-
 private:
     bool onLeftBoundary_(const GlobalPosition &globalPos) const
     {
diff --git a/test/porousmediumflow/2p/implicit/incompressible/test_2p_fv.cc b/test/porousmediumflow/2p/implicit/incompressible/test_2p_fv.cc
index 30c9011c4f..6419e8b9be 100644
--- a/test/porousmediumflow/2p/implicit/incompressible/test_2p_fv.cc
+++ b/test/porousmediumflow/2p/implicit/incompressible/test_2p_fv.cc
@@ -51,6 +51,7 @@
 
 #include <dumux/io/vtkoutputmodule.hh>
 #include <dumux/io/grid/gridmanager.hh>
+#include <dumux/io/restart.hh>
 
 /*!
  * \brief Provides an interface for customizing error messages associated with
@@ -133,7 +134,13 @@ int main(int argc, char** argv) try
     // the solution vector
     using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
     SolutionVector x(fvGridGeometry->numDofs());
-    problem->applyInitialSolution(x, restartTime);
+    if (restartTime > 0)
+    {
+        using PvNames = typename GET_PROP_TYPE(TypeTag, PrimaryVariableNames);
+        Restart::loadSolutionFromVtkFile(*fvGridGeometry, PvNames::get(), x);
+    }
+    else
+        problem->applyInitialSolution(x);
     auto xOld = x;
 
     // maybe update the interface parameters
diff --git a/test/porousmediumflow/2p2c/implicit/injectionproblem.hh b/test/porousmediumflow/2p2c/implicit/injectionproblem.hh
index a78b72cec1..56e2d8093c 100644
--- a/test/porousmediumflow/2p2c/implicit/injectionproblem.hh
+++ b/test/porousmediumflow/2p2c/implicit/injectionproblem.hh
@@ -30,8 +30,6 @@
 #include <dumux/discretization/cellcentered/tpfa/properties.hh>
 #include <dumux/discretization/box/properties.hh>
 
-#include <dumux/io/restart.hh>
-
 #include <dumux/porousmediumflow/problem.hh>
 #include <dumux/porousmediumflow/2p2c/model.hh>
 #include <dumux/material/fluidsystems/h2on2.hh>
@@ -294,14 +292,6 @@ public:
 
     // \}
 
-    template <class SolutionVector>
-    void applyRestartSolution(SolutionVector& sol) const
-    {
-        using PvNames = typename GET_PROP_TYPE(TypeTag, PrimaryVariableNames);
-
-        Restart::loadSolutionFromVtkFile(this->fvGridGeometry(), PvNames::get(), sol);
-    }
-
 private:
     /*!
      * \brief Evaluates the initial values for a control volume
diff --git a/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.cc b/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.cc
index 1e80cd70e3..fa0fe82b67 100644
--- a/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.cc
+++ b/test/porousmediumflow/2p2c/implicit/test_2p2c_fv.cc
@@ -47,6 +47,7 @@
 
 #include <dumux/io/vtkoutputmodule.hh>
 #include <dumux/io/grid/gridmanager.hh>
+#include <dumux/io/restart.hh>
 
 // the problem definitions
 #include "injectionproblem.hh"
@@ -101,7 +102,13 @@ int main(int argc, char** argv) try
     // the solution vector
     using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
     SolutionVector x(fvGridGeometry->numDofs());
-    problem->applyInitialSolution(x, restartTime);
+    if (restartTime > 0)
+    {
+        using PvNames = typename GET_PROP_TYPE(TypeTag, PrimaryVariableNames);
+        Restart::loadSolutionFromVtkFile(*fvGridGeometry, PvNames::get(), x);
+    }
+    else
+        problem->applyInitialSolution(x);
     auto xOld = x;
 
     // the grid variables
-- 
GitLab