diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C index 4e4d745a63..287db3ab31 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.C +++ b/src/OpenFOAM/meshes/meshShapes/face/face.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2021-2022 OpenCFD Ltd. + Copyright (C) 2021-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -812,7 +812,7 @@ Foam::edgeList Foam::face::rcEdges() const int Foam::face::edgeDirection(const Foam::edge& e) const { - const label idx = find(e.first()); + const label idx = labelList::find(e.first()); if (idx != -1) { diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H index 96167660c0..7f37647997 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.H +++ b/src/OpenFOAM/meshes/meshShapes/face/face.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -365,6 +365,15 @@ public: // and rcEdge 1 is from [n-1] to [n-2] edgeList rcEdges() const; + + // Searching + + //- Regular contains(pointi) tests + using labelList::contains; + + //- True if face contains(edge) + inline bool contains(const Foam::edge& e) const; + //- Test the edge direction on the face // \return // - 0: edge not found on the face diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceI.H b/src/OpenFOAM/meshes/meshShapes/face/faceI.H index 73902597a1..490f5b76d2 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceI.H +++ b/src/OpenFOAM/meshes/meshShapes/face/faceI.H @@ -232,6 +232,12 @@ inline bool Foam::face::connected(const FixedList& other) const } +inline bool Foam::face::contains(const Foam::edge& e) const +{ + return (edgeDirection(e) != 0); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // inline void Foam::face::operator+=(const label vertexOffset) diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H index c3753be895..300a5aa0d1 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -319,6 +319,15 @@ public: // and rcEdge 1 is from [n-1] to [n-2] inline edgeList rcEdges() const; + + // Searching + + //- Regular contains(pointi) tests + using FixedList::contains; + + //- True if face contains(edge) + inline bool contains(const Foam::edge& e) const; + //- Test the edge direction on the face // \return // - +1: forward (counter-clockwise) on the face diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H index d839354690..f2fb6446a3 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -446,24 +446,30 @@ inline int Foam::triFace::edgeDirection(const Foam::edge& e) const { if (e.first() == a()) { - if (e.second() == b()) return 1; // Forward - if (e.second() == c()) return -1; // Reverse + if (e.second() == b()) return 1; // edge 0 - forward + if (e.second() == c()) return -1; // edge 2 - reverse } if (e.first() == b()) { - if (e.second() == c()) return 1; // Forward - if (e.second() == a()) return -1; // Reverse + if (e.second() == c()) return 1; // edge 1 - forward + if (e.second() == a()) return -1; // edge 0 - reverse } if (e.first() == c()) { - if (e.second() == a()) return 1; // Forward - if (e.second() == b()) return -1; // Reverse + if (e.second() == a()) return 1; // edge 2 - forward + if (e.second() == b()) return -1; // edge 1 - reverse } return 0; // Not found } +inline bool Foam::triFace::contains(const Foam::edge& e) const +{ + return (edgeDirection(e) != 0); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // inline void Foam::triFace::operator+=(const label vertexOffset) diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C index 5ddb6f5b23..0698c0eb16 100644 --- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C +++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C @@ -106,7 +106,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace const Foam::face& otherFace = pFaces[facei]; - label edDir = otherFace.edgeDirection(e); + const auto edDir = otherFace.edgeDirection(e); if (edDir == 0) { @@ -128,7 +128,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace label eIndex = -1; - if (edDir == 1) + if (edDir > 0) { // Edge is in the forward circulation of this face, so // work with the start point of the edge @@ -136,7 +136,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace } else { - // edDir == -1, so the edge is in the reverse + // (edge-direction < 0) - edge is in the reverse // circulation of this face, so work with the end // point of the edge eIndex = otherFace.find(e.end()); diff --git a/src/mesh/snappyHexMesh/refinementSurfaces/refinementSurfaces.C b/src/mesh/snappyHexMesh/refinementSurfaces/refinementSurfaces.C index 8c31035de5..81b70f72e9 100644 --- a/src/mesh/snappyHexMesh/refinementSurfaces/refinementSurfaces.C +++ b/src/mesh/snappyHexMesh/refinementSurfaces/refinementSurfaces.C @@ -1026,11 +1026,12 @@ void Foam::refinementSurfaces::setCurvatureMinLevelFields const auto& f1 = ts[eFaces[1]]; const vector n0 = f0.unitNormal(points); - - const int dir0 = f0.edgeDirection(meshE); - const int dir1 = f1.edgeDirection(meshE); vector n1 = f1.unitNormal(points); - if (dir0 == dir1) + + const auto dir0 = f0.edgeDirection(meshE); + const auto dir1 = f1.edgeDirection(meshE); + + if (dir0 && ((dir0 > 0) == (dir1 > 0))) { // Flip since use edge in same direction // (should not be the case for 'proper' diff --git a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C index bf7069fd35..2b99b2443a 100644 --- a/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C +++ b/src/meshTools/triSurface/surfaceFeatures/surfaceFeatures.C @@ -587,7 +587,7 @@ Foam::surfaceFeatures::surfaceFeatures::checkFlatRegionEdge forAll(bin0, i) { const labelledTri& t = surf.localFaces()[eFaces[bin0[i]]]; - int dir = t.edgeDirection(e); + const auto dir = t.edgeDirection(e); if (dir > 0) { @@ -610,7 +610,7 @@ Foam::surfaceFeatures::surfaceFeatures::checkFlatRegionEdge forAll(bin1, i) { const labelledTri& t = surf.localFaces()[eFaces[bin1[i]]]; - int dir = t.edgeDirection(e); + const auto dir = t.edgeDirection(e); label myRegionAndNormal; if (dir > 0) diff --git a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C index 1c77ad3f96..f3949c5b96 100644 --- a/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C +++ b/src/parallel/distributed/distributedTriSurfaceMesh/distributedTriSurfaceMesh.C @@ -1174,8 +1174,7 @@ Foam::label Foam::distributedTriSurfaceMesh::findOtherFace { if (facei != nearFacei) { - int dir = surf[facei].edgeDirection(e); - if (dir != 0) + if (surf[facei].contains(e)) { return facei; } @@ -1211,7 +1210,7 @@ void Foam::distributedTriSurfaceMesh::calcFaceFaces { if (otherFacei != facei) { - if (s[otherFacei].edgeDirection(e) != 0) + if (s[otherFacei].contains(e)) { if (!nbrs.find(otherFacei)) {