From d4fd0b97429a747523e04e731e7b6705528f0c79 Mon Sep 17 00:00:00 2001
From: Wenqing Wang <wenqing.wang@ufz.de>
Date: Fri, 30 Apr 2021 17:12:11 +0200
Subject: [PATCH] [Element] Added a member of space_dimension

---
 MeshLib/Elements/Element.h              | 4 +++-
 MeshLib/Elements/TemplateElement-impl.h | 6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h
index 2a29f390996..a9df40b120c 100644
--- a/MeshLib/Elements/Element.h
+++ b/MeshLib/Elements/Element.h
@@ -184,6 +184,9 @@ public:
     friend std::ostream& operator<<(std::ostream& os, Element const& e);
 #endif  // NDEBUG
 
+    /// Dimension of the space, where the element exists.
+    unsigned space_dimension_ = 3u;
+
 protected:
     /// Constructor for a generic mesh element without an array of mesh nodes.
     /// @param id     element id
@@ -201,7 +204,6 @@ protected:
     /// Sets the neighbor over the face with \c face_id to the given \c
     /// neighbor.
     void setNeighbor(Element* neighbor, unsigned const face_id);
-
 }; /* class */
 
 /// Returns true if elem is a neighbour of this element and false otherwise.
diff --git a/MeshLib/Elements/TemplateElement-impl.h b/MeshLib/Elements/TemplateElement-impl.h
index ce42a7d6a52..7a210f3f439 100644
--- a/MeshLib/Elements/TemplateElement-impl.h
+++ b/MeshLib/Elements/TemplateElement-impl.h
@@ -21,6 +21,8 @@ TemplateElement<ELEMENT_RULE>::TemplateElement(Node* nodes[n_all_nodes], std::si
     this->_neighbors = new Element*[getNumberOfNeighbors()];
     std::fill(this->_neighbors, this->_neighbors + getNumberOfNeighbors(), nullptr);
     this->_content = ELEMENT_RULE::computeVolume(this->_nodes);
+
+    this->space_dimension_ = ELEMENT_RULE::dimension;
 }
 
 template <class ELEMENT_RULE>
@@ -32,6 +34,8 @@ TemplateElement<ELEMENT_RULE>::TemplateElement(std::array<Node*, n_all_nodes> co
     this->_neighbors = new Element*[getNumberOfNeighbors()];
     std::fill(this->_neighbors, this->_neighbors + getNumberOfNeighbors(), nullptr);
     this->_content = ELEMENT_RULE::computeVolume(this->_nodes);
+
+    this->space_dimension_ = ELEMENT_RULE::dimension;
 }
 
 template <class ELEMENT_RULE>
@@ -49,6 +53,8 @@ TemplateElement<ELEMENT_RULE>::TemplateElement(const TemplateElement &e)
         this->_neighbors[i] = e._neighbors[i];
     }
     this->_content = e.getContent();
+
+    this->space_dimension_ = e.space_dimension_;
 }
 
 
-- 
GitLab