From 0d5283a6bc408ddfcb6e5ba7f7bbdedc944a2d27 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 13 Sep 2018 09:48:01 +0200 Subject: [PATCH] ENH: added edge::valid() method - simple check for unique and non-negative point labels --- src/OpenFOAM/meshes/meshShapes/edge/edge.H | 11 +++++++---- src/OpenFOAM/meshes/meshShapes/edge/edgeI.H | 12 +++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edge.H b/src/OpenFOAM/meshes/meshShapes/edge/edge.H index 81a6d1ef3a4..ede402d50d1 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/edge.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edge.H @@ -134,6 +134,9 @@ public: // No special handling of negative point labels. inline label maxVertex() const; + //- Return true if the vertices are unique and non-negative. + inline bool valid() const; + //- Return true if point label is found in edge. // Always false for a negative label. inline bool found(const label pointLabel) const; @@ -146,19 +149,19 @@ public: // Negative point labels never connect. inline bool connects(const edge& other) const; - //- Return vertex common with otherEdge or -1 on failure + //- Return vertex common with other edge or -1 on failure // Negative point labels are never considered common between edges. inline label commonVertex(const edge& other) const; - //- Given one vertex index, return the other one. + //- Given the point label for one vertex, return the other one. // No special treatment for negative point labels. - inline label otherVertex(const label index) const; + inline label otherVertex(const label pointLabel) const; // Editing //- 'Collapse' edge by marking duplicate point labels as '-1', - // the lower vertex is retained. + //- the lower vertex is retained. // Return the effective size after collapsing. inline label collapse(); diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H index 22efb3d438a..e011a8d0d8a 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H @@ -114,6 +114,12 @@ inline Foam::label Foam::edge::maxVertex() const } +inline bool Foam::edge::valid() const +{ + return (first() != second() && first() >= 0 && second() >= 0); +} + + inline bool Foam::edge::found(const label pointLabel) const { // -1: always false @@ -166,13 +172,13 @@ inline Foam::label Foam::edge::commonVertex(const edge& other) const } -inline Foam::label Foam::edge::otherVertex(const label index) const +inline Foam::label Foam::edge::otherVertex(const label pointLabel) const { - if (index == first()) + if (pointLabel == first()) { return second(); } - if (index == second()) + if (pointLabel == second()) { return first(); } -- GitLab