From dc0554655ebbd05ac7e033fea5acd36cc883f26d Mon Sep 17 00:00:00 2001
From: Oliver Sander <oliver.sander@tu-dresden.de>
Date: Mon, 15 Jan 2018 13:53:08 +0100
Subject: [PATCH] Add stubs to allow building projected FE with
 OrthogonalMatrix

---
 dune/gfe/orthogonalmatrix.hh | 112 ++++++++++++++++++++++++++++++++++-
 1 file changed, 109 insertions(+), 3 deletions(-)

diff --git a/dune/gfe/orthogonalmatrix.hh b/dune/gfe/orthogonalmatrix.hh
index 2e00270a..36d7c10b 100644
--- a/dune/gfe/orthogonalmatrix.hh
+++ b/dune/gfe/orthogonalmatrix.hh
@@ -3,6 +3,8 @@
 
 #include <dune/common/fmatrix.hh>
 
+#include <dune/gfe/skewmatrix.hh>
+
 /** \brief An orthogonal \f$ n \times n \f$ matrix
  * \tparam T Type of the matrix entries
  * \tparam N Space dimension
@@ -11,7 +13,24 @@ template <class T, int N>
 class OrthogonalMatrix
 {
 public:
-    
+  /** \brief The type used for coordinates */
+  typedef T ctype;
+
+  /** \brief Dimension of the manifold formed by the orthogonal matrices */
+  static const int dim = N*(N-1)/2;
+
+  /** \brief Coordinates are embedded into a Euclidean space of N x N - matrices */
+  static const int embeddedDim = N*N;
+
+  /** \brief The type used for global coordinates */
+  typedef Dune::FieldVector<T,embeddedDim> CoordinateType;
+
+  /** \brief Member of the corresponding Lie algebra.  This really is a skew-symmetric matrix */
+  typedef Dune::FieldVector<T,dim> TangentVector;
+
+  /** \brief A tangent vector as a vector in the surrounding coordinate space */
+  typedef Dune::FieldVector<T,embeddedDim> EmbeddedTangentVector;
+
     /** \brief Default constructor -- leaves the matrix uninitialized */
     OrthogonalMatrix()
     {}
@@ -24,6 +43,15 @@ public:
     : data_(matrix)
     {}
 
+    /** \brief Copy constructor
+     *
+     * It is not checked whether the matrix is really orthogonal
+     */
+    explicit OrthogonalMatrix(const CoordinateType& other)
+    {
+      DUNE_THROW(Dune::NotImplemented, "constructor");
+    }
+
     /** \brief Const access to the matrix entries */
     const Dune::FieldMatrix<T,N,N>& data() const
     {
@@ -63,7 +91,85 @@ public:
                 
         return result;
     }
-    
+
+    /** \brief Rebind the OrthogonalMatrix to another coordinate type */
+    template<class U>
+    struct rebind
+    {
+      typedef OrthogonalMatrix<U,N> other;
+    };
+
+    OrthogonalMatrix& operator= (const CoordinateType& other)
+    {
+      std::size_t idx = 0;
+      for (int i=0; i<N; i++)
+        for (int j=0; j<N; j++)
+          data_[i][j] = other[idx++];
+      return *this;
+    }
+
+  /** \brief The exponential map from a given point $p \in SO(n)$.
+
+    \param v A tangent vector.
+   */
+  static OrthogonalMatrix<T,3> exp(const OrthogonalMatrix<T,N>& p, const TangentVector& v)
+  {
+    DUNE_THROW(Dune::NotImplemented, "exp");
+  }
+
+    /** \brief Return the actual matrix */
+    void matrix(Dune::FieldMatrix<T,N,N>& m) const
+  {
+      m = data_;
+  }
+
+  /** \brief Project tangent vector of R^n onto the normal space space */
+  EmbeddedTangentVector projectOntoNormalSpace(const EmbeddedTangentVector& v) const
+  {
+    DUNE_THROW(Dune::NotImplemented, "projectOntoNormalSpace");
+  }
+
+  /** \brief The Weingarten map */
+  EmbeddedTangentVector weingarten(const EmbeddedTangentVector& z, const EmbeddedTangentVector& v) const
+  {
+    EmbeddedTangentVector result;
+    DUNE_THROW(Dune::NotImplemented, "weingarten");
+    return result;
+  }
+
+  static OrthogonalMatrix<T,N> projectOnto(const CoordinateType& p)
+  {
+    DUNE_THROW(Dune::NotImplemented, "projectOnto");
+  }
+
+  // TODO return type is wrong
+  static Dune::FieldMatrix<T,1,1> derivativeOfProjection(const CoordinateType& p)
+  {
+    Dune::FieldMatrix<T,1,1> result;
+    return result;
+  }
+
+  /** \brief The global coordinates, if you really want them */
+  CoordinateType globalCoordinates() const
+  {
+    CoordinateType result;
+    std::size_t idx = 0;
+
+    for (int i=0; i<N; i++)
+      for (int j=0; j<N; j++)
+        result[idx++] = data_[i][j];
+
+    return result;
+  }
+
+  /** \brief Compute an orthonormal basis of the tangent space of SO(n). */
+  Dune::FieldMatrix<T,dim,embeddedDim> orthonormalFrame() const
+  {
+    Dune::FieldMatrix<T,dim,embeddedDim> result;
+    DUNE_THROW(Dune::NotImplemented, "orthonormalFrame");
+    return result;
+  }
+
 private:
     
     /** \brief The actual data */
@@ -71,4 +177,4 @@ private:
     
 };
 
-#endif // ORTHOGONAL_MATRIX_HH
\ No newline at end of file
+#endif // ORTHOGONAL_MATRIX_HH
-- 
GitLab