From fbad8e85129a5352191fabfae302cacf1fe1f94e Mon Sep 17 00:00:00 2001
From: Jonathan Youett <youett@math.fu-berlin.de>
Date: Tue, 24 Oct 2017 15:27:20 +0200
Subject: [PATCH] [bugfix] Properly implement integrationOuterNormal for leaf
 intersections

---
 dune/subgrid/subgrid/subgridintersection.hh | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/dune/subgrid/subgrid/subgridintersection.hh b/dune/subgrid/subgrid/subgridintersection.hh
index 5f9a7e7..bed83a4 100644
--- a/dune/subgrid/subgrid/subgridintersection.hh
+++ b/dune/subgrid/subgrid/subgridintersection.hh
@@ -35,12 +35,6 @@ public:
         return insideIntersect_.outerNormal(local);
     }
 
-    //! return outer normal, this should be dependent on local
-    //! coordinates for higher order boundary
-    const FieldVector<ctype, dimworld> integrationOuterNormal (const FieldVector<ctype, dim-1>& local) const {
-        return  insideIntersect_.integrationOuterNormal(local);
-    }
-
     //! return outer normal, this should be dependent on local
     //! coordinates for higher order boundary
     const FieldVector<ctype, dimworld> unitOuterNormal (const FieldVector<ctype, dim-1>& local) const {
@@ -198,6 +192,16 @@ public:
             return insideIntersect_.type();
     }
 
+    /** \brief Return outer normal scaled with the integration element. */
+    const FieldVector<ctype, dimworld> integrationOuterNormal (const FieldVector<ctype, dim-1>& local) const {
+        if (neighbor() and (outside_.level() > inside_.level())) {
+            auto normal = outsideIntersect_.integrationOuterNormal(outsideIntersect_.geometry().local(insideIntersect_.geometry().global(local)));
+            normal *= -1;
+            return normal;
+        } else
+          return  insideIntersect_.integrationOuterNormal(local);
+    }
+
     /*! @brief Return unit outer normal at the center of the intersection geometry */
     FieldVector<typename GridImp::ctype, dimworld> centerUnitOuterNormal () const
     {
@@ -396,6 +400,11 @@ public:
         return insideIntersect_.centerUnitOuterNormal();
     }
 
+    /** \brief Return outer normal scaled with the integration element. */
+    const FieldVector<ctype, dimworld> integrationOuterNormal (const FieldVector<ctype, dim-1>& local) const {
+       return insideIntersect_.integrationOuterNormal(local);
+    }
+
     //! intersection of codimension 1 of this neighbor with element where
     //! iteration started.
     //! Here returned element is in LOCAL coordinates of the element
-- 
GitLab