From a88d5041bb70708cba6f97ccc3ae1826999aa5c6 Mon Sep 17 00:00:00 2001
From: Wenqing Wang <wenqing.wang@ufz.de>
Date: Wed, 5 May 2021 15:51:57 +0200
Subject: [PATCH] [ElementCoordinatesMappingLocal] Enabled it work for inclined
 2D mesh and

 1D elements of inclined 2D mesh.
---
 MeshLib/ElementCoordinatesMappingLocal.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/MeshLib/ElementCoordinatesMappingLocal.cpp b/MeshLib/ElementCoordinatesMappingLocal.cpp
index 34692d62cae..3f9e733d842 100644
--- a/MeshLib/ElementCoordinatesMappingLocal.cpp
+++ b/MeshLib/ElementCoordinatesMappingLocal.cpp
@@ -74,7 +74,8 @@ ElementCoordinatesMappingLocal::ElementCoordinatesMappingLocal(
     const Element& e, const unsigned global_dim)
     : _global_dim(global_dim), _matR2global(Eigen::Matrix3d::Identity())
 {
-    assert(e.getDimension() <= global_dim);
+    unsigned const space_dim = std::max(e.space_dimension_, _global_dim);
+    assert(e.getDimension() <= space_dim);
     _points.reserve(e.getNumberOfNodes());
     for (unsigned i = 0; i < e.getNumberOfNodes(); i++)
     {
@@ -83,10 +84,10 @@ ElementCoordinatesMappingLocal::ElementCoordinatesMappingLocal(
 
     auto const element_dim = e.getDimension();
 
-    if (global_dim != element_dim)
+    if (element_dim != space_dim)
     {
         _matR2global =
-            detail::getRotationMatrixToGlobal(element_dim, global_dim, _points);
+            detail::getRotationMatrixToGlobal(element_dim, space_dim, _points);
         detail::rotateToLocal(_matR2global.transpose(), _points);
     }
 }
-- 
GitLab