From a72c1e4f5bea551d8bdd8c77bd09e50b8c3862bd Mon Sep 17 00:00:00 2001
From: Oliver Sander <oliver.sander@tu-dresden.de>
Date: Sun, 17 Jan 2016 06:39:49 +0100
Subject: [PATCH] Introduce new evaluation methods that return their results
 by-value

I intend to move as much towards the dune-functions interface for functions,
and this is a first step.
---
 dune/gfe/embeddedglobalgfefunction.hh | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/dune/gfe/embeddedglobalgfefunction.hh b/dune/gfe/embeddedglobalgfefunction.hh
index 6708774d..1c410007 100644
--- a/dune/gfe/embeddedglobalgfefunction.hh
+++ b/dune/gfe/embeddedglobalgfefunction.hh
@@ -49,6 +49,12 @@ public:
 
     /** \brief Evaluate the function at local coordinates. */
     void evaluateLocal(const Element& element, const Dune::FieldVector<ctype,gridDim>& local, typename TargetSpace::CoordinateType& out) const
+    {
+        out = this->operator()(element,local);
+    }
+
+    /** \brief Evaluate the function at local coordinates. */
+    typename TargetSpace::CoordinateType operator()(const Element& element, const Dune::FieldVector<ctype,gridDim>& local) const
     {
         int numOfBaseFct = basis_.getLocalFiniteElement(element).localBasis().size();
 
@@ -60,12 +66,18 @@ public:
 
         // create local gfe function
         LocalGFEFunction localGFE(basis_.getLocalFiniteElement(element),localCoeff);
-        out = localGFE.evaluate(local).globalCoordinates();
+        return localGFE.evaluate(local).globalCoordinates();
     }
 
     /** \brief Evaluate the derivative of the function at local coordinates. */
     void evaluateDerivativeLocal(const Element& element, const Dune::FieldVector<ctype,gridDim>& local,
                                  Dune::FieldMatrix<ctype, embeddedDim, gridDim>& out) const
+    {
+        out = derivative(element,local);
+    }
+
+    /** \brief Evaluate the derivative of the function at local coordinates. */
+    Dune::FieldMatrix<ctype, embeddedDim, gridDim> derivative(const Element& element, const Dune::FieldVector<ctype,gridDim>& local) const
     {
         int numOfBaseFct = basis_.getLocalFiniteElement(element).localBasis().size();
 
@@ -81,11 +93,13 @@ public:
         // use it to evaluate the derivative
         Dune::FieldMatrix<ctype, embeddedDim, gridDim> refJac = localGFE.evaluateDerivative(local);
 
-        out =0.0;
+        Dune::FieldMatrix<ctype, embeddedDim, gridDim> out =0.0;
         //transform the gradient
         const Dune::FieldMatrix<double,gridDim,gridDim>& jacInvTrans = element.geometry().jacobianInverseTransposed(local);
         for (size_t k=0; k< refJac.N(); k++)
             jacInvTrans.umv(refJac[k],out[k]);
+
+        return out;
     }
 
     /** \brief Export basis */
-- 
GitLab