From 5240401163382a9f2f1910e4bff497f7668b5e30 Mon Sep 17 00:00:00 2001
From: Lisa Julia Nebel <lisa_julia.nebel@tu-dresden.de>
Date: Mon, 5 Jul 2021 08:15:44 +0200
Subject: [PATCH] Fix error in surfacecosseratenergy

The contravariant base vectors were not calculated correctly.
The contravariant base vectors are the *columns* of the inverse of the covariant matrix, not the rows.
To fix this, take the rows of the transpose of inverse of the covariant matrix.
---
 dune/gfe/surfacecosseratenergy.hh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/dune/gfe/surfacecosseratenergy.hh b/dune/gfe/surfacecosseratenergy.hh
index e34f6740..7ece7fe2 100644
--- a/dune/gfe/surfacecosseratenergy.hh
+++ b/dune/gfe/surfacecosseratenergy.hh
@@ -263,6 +263,9 @@ RT energy(const typename Basis::LocalView& localView,
 
       auto aContravariant = aCovariant;
       aContravariant.invert();
+      // The contravariant base vectors are the *columns* of the inverse of the covariant matrix
+      // To get an easier access to the columns, we use the transpose of the contravariant matrix
+      aContravariant = Dune::GFE::transpose(aContravariant);
 
       Dune::FieldMatrix<double,3,3> a(0);
       for (int alpha=0; alpha<boundaryDim; alpha++)
-- 
GitLab