From 21177d6088392675831dd373b649b64d11a390e5 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Fri, 19 Sep 2014 18:40:30 +0000
Subject: [PATCH] Implement the derivative of the projection onto the set of
 unit vectors

This is needed for projection-based finite elements.

The code in this patch has not been tested yet.

[[Imported from SVN: r9887]]
---
 dune/gfe/unitvector.hh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/dune/gfe/unitvector.hh b/dune/gfe/unitvector.hh
index 63ce6f72..87875bf6 100644
--- a/dune/gfe/unitvector.hh
+++ b/dune/gfe/unitvector.hh
@@ -374,6 +374,15 @@ public:
         return result;
     }
 
+    static Dune::FieldMatrix<T, N, N> derivativeOfProjection(const Dune::FieldVector<T,N>& p)
+    {
+      Dune::FieldMatrix<T,N,N> result;
+      for (int i=0; i<N; i++)
+        for (int j=0; j<N; j++)
+          result[i][j] = ( (i==j) - p[i]*p[j] / p.two_norm2() ) / p.two_norm();
+      return result;
+    }
+
     /** \brief The global coordinates, if you really want them */
     const CoordinateType& globalCoordinates() const {
         return data_;
-- 
GitLab