diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h index 4e2df7cce9885e5b61e2cb133445ee053fa9f035..1216bad930bfc731fb3880f7bba78e42e441f342 100644 --- a/MeshLib/Elements/Element.h +++ b/MeshLib/Elements/Element.h @@ -86,9 +86,13 @@ public: /// Returns the i-th face of the element. virtual const Element* getFace(unsigned i) const = 0; + virtual const Element* getBoundary(unsigned i) const = 0; + /// Returns the ID of the element. virtual std::size_t getID() const final { return _id; } + virtual unsigned getNumberOfBoundaries() const = 0; + /// Get the number of edges for this element. virtual unsigned getNumberOfEdges() const = 0; diff --git a/MeshLib/Elements/TemplateElement.h b/MeshLib/Elements/TemplateElement.h index f2afb2a7c20b359583e1c9fe165f8919260aad73..a05d7cab6e666d519afe60f273e3ff7aeb4ffdf6 100644 --- a/MeshLib/Elements/TemplateElement.h +++ b/MeshLib/Elements/TemplateElement.h @@ -17,6 +17,8 @@ #include "MeshLib/Node.h" #include "MeshLib/Elements/Element.h" +#include "MeshLib/Elements/FaceRule.h" +#include "MeshLib/Elements/CellRule.h" #include "MeshLib/Elements/ElementErrorCode.h" namespace MeshLib @@ -85,6 +87,33 @@ public: return ELEMENT_RULE::getFace(this, i); } + /// Returns the boundary i of the element. + const Element* getBoundary(unsigned i) const override + { + if constexpr (std::is_convertible<ELEMENT_RULE, FaceRule>::value) + { + return ELEMENT_RULE::EdgeReturn::getEdge(this, i); + } + if constexpr (std::is_convertible<ELEMENT_RULE, CellRule>::value) + { + return ELEMENT_RULE::getFace(this, i); + } + OGS_FATAL("TemplateElement::getBoundary for boundary %u failed.", i); + } + + /// Returns the number of boundaries of the element. + unsigned getNumberOfBoundaries() const override + { + if constexpr (std::is_convertible<ELEMENT_RULE, FaceRule>::value) + { + return ELEMENT_RULE::n_edges; + } + else + { + return ELEMENT_RULE::n_faces; + } + } + /// Get the number of edges for this element. unsigned getNumberOfEdges() const override { return ELEMENT_RULE::n_edges; } /// Get the number of faces for this element.