From 452489ff12cce6610b1ce13bb523e8efddee6a26 Mon Sep 17 00:00:00 2001
From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de>
Date: Mon, 24 Jul 2017 18:18:25 +0200
Subject: [PATCH] [3p3c][model] Adapt to new volVar interface

---
 dumux/porousmediumflow/3p3c/implicit/model.hh | 45 ++++++++++++++-----
 1 file changed, 34 insertions(+), 11 deletions(-)

diff --git a/dumux/porousmediumflow/3p3c/implicit/model.hh b/dumux/porousmediumflow/3p3c/implicit/model.hh
index 5d50e45d42..15f4010914 100644
--- a/dumux/porousmediumflow/3p3c/implicit/model.hh
+++ b/dumux/porousmediumflow/3p3c/implicit/model.hh
@@ -106,6 +106,7 @@ class ThreePThreeCModel: public GET_PROP_TYPE(TypeTag, BaseModel)
     using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables);
     using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables);
     using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
+    using ElementSolutionVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector);
     using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
 
     enum {
@@ -198,27 +199,49 @@ public:
         // update the secondary variables if global caching is enabled
         // \note we only updated if phase presence changed as the volume variables
         //       are already updated once by the switch
-        if (switchFlag_)
+        for (const auto& element : elements(this->problem_().gridView()))
         {
-            for (const auto& element : elements(this->problem_().gridView()))
-            {
-                // make sure FVElementGeometry & vol vars are bound to the element
-                auto fvGeometry = localView(this->globalFvGeometry());
-                fvGeometry.bindElement(element);
+            // make sure FVElementGeometry & vol vars are bound to the element
+            auto fvGeometry = localView(this->globalFvGeometry());
+            fvGeometry.bindElement(element);
 
+            if (switchFlag_)
+            {
                 for (auto&& scv : scvs(fvGeometry))
                 {
                     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 cell-centered models
+            if(!isBox)
+            {
+                for (auto&& scvf : scvfs(fvGeometry))
+                {
+                    // 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(), 0/*indexInElement*/).update(elemSol, this->problem_(), element, insideScv);
+                    }
+                }
             }
         }
     }
-- 
GitLab