mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add face/triFace contains(edge) method (#3004)
STYLE: use contains() and reduce reliance on edgeDirection -1/+1 values
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
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
|
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)
|
if (idx != -1)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -365,6 +365,15 @@ public:
|
|||||||
// and rcEdge 1 is from [n-1] to [n-2]
|
// and rcEdge 1 is from [n-1] to [n-2]
|
||||||
edgeList rcEdges() const;
|
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
|
//- Test the edge direction on the face
|
||||||
// \return
|
// \return
|
||||||
// - 0: edge not found on the face
|
// - 0: edge not found on the face
|
||||||
|
|||||||
@ -232,6 +232,12 @@ inline bool Foam::face::connected(const FixedList<label, N>& other) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::face::contains(const Foam::edge& e) const
|
||||||
|
{
|
||||||
|
return (edgeDirection(e) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline void Foam::face::operator+=(const label vertexOffset)
|
inline void Foam::face::operator+=(const label vertexOffset)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -319,6 +319,15 @@ public:
|
|||||||
// and rcEdge 1 is from [n-1] to [n-2]
|
// and rcEdge 1 is from [n-1] to [n-2]
|
||||||
inline edgeList rcEdges() const;
|
inline edgeList rcEdges() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Searching
|
||||||
|
|
||||||
|
//- Regular contains(pointi) tests
|
||||||
|
using FixedList<label, 3>::contains;
|
||||||
|
|
||||||
|
//- True if face contains(edge)
|
||||||
|
inline bool contains(const Foam::edge& e) const;
|
||||||
|
|
||||||
//- Test the edge direction on the face
|
//- Test the edge direction on the face
|
||||||
// \return
|
// \return
|
||||||
// - +1: forward (counter-clockwise) on the face
|
// - +1: forward (counter-clockwise) on the face
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2013 OpenFOAM Foundation
|
Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
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.first() == a())
|
||||||
{
|
{
|
||||||
if (e.second() == b()) return 1; // Forward
|
if (e.second() == b()) return 1; // edge 0 - forward
|
||||||
if (e.second() == c()) return -1; // Reverse
|
if (e.second() == c()) return -1; // edge 2 - reverse
|
||||||
}
|
}
|
||||||
if (e.first() == b())
|
if (e.first() == b())
|
||||||
{
|
{
|
||||||
if (e.second() == c()) return 1; // Forward
|
if (e.second() == c()) return 1; // edge 1 - forward
|
||||||
if (e.second() == a()) return -1; // Reverse
|
if (e.second() == a()) return -1; // edge 0 - reverse
|
||||||
}
|
}
|
||||||
if (e.first() == c())
|
if (e.first() == c())
|
||||||
{
|
{
|
||||||
if (e.second() == a()) return 1; // Forward
|
if (e.second() == a()) return 1; // edge 2 - forward
|
||||||
if (e.second() == b()) return -1; // Reverse
|
if (e.second() == b()) return -1; // edge 1 - reverse
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0; // Not found
|
return 0; // Not found
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::triFace::contains(const Foam::edge& e) const
|
||||||
|
{
|
||||||
|
return (edgeDirection(e) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline void Foam::triFace::operator+=(const label vertexOffset)
|
inline void Foam::triFace::operator+=(const label vertexOffset)
|
||||||
|
|||||||
@ -106,7 +106,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace
|
|||||||
|
|
||||||
const Foam::face& otherFace = pFaces[facei];
|
const Foam::face& otherFace = pFaces[facei];
|
||||||
|
|
||||||
label edDir = otherFace.edgeDirection(e);
|
const auto edDir = otherFace.edgeDirection(e);
|
||||||
|
|
||||||
if (edDir == 0)
|
if (edDir == 0)
|
||||||
{
|
{
|
||||||
@ -128,7 +128,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace
|
|||||||
|
|
||||||
label eIndex = -1;
|
label eIndex = -1;
|
||||||
|
|
||||||
if (edDir == 1)
|
if (edDir > 0)
|
||||||
{
|
{
|
||||||
// Edge is in the forward circulation of this face, so
|
// Edge is in the forward circulation of this face, so
|
||||||
// work with the start point of the edge
|
// work with the start point of the edge
|
||||||
@ -136,7 +136,7 @@ void Foam::wallBoundedParticle::crossEdgeConnectedFace
|
|||||||
}
|
}
|
||||||
else
|
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
|
// circulation of this face, so work with the end
|
||||||
// point of the edge
|
// point of the edge
|
||||||
eIndex = otherFace.find(e.end());
|
eIndex = otherFace.find(e.end());
|
||||||
|
|||||||
@ -1026,11 +1026,12 @@ void Foam::refinementSurfaces::setCurvatureMinLevelFields
|
|||||||
const auto& f1 = ts[eFaces[1]];
|
const auto& f1 = ts[eFaces[1]];
|
||||||
|
|
||||||
const vector n0 = f0.unitNormal(points);
|
const vector n0 = f0.unitNormal(points);
|
||||||
|
|
||||||
const int dir0 = f0.edgeDirection(meshE);
|
|
||||||
const int dir1 = f1.edgeDirection(meshE);
|
|
||||||
vector n1 = f1.unitNormal(points);
|
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
|
// Flip since use edge in same direction
|
||||||
// (should not be the case for 'proper'
|
// (should not be the case for 'proper'
|
||||||
|
|||||||
@ -587,7 +587,7 @@ Foam::surfaceFeatures::surfaceFeatures::checkFlatRegionEdge
|
|||||||
forAll(bin0, i)
|
forAll(bin0, i)
|
||||||
{
|
{
|
||||||
const labelledTri& t = surf.localFaces()[eFaces[bin0[i]]];
|
const labelledTri& t = surf.localFaces()[eFaces[bin0[i]]];
|
||||||
int dir = t.edgeDirection(e);
|
const auto dir = t.edgeDirection(e);
|
||||||
|
|
||||||
if (dir > 0)
|
if (dir > 0)
|
||||||
{
|
{
|
||||||
@ -610,7 +610,7 @@ Foam::surfaceFeatures::surfaceFeatures::checkFlatRegionEdge
|
|||||||
forAll(bin1, i)
|
forAll(bin1, i)
|
||||||
{
|
{
|
||||||
const labelledTri& t = surf.localFaces()[eFaces[bin1[i]]];
|
const labelledTri& t = surf.localFaces()[eFaces[bin1[i]]];
|
||||||
int dir = t.edgeDirection(e);
|
const auto dir = t.edgeDirection(e);
|
||||||
|
|
||||||
label myRegionAndNormal;
|
label myRegionAndNormal;
|
||||||
if (dir > 0)
|
if (dir > 0)
|
||||||
|
|||||||
@ -1174,8 +1174,7 @@ Foam::label Foam::distributedTriSurfaceMesh::findOtherFace
|
|||||||
{
|
{
|
||||||
if (facei != nearFacei)
|
if (facei != nearFacei)
|
||||||
{
|
{
|
||||||
int dir = surf[facei].edgeDirection(e);
|
if (surf[facei].contains(e))
|
||||||
if (dir != 0)
|
|
||||||
{
|
{
|
||||||
return facei;
|
return facei;
|
||||||
}
|
}
|
||||||
@ -1211,7 +1210,7 @@ void Foam::distributedTriSurfaceMesh::calcFaceFaces
|
|||||||
{
|
{
|
||||||
if (otherFacei != facei)
|
if (otherFacei != facei)
|
||||||
{
|
{
|
||||||
if (s[otherFacei].edgeDirection(e) != 0)
|
if (s[otherFacei].contains(e))
|
||||||
{
|
{
|
||||||
if (!nbrs.find(otherFacei))
|
if (!nbrs.find(otherFacei))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user