From 6fae9dc35b80aef922e9192cf2b969ce10acde4b Mon Sep 17 00:00:00 2001
From: melaniel <melanie.lipp@iws.uni-stuttgart.de>
Date: Mon, 17 Dec 2018 18:07:46 +0100
Subject: [PATCH] [test][freeflow] Let angeli problem have time_ and
 timeStepSize_ instead of timeLoop_.

---
 test/freeflow/navierstokes/angeli/main.cc    |  5 ++-
 test/freeflow/navierstokes/angeli/problem.hh | 33 +++++++++++---------
 2 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/test/freeflow/navierstokes/angeli/main.cc b/test/freeflow/navierstokes/angeli/main.cc
index b68dfd7d76..aa74f7aa98 100644
--- a/test/freeflow/navierstokes/angeli/main.cc
+++ b/test/freeflow/navierstokes/angeli/main.cc
@@ -93,7 +93,8 @@ int main(int argc, char** argv) try
     // the problem (initial and boundary conditions)
     using Problem = GetPropType<TypeTag, Properties::Problem>;
     auto problem = std::make_shared<Problem>(fvGridGeometry);
-    problem->setTimeLoop(timeLoop);
+    problem->updateTimeStepSize(timeLoop->timeStepSize());
+    problem->createAnalyticalSolution();
 
     // the solution vector
     using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
@@ -148,6 +149,7 @@ int main(int argc, char** argv) try
 
         // advance to the time loop to the next step
         timeLoop->advanceTimeStep();
+        problem->updateTime(timeLoop->time());
 
         // write vtk output
         vtkWriter.write(timeLoop->time());
@@ -157,6 +159,7 @@ int main(int argc, char** argv) try
 
         // set new dt as suggested by newton solver
         timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize()));
+        problem->updateTimeStepSize(timeLoop->timeStepSize());
 
     } while (!timeLoop->finished());
 
diff --git a/test/freeflow/navierstokes/angeli/problem.hh b/test/freeflow/navierstokes/angeli/problem.hh
index 0ed5f3ade5..17eb1680c8 100644
--- a/test/freeflow/navierstokes/angeli/problem.hh
+++ b/test/freeflow/navierstokes/angeli/problem.hh
@@ -104,7 +104,7 @@ class AngeliTestProblem : public NavierStokesProblem<TypeTag>
 
 public:
     AngeliTestProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry)
-    : ParentType(fvGridGeometry), eps_(1e-6)
+    : ParentType(fvGridGeometry)
     {
         printL2Error_ = getParam<bool>("Problem.PrintL2Error");
         kinematicViscosity_ = getParam<Scalar>("Component.LiquidKinematicViscosity", 1.0);
@@ -209,7 +209,7 @@ public:
     PrimaryVariables dirichletAtPos(const GlobalPosition & globalPos) const
     {
         // use the values of the analytical solution
-        return analyticalSolution(globalPos, time());
+        return analyticalSolution(globalPos, time_);
     }
 
     /*!
@@ -223,7 +223,7 @@ public:
         const Scalar x = globalPos[0];
         const Scalar y = globalPos[1];
 
-        const Scalar t = time + timeLoop_->timeStepSize();
+        const Scalar t = time + timeStepSize_;
 
         PrimaryVariables values;
 
@@ -248,7 +248,7 @@ public:
      */
     PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
     {
-        return analyticalSolution(globalPos, -timeLoop_->timeStepSize());
+        return analyticalSolution(globalPos, -timeStepSize_);
     }
 
    /*!
@@ -275,15 +275,20 @@ public:
         return analyticalVelocityOnFace_;
     }
 
-    void setTimeLoop(TimeLoopPtr timeLoop)
+    /*!
+     * \brief Updates the time
+     */
+    void updateTime(const Scalar time)
     {
-        timeLoop_ = timeLoop;
-        createAnalyticalSolution();
+        time_ = time;
     }
 
-    Scalar time() const
+    /*!
+     * \brief Updates the time step size
+     */
+    void updateTimeStepSize(const Scalar timeStepSize)
     {
-        return timeLoop_->time();
+        timeStepSize_ = timeStepSize;
     }
 
    /*!
@@ -305,7 +310,7 @@ public:
             {
                 auto ccDofIdx = scv.dofIndex();
                 auto ccDofPosition = scv.dofPosition();
-                auto analyticalSolutionAtCc = analyticalSolution(ccDofPosition, time());
+                auto analyticalSolutionAtCc = analyticalSolution(ccDofPosition, time_);
 
                 // velocities on faces
                 for (auto&& scvf : scvfs(fvGeometry))
@@ -313,7 +318,7 @@ public:
                     const auto faceDofIdx = scvf.dofIndex();
                     const auto faceDofPosition = scvf.center();
                     const auto dirIdx = scvf.directionIndex();
-                    const auto analyticalSolutionAtFace = analyticalSolution(faceDofPosition, time());
+                    const auto analyticalSolutionAtFace = analyticalSolution(faceDofPosition, time_);
                     analyticalVelocityOnFace_[faceDofIdx][dirIdx] = analyticalSolutionAtFace[Indices::velocity(dirIdx)];
                 }
 
@@ -326,11 +331,11 @@ public:
     }
 
 private:
-
-    Scalar eps_;
+    static constexpr Scalar eps_ = 1e-6;
 
     Scalar kinematicViscosity_;
-    TimeLoopPtr timeLoop_;
+    Scalar time_ = 0;
+    Scalar timeStepSize_ = 0;
     bool printL2Error_;
     std::vector<Scalar> analyticalPressure_;
     std::vector<VelocityVector> analyticalVelocity_;
-- 
GitLab