From 59b0c4ff5938217cab117385991d33e605c7c351 Mon Sep 17 00:00:00 2001
From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de>
Date: Wed, 8 Mar 2017 18:36:03 +0100
Subject: [PATCH] [3pwateroil] Adapt to new interface of intialPhasePresence

---
 dumux/porousmediumflow/3pwateroil/model.hh    | 39 +++++++------------
 .../implicit/3pwateroilsagdproblem.hh         |  6 +--
 2 files changed, 14 insertions(+), 31 deletions(-)

diff --git a/dumux/porousmediumflow/3pwateroil/model.hh b/dumux/porousmediumflow/3pwateroil/model.hh
index 02d0582309..5a30c8825e 100644
--- a/dumux/porousmediumflow/3pwateroil/model.hh
+++ b/dumux/porousmediumflow/3pwateroil/model.hh
@@ -152,38 +152,25 @@ public:
 
         setSwitched_(false);
 
-        if (isBox)
-        {
-            for (const auto& vertex : vertices(this->gridView_()))
-            {
-                int globalIdx = this->dofMapper().index(vertex);
-                const GlobalPosition &globalPos = vertex.geometry().corner(0);
-
-                // initialize phase presence
-                staticDat_[globalIdx].phasePresence
-                    = this->problem_().initialPhasePresence(vertex, globalIdx,
-                                                        globalPos);
-                staticDat_[globalIdx].wasSwitched = false;
+        FVElementGeometry fvGeometry;
 
-                staticDat_[globalIdx].oldPhasePresence
-                    = staticDat_[globalIdx].phasePresence;
-            }
-        }
-        else
+        for (const auto& element : elements(this->gridView_()))
         {
-            for (const auto& element : elements(this->gridView_()))
+            // deal with the current element
+            fvGeometry.update(this->gridView_(), element);
+
+            // loop over all element vertices, i.e. sub control volumes
+            for (int scvIdx = 0; scvIdx < fvGeometry.numScv; scvIdx++)
             {
-                int globalIdx = this->dofMapper().index(element);
-                const GlobalPosition &globalPos = element.geometry().center();
+                // get the global index of the degree of freedom
+                int dofIdxGlobal = this->dofMapper().subIndex(element, scvIdx, dofCodim);
 
                 // initialize phase presence
-                staticDat_[globalIdx].phasePresence
-                    = this->problem_().initialPhasePresence(*this->gridView_().template begin<dim> (),
-                                                            globalIdx, globalPos);
-                staticDat_[globalIdx].wasSwitched = false;
+                staticDat_[dofIdxGlobal].phasePresence = this->problem_().initialPhasePresence(element, fvGeometry, scvIdx);
+
+                staticDat_[dofIdxGlobal].wasSwitched = false;
 
-                staticDat_[globalIdx].oldPhasePresence
-                    = staticDat_[globalIdx].phasePresence;
+                staticDat_[dofIdxGlobal].oldPhasePresence = staticDat_[dofIdxGlobal].phasePresence;
             }
         }
     }
diff --git a/test/porousmediumflow/3pwateroil/implicit/3pwateroilsagdproblem.hh b/test/porousmediumflow/3pwateroil/implicit/3pwateroilsagdproblem.hh
index ff96757056..0602f0da37 100644
--- a/test/porousmediumflow/3pwateroil/implicit/3pwateroilsagdproblem.hh
+++ b/test/porousmediumflow/3pwateroil/implicit/3pwateroilsagdproblem.hh
@@ -406,13 +406,9 @@ public:
     /*!
      * \brief Return the initial phase state inside a control volume.
      *
-     * \param vert The vertex
-     * \param globalIdx The index of the global vertex
      * \param globalPos The global position
      */
-    int initialPhasePresence(const Vertex &vert,
-                             int &globalIdx,
-                             const GlobalPosition &globalPos) const
+    int initialPhasePresenceAtPos(const GlobalPosition &globalPos) const
     {
         return wnPhaseOnly;
     }
-- 
GitLab