From 2df5e29f7d02858d14a809bda4489d4dc55f66f5 Mon Sep 17 00:00:00 2001
From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de>
Date: Fri, 9 Dec 2016 13:10:35 +0100
Subject: [PATCH] [staggeredGrid][stencils] Use local information to get
 neighbor elem

---
 dumux/discretization/staggered/stencils.hh | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/dumux/discretization/staggered/stencils.hh b/dumux/discretization/staggered/stencils.hh
index f977e8966b..02cf779939 100644
--- a/dumux/discretization/staggered/stencils.hh
+++ b/dumux/discretization/staggered/stencils.hh
@@ -111,22 +111,26 @@ class StaggeredFaceStencils
 
 public:
     void update(const Problem& problem,
-                const SubControlVolumeFace& scvf)
+                const SubControlVolumeFace& scvf,
+                const FVElementGeometry& fvGeometry)
     {
         faceToCellCenterStencil_.clear();
         faceToFaceStencil_.clear();
+        const int eIdx = scvf.insideScvIdx();
 
-        faceToCellCenterStencil_.push_back(scvf.insideScvIdx());
+        faceToCellCenterStencil_.push_back(eIdx);
 
         faceToFaceStencil_.push_back(scvf.dofIndexSelf());
         faceToFaceStencil_.push_back(scvf.dofIndexOpposite());
 
         for(const auto& data : scvf.pairData())
         {
-            const auto& outerParallelElementDofIdx = data.outerParallelElementDofIdx;
-            const auto& outerParallelFaceDofIdx = data.outerParallelFaceDofIdx;
-            if(outerParallelElementDofIdx >= 0)
+            auto& normalFace = fvGeometry.scvf(eIdx, data.localNormalFaceIdx);
+            const auto outerParallelElementDofIdx = normalFace.outsideScvIdx();
+            if(!normalFace.boundary())
                 faceToCellCenterStencil_.push_back(outerParallelElementDofIdx);
+
+            const auto& outerParallelFaceDofIdx = data.outerParallelFaceDofIdx;
             if(outerParallelFaceDofIdx >= 0)
                 faceToFaceStencil_.push_back(outerParallelFaceDofIdx);
 
@@ -134,7 +138,6 @@ public:
             if(!scvf.boundary())
                 faceToFaceStencil_.push_back(data.normalPair.second);
         }
-
     }
 
      //! The full face stencil (all dofs this face is interacting with)
@@ -198,7 +201,7 @@ public:
             // loop over sub control faces
             for (auto&& scvf : scvfs(fvGeometry))
             {
-                faceStencils_[scvf.index()].update(problem, scvf);
+                faceStencils_[scvf.index()].update(problem, scvf, fvGeometry);
 
                 const IndexType idx = scvf.dofIndexSelf();
 
-- 
GitLab