diff --git a/MeshLib/Elements/Element.cpp b/MeshLib/Elements/Element.cpp index e2866d0cbefd2556cddfe75187e55d0d7f89139b..a2b010aa34160544ee9dc392179aa6a564f3f020 100644 --- a/MeshLib/Elements/Element.cpp +++ b/MeshLib/Elements/Element.cpp @@ -23,7 +23,7 @@ namespace MeshLib { Element::Element(std::size_t id) - : _nodes(nullptr), _id(id), _content(-1.0), _neighbors(nullptr) + : _nodes(nullptr), _id(id), _neighbors(nullptr) { } diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h index 65b62a6bf9d97397f812b0d2c7770d6f2971c124..590527f20a45ae492330ed9bec8bbcb3af0f4ffe 100644 --- a/MeshLib/Elements/Element.h +++ b/MeshLib/Elements/Element.h @@ -43,7 +43,7 @@ public: std::optional<unsigned> addNeighbor(Element* e); /// Returns the length, area or volume of a 1D, 2D or 3D element - double getContent() const { return _content; } + virtual double getContent() const = 0; /** * Get node with local index i where i should be at most the number @@ -194,8 +194,6 @@ protected: Node** _nodes; std::size_t _id; - /// Content corresponds to length for 1D, area for 2D, and volume for 3D elements - double _content; Element** _neighbors; /// Sets the neighbor over the face with \c face_id to the given \c diff --git a/MeshLib/Elements/TemplateElement-impl.h b/MeshLib/Elements/TemplateElement-impl.h index 7a210f3f4395ba6c10489f4f617dc5c10b19fc51..27d4890435072b9a65c1d21eab4b11164b22af91 100644 --- a/MeshLib/Elements/TemplateElement-impl.h +++ b/MeshLib/Elements/TemplateElement-impl.h @@ -20,7 +20,6 @@ TemplateElement<ELEMENT_RULE>::TemplateElement(Node* nodes[n_all_nodes], std::si this->_nodes = nodes; 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; } @@ -33,7 +32,6 @@ TemplateElement<ELEMENT_RULE>::TemplateElement(std::array<Node*, n_all_nodes> co std::copy(nodes.begin(), nodes.end(), this->_nodes); 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; } @@ -52,11 +50,15 @@ TemplateElement<ELEMENT_RULE>::TemplateElement(const TemplateElement &e) { this->_neighbors[i] = e._neighbors[i]; } - this->_content = e.getContent(); this->space_dimension_ = e.space_dimension_; } +template <class ELEMENT_RULE> +double TemplateElement<ELEMENT_RULE>::getContent() const +{ + return ELEMENT_RULE::computeVolume(this->_nodes); +} namespace details { diff --git a/MeshLib/Elements/TemplateElement.h b/MeshLib/Elements/TemplateElement.h index db06fbebba0bf562e75d3d8d3e5218cc4f3c3267..2de5766335ca00c1b40b5c6b3346a99f5acd931a 100644 --- a/MeshLib/Elements/TemplateElement.h +++ b/MeshLib/Elements/TemplateElement.h @@ -209,6 +209,7 @@ public: return ELEMENT_RULE::testElementNodeOrder(*this); } + double getContent() const override final; }; } // namespace MeshLib