From a616cc77176b49f61d12b56ee8d6c6e26f361301 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Mon, 20 Jan 2020 10:37:47 +0100 Subject: [PATCH] [MeL/Elements] Impl. of interface for boundaries. --- MeshLib/Elements/Element.h | 4 ++++ MeshLib/Elements/TemplateElement.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h index 4e2df7cce98..1216bad930b 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 f2afb2a7c20..a05d7cab6e6 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. -- GitLab