diff --git a/MeshLib/Elements/Element.cpp b/MeshLib/Elements/Element.cpp index da7506ef581efe4b2829deeddc91242b5b1eaa82..e2866d0cbefd2556cddfe75187e55d0d7f89139b 100644 --- a/MeshLib/Elements/Element.cpp +++ b/MeshLib/Elements/Element.cpp @@ -82,20 +82,6 @@ std::optional<unsigned> Element::addNeighbor(Element* e) return std::optional<unsigned>(); } -const Element* Element::getNeighbor(unsigned i) const -{ -#ifndef NDEBUG - if (i < getNumberOfNeighbors()) -#endif - { - return _neighbors[i]; - } -#ifndef NDEBUG - ERR("Error in MeshLib::Element::getNeighbor() - Index does not exist."); - return nullptr; -#endif -} - const Node* Element::getNode(unsigned i) const { #ifndef NDEBUG diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h index 791a7fab9bfbdd8da5ffb5f7c764d26dcb467da3..65b62a6bf9d97397f812b0d2c7770d6f2971c124 100644 --- a/MeshLib/Elements/Element.h +++ b/MeshLib/Elements/Element.h @@ -89,7 +89,7 @@ public: virtual unsigned getNumberOfFaces() const = 0; /// Get the specified neighbor. - const Element* getNeighbor(unsigned i) const; + virtual const Element* getNeighbor(unsigned i) const = 0; /// Get the number of neighbors for this element. virtual unsigned getNumberOfNeighbors() const = 0; diff --git a/MeshLib/Elements/TemplateElement.h b/MeshLib/Elements/TemplateElement.h index 16d7a5cc90ac1f018fabcd837c7bed887afb799c..db06fbebba0bf562e75d3d8d3e5218cc4f3c3267 100644 --- a/MeshLib/Elements/TemplateElement.h +++ b/MeshLib/Elements/TemplateElement.h @@ -124,6 +124,22 @@ public: return ELEMENT_RULE::n_neighbors; } + const Element* getNeighbor(unsigned i) const override + { +#ifndef NDEBUG + if (i < ELEMENT_RULE::n_neighbors) +#endif + { + return _neighbors[i]; + } +#ifndef NDEBUG + ERR("Error in MeshLib::TemplateElement::getNeighbor() - Index {:d} " + "does not exist.", + i); + return nullptr; +#endif + } + /// Get the number of linear nodes for this element. unsigned getNumberOfBaseNodes() const override { return n_base_nodes; } /// Get the number of all nodes for this element.