mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
use PatchTools algorithms
This commit is contained in:
@ -58,7 +58,7 @@ Foam::PatchTools::checkOrientation
|
||||
{
|
||||
Info<< "Face[" << faceI << "] " << p[faceI]
|
||||
<< " has fewer than 3 edges. Edges: " << edgeLabels
|
||||
<< nl;
|
||||
<< endl;
|
||||
}
|
||||
valid = false;
|
||||
}
|
||||
@ -70,10 +70,12 @@ Foam::PatchTools::checkOrientation
|
||||
{
|
||||
if (report)
|
||||
{
|
||||
Info<< "edge number " << edgeLabels[i] << " on face " << faceI
|
||||
Info<< "edge number " << edgeLabels[i]
|
||||
<< " on face " << faceI
|
||||
<< " out-of-range\n"
|
||||
<< "This usually means the input surface has "
|
||||
<< "edges with more than 2 faces connected." << nl;
|
||||
<< "edges with more than 2 faces connected."
|
||||
<< endl;
|
||||
}
|
||||
valid = false;
|
||||
}
|
||||
@ -91,9 +93,9 @@ Foam::PatchTools::checkOrientation
|
||||
//- Compute normal from 3 points, use the first as the origin
|
||||
// minor warpage should not be a problem
|
||||
const Face& f = p[faceI];
|
||||
const point p0(p.points()[f[0]]);
|
||||
const point p1(p.points()[f[1]]);
|
||||
const point p2(p.points()[f[f.size()-1]]);
|
||||
const point& p0 = p.points()[f[0]];
|
||||
const point& p1 = p.points()[f[1]];
|
||||
const point& p2 = p.points()[f[f.size()-1]];
|
||||
|
||||
const vector pointNormal((p1 - p0) ^ (p2 - p0));
|
||||
if ((pointNormal & p.faceNormals()[faceI]) < 0)
|
||||
@ -103,12 +105,12 @@ Foam::PatchTools::checkOrientation
|
||||
if (report)
|
||||
{
|
||||
Info
|
||||
<< "Normal calculated from points inconsistent with faceNormal"
|
||||
<< nl
|
||||
<< "Normal calculated from points inconsistent"
|
||||
<< " with faceNormal" << nl
|
||||
<< "face: " << f << nl
|
||||
<< "points: " << p0 << ' ' << p1 << ' ' << p2 << nl
|
||||
<< "pointNormal:" << pointNormal << nl
|
||||
<< "faceNormal:" << p.faceNormals()[faceI] << nl;
|
||||
<< "faceNormal:" << p.faceNormals()[faceI] << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,127 +347,6 @@ void Foam::triSurface::checkEdges(const bool verbose)
|
||||
}
|
||||
|
||||
|
||||
// Check normals and orientation
|
||||
Foam::boolList Foam::triSurface::checkOrientation(const bool verbose)
|
||||
{
|
||||
const edgeList& es = edges();
|
||||
const labelListList& faceEs = faceEdges();
|
||||
|
||||
// Check edge normals, face normals, point normals.
|
||||
forAll(faceEs, facei)
|
||||
{
|
||||
const labelList& edgeLabels = faceEs[facei];
|
||||
|
||||
if (edgeLabels.size() != 3)
|
||||
{
|
||||
FatalErrorIn("triSurface::checkOrientation(bool)")
|
||||
<< "triangle " << (*this)[facei]
|
||||
<< " does not have 3 edges. Edges:" << edgeLabels
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
bool valid = true;
|
||||
forAll(edgeLabels, i)
|
||||
{
|
||||
if (edgeLabels[i] < 0 || edgeLabels[i] >= nEdges())
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"triSurface::checkOrientation(bool)"
|
||||
) << "edge number " << edgeLabels[i] << " on face " << facei
|
||||
<< " out-of-range\n"
|
||||
<< "This usually means that the input surface has "
|
||||
<< "edges with more than 2 triangles connected.\n"
|
||||
<< endl;
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
if (! valid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
//- Compute normal from triangle points.
|
||||
//
|
||||
|
||||
const labelledTri& tri = (*this)[facei];
|
||||
const point pa(points()[tri[0]]);
|
||||
const point pb(points()[tri[1]]);
|
||||
const point pc(points()[tri[2]]);
|
||||
|
||||
const vector pointNormal((pc - pb) ^ (pa - pb));
|
||||
if ((pointNormal & faceNormals()[facei]) < 0)
|
||||
{
|
||||
FatalErrorIn("triSurface::checkOrientation(bool)")
|
||||
<< "Normal calculated from points not consistent with"
|
||||
" faceNormal" << endl
|
||||
<< "triangle:" << tri << endl
|
||||
<< "points:" << pa << ' ' << pb << ' ' << pc << endl
|
||||
<< "pointNormal:" << pointNormal << endl
|
||||
<< "faceNormal:" << faceNormals()[facei]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const labelListList& eFaces = edgeFaces();
|
||||
|
||||
// Storage for holding status of edge. True if normal flips across this
|
||||
// edge
|
||||
boolList borderEdge(nEdges(), false);
|
||||
|
||||
forAll(es, edgeI)
|
||||
{
|
||||
const edge& e = es[edgeI];
|
||||
const labelList& neighbours = eFaces[edgeI];
|
||||
|
||||
if (neighbours.size() == 2)
|
||||
{
|
||||
const labelledTri& faceA = (*this)[neighbours[0]];
|
||||
const labelledTri& faceB = (*this)[neighbours[1]];
|
||||
|
||||
// The edge cannot be going in the same direction if both faces
|
||||
// are oriented counterclockwise.
|
||||
// Thus the next face point *must* different between the faces.
|
||||
if
|
||||
(
|
||||
faceA[faceA.fcIndex(findIndex(faceA, e.start()))]
|
||||
== faceB[faceB.fcIndex(findIndex(faceB, e.start()))]
|
||||
)
|
||||
{
|
||||
borderEdge[edgeI] = true;
|
||||
if (verbose)
|
||||
{
|
||||
WarningIn("PrimitivePatchExtra::checkOrientation(bool)")
|
||||
<< "face orientation incorrect." << nl
|
||||
<< "edge[" << edgeI << "] " << e
|
||||
<< " between faces " << neighbours << ":" << nl
|
||||
<< "face[" << neighbours[0] << "] " << faceA << nl
|
||||
<< "face[" << neighbours[1] << "] " << faceB << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (neighbours.size() != 1)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
WarningIn("triSurface::checkOrientation(bool)")
|
||||
<< "Wrong number of edge neighbours." << endl
|
||||
<< "edge[" << edgeI << "] " << e
|
||||
<< "with points:" << localPoints()[e.start()]
|
||||
<< ' ' << localPoints()[e.end()]
|
||||
<< " has neighbours:" << neighbours << endl;
|
||||
}
|
||||
borderEdge[edgeI] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return borderEdge;
|
||||
}
|
||||
|
||||
|
||||
// Read triangles, points from Istream
|
||||
bool Foam::triSurface::read(Istream& is)
|
||||
{
|
||||
|
||||
@ -326,17 +326,12 @@ public:
|
||||
//- Scale points. A non-positive factor is ignored
|
||||
virtual void scalePoints(const scalar&);
|
||||
|
||||
//- Check/fix duplicate/degenerate triangles
|
||||
//- Check/remove duplicate/degenerate triangles
|
||||
void checkTriangles(const bool verbose);
|
||||
|
||||
//- Check triply (or more) connected edges. Return list of faces
|
||||
// sharing these edges.
|
||||
//- Check triply (or more) connected edges.
|
||||
void checkEdges(const bool verbose);
|
||||
|
||||
//- Check orientation (normals) and normals of neighbouring
|
||||
// triangles
|
||||
boolList checkOrientation(const bool verbose);
|
||||
|
||||
//- Remove non-valid triangles
|
||||
void cleanup(const bool verbose);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user