From 76f49c176190d7d3951673890a3ecac92604dd8e Mon Sep 17 00:00:00 2001
From: Beatrix Becker <beatrix.becker@iws.uni-stuttgart.de>
Date: Wed, 27 Jan 2016 11:01:59 +0100
Subject: [PATCH] [decoupled] increase flexibility of some functions

The calls to several functions are hardwired to the base class.
By using asImp, some of those calls are now forwarded to the
derived class, if applicable.
---
 .../sequential/diffusion/cellcentered/pressure.hh   | 13 ++++++++++++-
 .../sequential/transport/cellcentered/saturation.hh |  5 +++--
 .../sequential/cellcentered/pressure.hh             |  6 ++----
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/dumux/porousmediumflow/2p/sequential/diffusion/cellcentered/pressure.hh b/dumux/porousmediumflow/2p/sequential/diffusion/cellcentered/pressure.hh
index d0f8619671..66a35159e4 100644
--- a/dumux/porousmediumflow/2p/sequential/diffusion/cellcentered/pressure.hh
+++ b/dumux/porousmediumflow/2p/sequential/diffusion/cellcentered/pressure.hh
@@ -100,6 +100,9 @@ template<class TypeTag> class FVPressure2P: public FVPressure<TypeTag>
 {
     typedef FVPressure<TypeTag> ParentType;
 
+    //the model implementation
+    typedef typename GET_PROP_TYPE(TypeTag, PressureModel) Implementation;
+
     typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
     typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
     typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem;
@@ -300,7 +303,7 @@ public:
         // iterate through leaf grid
         for (const auto& element : Dune::elements(problem_.gridView()))
         {
-            storePressureSolution(element);
+            asImp_().storePressureSolution(element);
         }
     }
 
@@ -547,6 +550,14 @@ public:
     }
 
 private:
+    //! Returns the implementation of the problem (i.e. static polymorphism)
+    Implementation &asImp_()
+    { return *static_cast<Implementation *>(this); }
+
+    //! \copydoc Dumux::IMPETProblem::asImp_()
+    const Implementation &asImp_() const
+    { return *static_cast<const Implementation *>(this); }
+
     Problem& problem_;
     const GlobalPosition& gravity_; //!< vector including the gravity constant
 
diff --git a/dumux/porousmediumflow/2p/sequential/transport/cellcentered/saturation.hh b/dumux/porousmediumflow/2p/sequential/transport/cellcentered/saturation.hh
index 8aad8fb53b..851f73f4a3 100644
--- a/dumux/porousmediumflow/2p/sequential/transport/cellcentered/saturation.hh
+++ b/dumux/porousmediumflow/2p/sequential/transport/cellcentered/saturation.hh
@@ -132,6 +132,7 @@ class FVSaturation2P: public FVTransport<TypeTag>
     typedef Dune::FieldVector<Scalar, dimWorld> GlobalPosition;
     typedef Dune::FieldVector<Scalar, dim> DimVector;
 
+protected:
     CapillaryFlux& capillaryFlux()
     {
         return *capillaryFlux_;
@@ -261,7 +262,7 @@ public:
         if (this->enableLocalTimeStepping())
             this->innerUpdate(updateVec);
         else
-            updateSaturationSolution(updateVec);
+            asImp_().updateSaturationSolution(updateVec);
     }
 
     /*! \brief Updates the primary transport variable.
@@ -272,7 +273,7 @@ public:
      */
     void updateTransportedQuantity(TransportSolutionType& updateVec, Scalar dt)
     {
-        updateSaturationSolution(updateVec, dt);
+        asImp_().updateSaturationSolution(updateVec, dt);
     }
 
     /*! \brief Globally updates the saturation solution
diff --git a/dumux/porousmediumflow/sequential/cellcentered/pressure.hh b/dumux/porousmediumflow/sequential/cellcentered/pressure.hh
index 4c0eb87e37..c8390eeb5d 100644
--- a/dumux/porousmediumflow/sequential/cellcentered/pressure.hh
+++ b/dumux/porousmediumflow/sequential/cellcentered/pressure.hh
@@ -225,7 +225,7 @@ public:
      */
     void update()
     {
-        assemble(false); Dune::dinfo << "pressure calculation"<< std::endl;
+        asImp_().assemble(false); Dune::dinfo << "pressure calculation"<< std::endl;
         solve();
 
         return;
@@ -431,9 +431,8 @@ void FVPressure<TypeTag>::assemble(bool first)
                     int eIdxGlobalJ = problem_.variables().index(elementNeighbor);
 
                     // check for hanging nodes
-                    // take a hanging node never from the element with smaller level!
                     bool haveSameLevel = (element.level() == elementNeighbor.level());
-                    // calculate only from one side, but add matrix entries for both sides
+                    // calculate only from one side (except for hanging nodes), but add matrix entries for both sides
                     // the last condition is needed to properly assemble in the presence
                     // of ghost elements
                     if (GET_PROP_VALUE(TypeTag, VisitFacesOnlyOnce)
@@ -441,7 +440,6 @@ void FVPressure<TypeTag>::assemble(bool first)
                         && elementNeighbor.partitionType() == Dune::InteriorEntity)
                         continue;
 
-                    //check for hanging nodes
                     entries = 0;
                     asImp_().getFlux(entries, intersection, cellDataI, first);
 
-- 
GitLab