From 206798e06f0c44c010603fdf22cee5b7b46aa464 Mon Sep 17 00:00:00 2001
From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de>
Date: Mon, 24 Jul 2017 18:18:09 +0200
Subject: [PATCH] [2pncmin][model] Adapt to new volVar interface

---
 .../2pncmin/implicit/model.hh                 | 40 +++++++++++--------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/dumux/porousmediumflow/2pncmin/implicit/model.hh b/dumux/porousmediumflow/2pncmin/implicit/model.hh
index b418c7e07e..b9d7159df8 100644
--- a/dumux/porousmediumflow/2pncmin/implicit/model.hh
+++ b/dumux/porousmediumflow/2pncmin/implicit/model.hh
@@ -121,6 +121,7 @@ class TwoPNCMinModel: public GET_PROP_TYPE(TypeTag, BaseModel)
     using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
     using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
     using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables);
+    using ElementSolutionVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector);
     using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
 
     enum {
@@ -233,30 +234,35 @@ public:
                     auto dofIdxGlobal = scv.dofIndex();
                     if (priVarSwitch_().wasSwitched(dofIdxGlobal))
                     {
-                        this->nonConstCurGlobalVolVars().volVars(scv).update(this->curSol()[dofIdxGlobal],
-                                                                                     this->problem_(),
-                                                                                     element,
-                                                                                     scv);
+                        const auto eIdx = this->problem_().elementMapper().index(element);
+                        const auto elemSol = this->elementSolution(element, this->curSol());
+                        this->nonConstCurGlobalVolVars().volVars(eIdx, scv.indexInElement()).update(elemSol,
+                                                                                                    this->problem_(),
+                                                                                                    element,
+                                                                                                    scv);
                     }
                 }
             }
 
-            // handle the boundary volume variables
-            for (auto&& scvf : scvfs(fvGeometry))
+            // handle the boundary volume variables for cell-centered models
+            if(!isBox)
             {
-                // if we are not on a boundary, skip the rest
-                if (!scvf.boundary())
-                    continue;
-
-                // check if boundary is a pure dirichlet boundary
-                const auto bcTypes = this->problem_().boundaryTypes(element, scvf);
-                if (bcTypes.hasOnlyDirichlet())
+                for (auto&& scvf : scvfs(fvGeometry))
                 {
-                    const auto insideScvIdx = scvf.insideScvIdx();
-                    const auto& insideScv = fvGeometry.scv(insideScvIdx);
-                    const auto dirichletPriVars = this->problem_().dirichlet(element, scvf);
+                    // if we are not on a boundary, skip the rest
+                    if (!scvf.boundary())
+                        continue;
+
+                    // check if boundary is a pure dirichlet boundary
+                    const auto bcTypes = this->problem_().boundaryTypes(element, scvf);
+                    if (bcTypes.hasOnlyDirichlet())
+                    {
+                        const auto insideScvIdx = scvf.insideScvIdx();
+                        const auto& insideScv = fvGeometry.scv(insideScvIdx);
+                        const auto elemSol = ElementSolutionVector{this->problem_().dirichlet(element, scvf)};
 
-                    this->nonConstCurGlobalVolVars().volVars(scvf.outsideScvIdx()).update(dirichletPriVars, this->problem_(), element, insideScv);
+                        this->nonConstCurGlobalVolVars().volVars(scvf.outsideScvIdx(), 0/*indexInElement*/).update(elemSol, this->problem_(), element, insideScv);
+                    }
                 }
             }
         }
-- 
GitLab