diff --git a/MeshLib/Node.cpp b/MeshLib/Node.cpp index e147769af02dd5fb10eb1f0a881b4148710545e6..a212f11539b0f91ff3dd6c0bab2e594c11253790 100644 --- a/MeshLib/Node.cpp +++ b/MeshLib/Node.cpp @@ -49,5 +49,18 @@ void Node::updateCoordinates(double x, double y, double z) _elements[i]->computeVolume(); } +bool isBaseNode(Node const& node) +{ + // Check if node is connected. + if (node.getNumberOfElements() == 0) + return true; + + // In a mesh a node always belongs to at least one element. + auto const e = node.getElement(0); + + auto const n_base_nodes = e->getNumberOfBaseNodes(); + auto const local_index = e->getNodeIDinElement(&node); + return local_index < n_base_nodes; +} } diff --git a/MeshLib/Node.h b/MeshLib/Node.h index dc105a3a24b0d61647f92120e3b174395e5bffe5..558561ef257baaa5281998c1819203051a7fd086 100644 --- a/MeshLib/Node.h +++ b/MeshLib/Node.h @@ -102,4 +102,8 @@ protected: std::vector<Element*> _elements; }; /* class */ +/// Returns true if the given node is a base node of a (first) element, or if it +/// is not connected to any element i.e. an unconnected node. +bool isBaseNode(Node const& node); + } /* namespace */