From 5184f9adcf64ab7be2ee6c226f0ca8d45d55bee4 Mon Sep 17 00:00:00 2001
From: Bernd Flemisch <bernd@iws.uni-stuttgart.de>
Date: Thu, 16 Oct 2014 14:22:03 +0000
Subject: [PATCH] [fvvelocity1p] store geometry reference

Without storing the geometry, the call
  const JacobianTransposed& jacT = eIt->geometry().jacobianTransposed()
effectively resulted in an all-zero matrix, once optimization >=-O1 is
turned on.

This is very disturbing, since such code might be in quite some places.
We have to investigate this thoroughly.

Discussed with and reviewed by Martin S.



git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@13509 2fb0f335-1f38-0410-981e-8018bf24f1b0
---
 dumux/decoupled/1p/diffusion/fv/fvvelocity1p.hh | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/dumux/decoupled/1p/diffusion/fv/fvvelocity1p.hh b/dumux/decoupled/1p/diffusion/fv/fvvelocity1p.hh
index b8a62f8d14..a5679dca9f 100644
--- a/dumux/decoupled/1p/diffusion/fv/fvvelocity1p.hh
+++ b/dumux/decoupled/1p/diffusion/fv/fvvelocity1p.hh
@@ -141,19 +141,20 @@ public:
             for (int i = 0; i < dim; i++)
                 refVelocity[i] = 0.5 * (flux[2*i + 1] - flux[2*i]);
 
-            typedef Dune::ReferenceElements<Scalar, dim> ReferenceElements;
+            const typename Element::Geometry& geometry = eIt->geometry();
 
-            const Dune::FieldVector<Scalar, dim>& localPos = ReferenceElements::general(eIt->geometry().type()).position(0,
-                    0);
+            typedef Dune::ReferenceElements<Scalar, dim> ReferenceElements;
+            const Dune::FieldVector<Scalar, dim>& localPos 
+              = ReferenceElements::general(geometry.type()).position(0, 0);
 
             // get the transposed Jacobian of the element mapping
             const typename Element::Geometry::JacobianTransposed& jacobianT = 
-                eIt->geometry().jacobianTransposed(localPos);
+                geometry.jacobianTransposed(localPos);
 
             // calculate the element velocity by the Piola transformation
             Dune::FieldVector<Scalar, dim> elementVelocity(0);
             jacobianT.umtv(refVelocity, elementVelocity);
-            elementVelocity /= eIt->geometry().integrationElement(localPos);
+            elementVelocity /= geometry.integrationElement(localPos);
 
             velocity[globalIdx] = elementVelocity;
         }
-- 
GitLab