primitiveMesh,polyMesh: Further refactoring of mesh checking

This commit is contained in:
Henry Weller
2023-06-23 13:44:35 +01:00
parent d6c6e99201
commit e019049bef
12 changed files with 284 additions and 760 deletions

View File

@ -23,11 +23,19 @@ License
\*---------------------------------------------------------------------------*/
#include "polyMesh.H"
#include "polyMeshCheck.H"
#include "polyMeshTools.H"
#include "unitConversion.H"
#include "syncTools.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::scalar Foam::polyMeshCheck::closedThreshold = 1.0e-6;
Foam::scalar Foam::polyMeshCheck::aspectThreshold = 1000;
Foam::scalar Foam::polyMeshCheck::nonOrthThreshold = 70; // deg
Foam::scalar Foam::polyMeshCheck::skewThreshold = 4;
Foam::scalar Foam::polyMeshCheck::planarCosAngle = 1.0e-6;
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::polyMesh::checkFaceOrthogonality
@ -56,7 +64,7 @@ bool Foam::polyMesh::checkFaceOrthogonality
// Severe nonorthogonality threshold
const scalar severeNonorthogonalityThreshold =
::cos(degToRad(primitiveMeshCheck::nonOrthThreshold));
::cos(degToRad(polyMeshCheck::nonOrthThreshold));
scalar minDDotS = great;
@ -125,7 +133,7 @@ bool Foam::polyMesh::checkFaceOrthogonality
if (severeNonOrth > 0)
{
Info<< " *Number of severely non-orthogonal (> "
<< primitiveMeshCheck::nonOrthThreshold << " degrees) faces: "
<< polyMeshCheck::nonOrthThreshold << " degrees) faces: "
<< severeNonOrth << "." << endl;
}
}
@ -191,7 +199,7 @@ bool Foam::polyMesh::checkFaceSkewness
{
// Check if the skewness vector is greater than the PN vector.
// This does not cause trouble but is a good indication of a poor mesh.
if (skew[facei] > primitiveMeshCheck::skewThreshold)
if (skew[facei] > polyMeshCheck::skewThreshold)
{
if (setPtr)
{
@ -636,4 +644,99 @@ bool Foam::polyMesh::checkVolRatio
}
bool Foam::polyMeshCheck::checkTopology(const polyMesh& mesh, const bool report)
{
label noFailedChecks = 0;
if (mesh.checkPoints(report)) noFailedChecks++;
if (mesh.checkUpperTriangular(report)) noFailedChecks++;
if (mesh.checkCellsZipUp(report)) noFailedChecks++;
if (mesh.checkFaceVertices(report)) noFailedChecks++;
if (mesh.checkFaceFaces(report)) noFailedChecks++;
if (noFailedChecks == 0)
{
if (report)
{
Info<< " Mesh topology OK." << endl;
}
return false;
}
else
{
if (report)
{
Info<< " Failed " << noFailedChecks
<< " mesh topology checks." << endl;
}
return true;
}
}
bool Foam::polyMeshCheck::checkGeometry(const polyMesh& mesh, const bool report)
{
label noFailedChecks = 0;
if (mesh.checkClosedBoundary(report)) noFailedChecks++;
if (mesh.checkClosedCells(report)) noFailedChecks++;
if (mesh.checkFaceAreas(report)) noFailedChecks++;
if (mesh.checkCellVolumes(report)) noFailedChecks++;
if (mesh.checkFaceOrthogonality(report)) noFailedChecks++;
if (mesh.checkFacePyramids(report)) noFailedChecks++;
if (mesh.checkFaceSkewness(report)) noFailedChecks++;
if (noFailedChecks == 0)
{
if (report)
{
Info<< " Mesh geometry OK." << endl;
}
return false;
}
else
{
if (report)
{
Info<< " Failed " << noFailedChecks
<< " mesh geometry checks." << endl;
}
return true;
}
}
bool Foam::polyMeshCheck::checkMesh(const polyMesh& mesh, const bool report)
{
const label noFailedChecks =
checkTopology(mesh, report)
+ checkGeometry(mesh, report);
if (noFailedChecks == 0)
{
if (report)
{
Info<< "Mesh OK." << endl;
}
return false;
}
else
{
if (report)
{
Info<< " Failed " << noFailedChecks
<< " mesh checks." << endl;
}
return true;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Namespace
Foam::polyMeshCheck
Description
SourceFiles
polyMeshCheck.C
\*---------------------------------------------------------------------------*/
#ifndef polyMeshCheck_H
#define polyMeshCheck_H
#include "polyMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Namespace polyMeshCheck Declaration
\*---------------------------------------------------------------------------*/
namespace polyMeshCheck
{
//- Check mesh topology for correctness.
// Returns false for no error.
bool checkTopology(const polyMesh& mesh, const bool report = false);
//- Check mesh geometry (& implicitly topology) for correctness.
// Returns false for no error.
bool checkGeometry(const polyMesh& mesh, const bool report = false);
//- Check mesh for correctness. Returns false for no error.
bool checkMesh(const polyMesh& mesh, const bool report = false);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -665,14 +665,6 @@ Foam::polyMesh::polyMesh
// Calculate the geometry for the patches (transformation tensors etc.)
boundary_.calcGeometry();
}
if (debug)
{
if (checkMesh())
{
Info<< "Mesh OK" << endl;
}
}
}
@ -945,14 +937,6 @@ Foam::polyMesh::polyMesh
// Calculate the geometry for the patches (transformation tensors etc.)
boundary_.calcGeometry();
}
if (debug)
{
if (checkMesh())
{
Info << "Mesh OK" << endl;
}
}
}

View File

@ -250,128 +250,6 @@ protected:
void calcEdgeVectors() const;
// Mesh checking
//- Check if all points on face are shared with another face.
bool checkDuplicateFaces
(
const label,
const Map<label>&,
label& nBaffleFaces,
labelHashSet*
) const;
//- Check that shared points are in consecutive order.
bool checkCommonOrder
(
const label,
const Map<label>&,
labelHashSet*
) const;
//- Check boundary for closedness
bool checkClosedBoundary
(
const vectorField&,
const bool,
const PackedBoolList&
) const;
//- Check cells for closedness
bool checkClosedCells
(
const vectorField& faceAreas,
const scalarField& cellVolumes,
const bool report,
labelHashSet* setPtr,
labelHashSet* aspectSetPtr,
const Vector<label>& meshD
) const;
//- Check for negative face areas
bool checkFaceAreas
(
const vectorField& faceAreas,
const bool report,
const bool detailedReport,
labelHashSet* setPtr
) const;
//- Check for negative cell volumes
bool checkCellVolumes
(
const scalarField& vols,
const bool report,
const bool detailedReport,
labelHashSet* setPtr
) const;
//- Check for non-orthogonality
bool checkFaceOrthogonality
(
const vectorField& fAreas,
const vectorField& cellCtrs,
const bool report,
labelHashSet* setPtr
) const;
//- Check face pyramid volume
bool checkFacePyramids
(
const pointField& points,
const vectorField& ctrs,
const bool report,
const bool detailedReport,
const scalar minPyrVol,
labelHashSet* setPtr
) const;
//- Check face skewness
bool checkFaceSkewness
(
const pointField& points,
const vectorField& fCtrs,
const vectorField& fAreas,
const vectorField& cellCtrs,
const bool report,
labelHashSet* setPtr
) const;
//- Check face angles
// Allows a slight non-convexity. E.g. maxDeg = 10 allows for
// angles < 190 (or 10 degrees concavity) (if truly concave and
// points not visible from face centre the face-pyramid check in
// checkMesh will fail)
bool checkFaceAngles
(
const pointField& points,
const vectorField& faceAreas,
const bool report,
const scalar maxDeg,
labelHashSet* setPtr
) const;
//- Check face warpage
bool checkFaceFlatness
(
const pointField& points,
const vectorField& faceCentres,
const vectorField& faceAreas,
const bool report,
const scalar warnFlatness,
labelHashSet* setPtr
) const;
//- Check for concave cells by the planes of faces
bool checkConcaveCells
(
const vectorField& fAreas,
const pointField& fCentres,
const bool report,
labelHashSet* setPtr
) const;
//- Construct null
primitiveMesh();
@ -592,35 +470,52 @@ public:
// Topological checks
//- Check face ordering
virtual bool checkUpperTriangular
bool checkUpperTriangular
(
const bool report = false,
labelHashSet* setPtr = nullptr
) const;
//- Check cell zip-up
virtual bool checkCellsZipUp
bool checkCellsZipUp
(
const bool report = false,
labelHashSet* setPtr = nullptr
) const;
//- Check uniqueness of face vertices
virtual bool checkFaceVertices
bool checkFaceVertices
(
const bool report = false,
labelHashSet* setPtr = nullptr
) const;
//- Check for unused points
virtual bool checkPoints
bool checkPoints
(
const bool report = false,
labelHashSet* setPtr = nullptr
) const;
//- Check if all points on face are shared with another face.
bool checkDuplicateFaces
(
const label,
const Map<label>&,
label& nBaffleFaces,
labelHashSet*
) const;
//- Check that shared points are in consecutive order.
bool checkCommonOrder
(
const label,
const Map<label>&,
labelHashSet*
) const;
//- Check face-face connectivity
virtual bool checkFaceFaces
bool checkFaceFaces
(
const bool report = false,
labelHashSet* setPtr = nullptr
@ -630,11 +525,10 @@ public:
// Geometric checks
//- Check boundary for closedness
virtual bool checkClosedBoundary(const bool report = false)
const;
bool checkClosedBoundary(const bool report = false) const;
//- Check cells for closedness
virtual bool checkClosedCells
bool checkClosedCells
(
const bool report = false,
labelHashSet* setPtr = nullptr,
@ -643,43 +537,29 @@ public:
) const;
//- Check for negative face areas
virtual bool checkFaceAreas
bool checkFaceAreas
(
const bool report = false,
labelHashSet* setPtr = nullptr
) const;
//- Check for negative cell volumes
virtual bool checkCellVolumes
(
const bool report = false,
labelHashSet* setPtr = nullptr
) const;
//- Check for non-orthogonality
virtual bool checkFaceOrthogonality
bool checkCellVolumes
(
const bool report = false,
labelHashSet* setPtr = nullptr
) const;
//- Check face pyramid volume
virtual bool checkFacePyramids
bool checkFacePyramids
(
const bool report = false,
const scalar minPyrVol = -small,
labelHashSet* setPtr = nullptr
) const;
//- Check face skewness
virtual bool checkFaceSkewness
(
const bool report = false,
labelHashSet* setPtr = nullptr
) const;
//- Check face angles
virtual bool checkFaceAngles
bool checkFaceAngles
(
const bool report = false,
const scalar maxSin = 10, // In degrees
@ -689,7 +569,7 @@ public:
//- Check face warpage: decompose face and check ratio between
// magnitude of sum of triangle areas and sum of magnitude of
// triangle areas.
virtual bool checkFaceFlatness
bool checkFaceFlatness
(
const bool report,
const scalar warnFlatness, // When to include in set.
@ -698,7 +578,7 @@ public:
//- Check for point-point-nearness,
// e.g. colocated points which may be part of baffles.
virtual bool checkPointNearness
bool checkPointNearness
(
const bool report,
const scalar reportDistSqr,
@ -706,7 +586,7 @@ public:
) const;
//- Check edge length
virtual bool checkEdgeLength
bool checkEdgeLength
(
const bool report,
const scalar minLenSqr,
@ -714,25 +594,13 @@ public:
) const;
//- Check for concave cells by the planes of faces
virtual bool checkConcaveCells
bool checkConcaveCells
(
const bool report = false,
labelHashSet* setPtr = nullptr
) const;
//- Check mesh topology for correctness.
// Returns false for no error.
virtual bool checkTopology(const bool report = false) const;
//- Check mesh geometry (& implicitly topology) for correctness.
// Returns false for no error.
virtual bool checkGeometry(const bool report = false) const;
//- Check mesh for correctness. Returns false for no error.
virtual bool checkMesh(const bool report = false) const;
// Useful derived info
//- Return true if the point in the cell bounding box.
@ -875,7 +743,7 @@ public:
};
namespace primitiveMeshCheck
namespace polyMeshCheck
{
//- Data to control mesh checking

View File

@ -31,22 +31,11 @@ License
#include "EdgeMap.H"
#include "primitiveMeshTools.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::scalar Foam::primitiveMeshCheck::closedThreshold = 1.0e-6;
Foam::scalar Foam::primitiveMeshCheck::aspectThreshold = 1000;
Foam::scalar Foam::primitiveMeshCheck::nonOrthThreshold = 70; // deg
Foam::scalar Foam::primitiveMeshCheck::skewThreshold = 4;
Foam::scalar Foam::primitiveMeshCheck::planarCosAngle = 1.0e-6;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::primitiveMesh::checkClosedBoundary
(
const vectorField& areas,
const bool report,
const PackedBoolList& internalOrCoupledFaces
const bool report
) const
{
if (debug)
@ -55,6 +44,8 @@ bool Foam::primitiveMesh::checkClosedBoundary
<< "Checking whether the boundary is closed" << endl;
}
const vectorField& areas = faceAreas();
// Loop through all boundary faces and sum up the face area vectors.
// For a closed boundary, this should be zero in all vector components
@ -62,20 +53,17 @@ bool Foam::primitiveMesh::checkClosedBoundary
scalar sumMagClosedBoundary = 0;
for (label facei = nInternalFaces(); facei < areas.size(); facei++)
{
if (!internalOrCoupledFaces.size() || !internalOrCoupledFaces[facei])
{
sumClosed += areas[facei];
sumMagClosedBoundary += mag(areas[facei]);
}
}
reduce(sumClosed, sumOp<vector>());
reduce(sumMagClosedBoundary, sumOp<scalar>());
vector openness = sumClosed/(sumMagClosedBoundary + vSmall);
if (cmptMax(cmptMag(openness)) > primitiveMeshCheck::closedThreshold)
if (cmptMax(cmptMag(openness)) > polyMeshCheck::closedThreshold)
{
if (debug || report)
{
@ -101,8 +89,6 @@ bool Foam::primitiveMesh::checkClosedBoundary
bool Foam::primitiveMesh::checkClosedCells
(
const vectorField& faceAreas,
const scalarField& cellVolumes,
const bool report,
labelHashSet* setPtr,
labelHashSet* aspectSetPtr,
@ -115,6 +101,9 @@ bool Foam::primitiveMesh::checkClosedCells
<< "Checking whether cells are closed" << endl;
}
const vectorField& faceAreas = this->faceAreas();
const scalarField& cellVolumes = this->cellVolumes();
// Check that all cells labels are valid
const cellList& c = cells();
@ -167,7 +156,7 @@ bool Foam::primitiveMesh::checkClosedCells
// Check the sums
forAll(openness, celli)
{
if (openness[celli] > primitiveMeshCheck::closedThreshold)
if (openness[celli] > polyMeshCheck::closedThreshold)
{
if (setPtr)
{
@ -177,7 +166,7 @@ bool Foam::primitiveMesh::checkClosedCells
nOpen++;
}
if (aspectRatio[celli] > primitiveMeshCheck::aspectThreshold)
if (aspectRatio[celli] > polyMeshCheck::aspectThreshold)
{
if (aspectSetPtr)
{
@ -233,9 +222,7 @@ bool Foam::primitiveMesh::checkClosedCells
bool Foam::primitiveMesh::checkFaceAreas
(
const vectorField& faceAreas,
const bool report,
const bool detailedReport,
labelHashSet* setPtr
) const
{
@ -244,6 +231,7 @@ bool Foam::primitiveMesh::checkFaceAreas
InfoInFunction << "Checking face area magnitudes" << endl;
}
const vectorField& faceAreas = this->faceAreas();
const scalarField magFaceAreas(mag(faceAreas));
scalar minArea = great;
@ -257,25 +245,6 @@ bool Foam::primitiveMesh::checkFaceAreas
{
setPtr->insert(facei);
}
if (detailedReport)
{
if (isInternalFace(facei))
{
Pout<< "Zero or negative face area detected for "
<< "internal face "<< facei << " between cells "
<< faceOwner()[facei] << " and "
<< faceNeighbour()[facei]
<< ". Face area magnitude = " << magFaceAreas[facei]
<< endl;
}
else
{
Pout<< "Zero or negative face area detected for "
<< "boundary face " << facei << " next to cell "
<< faceOwner()[facei] << ". Face area magnitude = "
<< magFaceAreas[facei] << endl;
}
}
}
minArea = min(minArea, magFaceAreas[facei]);
@ -311,9 +280,7 @@ bool Foam::primitiveMesh::checkFaceAreas
bool Foam::primitiveMesh::checkCellVolumes
(
const scalarField& vols,
const bool report,
const bool detailedReport,
labelHashSet* setPtr
) const
{
@ -322,6 +289,7 @@ bool Foam::primitiveMesh::checkCellVolumes
InfoInFunction << "Checking cell volumes" << endl;
}
const scalarField& vols = cellVolumes();
scalar minVolume = great;
scalar maxVolume = -great;
@ -335,11 +303,6 @@ bool Foam::primitiveMesh::checkCellVolumes
{
setPtr->insert(celli);
}
if (detailedReport)
{
Pout<< "Zero or negative cell volume detected for cell "
<< celli << ". Volume = " << vols[celli] << endl;
}
nNegVolCells++;
}
@ -379,122 +342,9 @@ bool Foam::primitiveMesh::checkCellVolumes
}
bool Foam::primitiveMesh::checkFaceOrthogonality
(
const vectorField& fAreas,
const vectorField& cellCtrs,
const bool report,
labelHashSet* setPtr
) const
{
if (debug)
{
InfoInFunction << "Checking mesh non-orthogonality" << endl;
}
tmp<scalarField> tortho = primitiveMeshTools::faceOrthogonality
(
*this,
fAreas,
cellCtrs
);
const scalarField& ortho = tortho();
// Severe nonorthogonality threshold
const scalar severeNonorthogonalityThreshold =
::cos(degToRad(primitiveMeshCheck::nonOrthThreshold));
scalar minDDotS = min(ortho);
scalar sumDDotS = sum(ortho);
label severeNonOrth = 0;
label errorNonOrth = 0;
forAll(ortho, facei)
{
if (ortho[facei] < severeNonorthogonalityThreshold)
{
if (ortho[facei] > small)
{
if (setPtr)
{
setPtr->insert(facei);
}
severeNonOrth++;
}
else
{
if (setPtr)
{
setPtr->insert(facei);
}
errorNonOrth++;
}
}
}
reduce(minDDotS, minOp<scalar>());
reduce(sumDDotS, sumOp<scalar>());
reduce(severeNonOrth, sumOp<label>());
reduce(errorNonOrth, sumOp<label>());
if (debug || report)
{
label neiSize = ortho.size();
reduce(neiSize, sumOp<label>());
if (neiSize > 0)
{
if (debug || report)
{
Info<< " Mesh non-orthogonality Max: "
<< radToDeg(::acos(minDDotS))
<< " average: " << radToDeg(::acos(sumDDotS/neiSize))
<< endl;
}
}
if (severeNonOrth > 0)
{
Info<< " *Number of severely non-orthogonal faces: "
<< severeNonOrth << "." << endl;
}
}
if (errorNonOrth > 0)
{
if (debug || report)
{
Info<< " ***Number of non-orthogonality errors: "
<< errorNonOrth << "." << endl;
}
return true;
}
else
{
if (debug || report)
{
Info<< " Non-orthogonality check OK." << endl;
}
return false;
}
}
bool Foam::primitiveMesh::checkFacePyramids
(
const pointField& points,
const vectorField& ctrs,
const bool report,
const bool detailedReport,
const scalar minPyrVol,
labelHashSet* setPtr
) const
@ -504,9 +354,8 @@ bool Foam::primitiveMesh::checkFacePyramids
InfoInFunction << "Checking face orientation" << endl;
}
const labelList& own = faceOwner();
const labelList& nei = faceNeighbour();
const faceList& f = faces();
const pointField& points = this->points();
const vectorField& ctrs = cellCentres();
scalarField ownPyrVol;
@ -531,15 +380,6 @@ bool Foam::primitiveMesh::checkFacePyramids
{
setPtr->insert(facei);
}
if (detailedReport)
{
Pout<< "Negative pyramid volume: " << ownPyrVol[facei]
<< " for face " << facei << " " << f[facei]
<< " and owner cell: " << own[facei] << endl
<< "Owner cell vertex labels: "
<< cells()[own[facei]].labels(faces())
<< endl;
}
nErrorPyrs++;
}
@ -552,15 +392,6 @@ bool Foam::primitiveMesh::checkFacePyramids
{
setPtr->insert(facei);
}
if (detailedReport)
{
Pout<< "Negative pyramid volume: " << neiPyrVol[facei]
<< " for face " << facei << " " << f[facei]
<< " and neighbour cell: " << nei[facei] << nl
<< "Neighbour cell vertex labels: "
<< cells()[nei[facei]].labels(faces())
<< endl;
}
nErrorPyrs++;
}
}
@ -591,83 +422,8 @@ bool Foam::primitiveMesh::checkFacePyramids
}
bool Foam::primitiveMesh::checkFaceSkewness
(
const pointField& points,
const vectorField& fCtrs,
const vectorField& fAreas,
const vectorField& cellCtrs,
const bool report,
labelHashSet* setPtr
) const
{
if (debug)
{
InfoInFunction << "Checking face skewness" << endl;
}
// Warn if the skew correction vector is more than skewWarning times
// larger than the face area vector
tmp<scalarField> tskewness = primitiveMeshTools::faceSkewness
(
*this,
points,
fCtrs,
fAreas,
cellCtrs
);
const scalarField& skewness = tskewness();
scalar maxSkew = max(skewness);
label nWarnSkew = 0;
forAll(skewness, facei)
{
// Check if the skewness vector is greater than the PN vector.
// This does not cause trouble but is a good indication of a poor mesh.
if (skewness[facei] > primitiveMeshCheck::skewThreshold)
{
if (setPtr)
{
setPtr->insert(facei);
}
nWarnSkew++;
}
}
reduce(maxSkew, maxOp<scalar>());
reduce(nWarnSkew, sumOp<label>());
if (nWarnSkew > 0)
{
if (debug || report)
{
Info<< " ***Max skewness = " << maxSkew
<< ", " << nWarnSkew << " highly skew faces detected"
" which may impair the quality of the results"
<< endl;
}
return true;
}
else
{
if (debug || report)
{
Info<< " Max skewness = " << maxSkew << " OK." << endl;
}
return false;
}
}
bool Foam::primitiveMesh::checkFaceAngles
(
const pointField& points,
const vectorField& faceAreas,
const bool report,
const scalar maxDeg,
labelHashSet* setPtr
@ -687,6 +443,8 @@ bool Foam::primitiveMesh::checkFaceAngles
const scalar maxSin = Foam::sin(degToRad(maxDeg));
const pointField& points = this->points();
const vectorField& faceAreas = this->faceAreas();
tmp<scalarField> tfaceAngles = primitiveMeshTools::faceConcavity
(
@ -746,9 +504,6 @@ bool Foam::primitiveMesh::checkFaceAngles
bool Foam::primitiveMesh::checkFaceFlatness
(
const pointField& points,
const vectorField& faceCentres,
const vectorField& faceAreas,
const bool report,
const scalar warnFlatness,
labelHashSet* setPtr
@ -766,6 +521,9 @@ bool Foam::primitiveMesh::checkFaceFlatness
<< exit(FatalError);
}
const pointField& points = this->points();
const vectorField& faceCentres = this->faceCentres();
const vectorField& faceAreas = this->faceAreas();
const faceList& fcs = faces();
tmp<scalarField> tfaceFlatness = primitiveMeshTools::faceFlatness
@ -851,8 +609,6 @@ bool Foam::primitiveMesh::checkFaceFlatness
bool Foam::primitiveMesh::checkConcaveCells
(
const vectorField& fAreas,
const pointField& fCentres,
const bool report,
labelHashSet* setPtr
) const
@ -862,6 +618,8 @@ bool Foam::primitiveMesh::checkConcaveCells
InfoInFunction << "Checking for concave cells" << endl;
}
const vectorField& fAreas = faceAreas();
const pointField& fCentres = faceCentres();
const cellList& c = cells();
const labelList& fOwner = faceOwner();
@ -916,7 +674,7 @@ bool Foam::primitiveMesh::checkConcaveCells
pC /= max(mag(pC), vSmall);
if ((pC & fN) > -primitiveMeshCheck::planarCosAngle)
if ((pC & fN) > -polyMeshCheck::planarCosAngle)
{
// Concave or planar face
@ -1680,266 +1438,4 @@ bool Foam::primitiveMesh::checkFaceFaces
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::primitiveMesh::checkClosedBoundary(const bool report) const
{
return checkClosedBoundary(faceAreas(), report, PackedBoolList(0));
}
bool Foam::primitiveMesh::checkClosedCells
(
const bool report,
labelHashSet* setPtr,
labelHashSet* aspectSetPtr,
const Vector<label>& solutionD
) const
{
return checkClosedCells
(
faceAreas(),
cellVolumes(),
report,
setPtr,
aspectSetPtr,
solutionD
);
}
bool Foam::primitiveMesh::checkFaceAreas
(
const bool report,
labelHashSet* setPtr
) const
{
return checkFaceAreas
(
faceAreas(),
report,
false, // detailedReport,
setPtr
);
}
bool Foam::primitiveMesh::checkCellVolumes
(
const bool report,
labelHashSet* setPtr
) const
{
return checkCellVolumes
(
cellVolumes(),
report,
false, // detailedReport,
setPtr
);
}
bool Foam::primitiveMesh::checkFaceOrthogonality
(
const bool report,
labelHashSet* setPtr
) const
{
return checkFaceOrthogonality
(
faceAreas(),
cellCentres(),
report,
setPtr
);
}
bool Foam::primitiveMesh::checkFacePyramids
(
const bool report,
const scalar minPyrVol,
labelHashSet* setPtr
) const
{
return checkFacePyramids
(
points(),
cellCentres(),
report,
false, // detailedReport,
minPyrVol,
setPtr
);
}
bool Foam::primitiveMesh::checkFaceSkewness
(
const bool report,
labelHashSet* setPtr
) const
{
return checkFaceSkewness
(
points(),
faceCentres(),
faceAreas(),
cellCentres(),
report,
setPtr
);
}
bool Foam::primitiveMesh::checkFaceAngles
(
const bool report,
const scalar maxDeg,
labelHashSet* setPtr
) const
{
return checkFaceAngles
(
points(),
faceAreas(),
report,
maxDeg,
setPtr
);
}
bool Foam::primitiveMesh::checkFaceFlatness
(
const bool report,
const scalar warnFlatness,
labelHashSet* setPtr
) const
{
return checkFaceFlatness
(
points(),
faceCentres(),
faceAreas(),
report,
warnFlatness,
setPtr
);
}
bool Foam::primitiveMesh::checkConcaveCells
(
const bool report,
labelHashSet* setPtr
) const
{
return checkConcaveCells
(
faceAreas(),
faceCentres(),
report,
setPtr
);
}
bool Foam::primitiveMesh::checkTopology(const bool report) const
{
label noFailedChecks = 0;
if (checkPoints(report)) noFailedChecks++;
if (checkUpperTriangular(report)) noFailedChecks++;
if (checkCellsZipUp(report)) noFailedChecks++;
if (checkFaceVertices(report)) noFailedChecks++;
if (checkFaceFaces(report)) noFailedChecks++;
if (noFailedChecks == 0)
{
if (debug || report)
{
Info<< " Mesh topology OK." << endl;
}
return false;
}
else
{
if (debug || report)
{
Info<< " Failed " << noFailedChecks
<< " mesh topology checks." << endl;
}
return true;
}
}
bool Foam::primitiveMesh::checkGeometry(const bool report) const
{
label noFailedChecks = 0;
if (checkClosedBoundary(report)) noFailedChecks++;
if (checkClosedCells(report)) noFailedChecks++;
if (checkFaceAreas(report)) noFailedChecks++;
if (checkCellVolumes(report)) noFailedChecks++;
if (checkFaceOrthogonality(report)) noFailedChecks++;
if (checkFacePyramids(report)) noFailedChecks++;
if (checkFaceSkewness(report)) noFailedChecks++;
if (noFailedChecks == 0)
{
if (debug || report)
{
Info<< " Mesh geometry OK." << endl;
}
return false;
}
else
{
if (debug || report)
{
Info<< " Failed " << noFailedChecks
<< " mesh geometry checks." << endl;
}
return true;
}
}
bool Foam::primitiveMesh::checkMesh(const bool report) const
{
if (debug)
{
InfoInFunction << "Checking primitiveMesh" << endl;
}
label noFailedChecks = checkTopology(report) + checkGeometry(report);
if (noFailedChecks == 0)
{
if (debug || report)
{
Info<< "Mesh OK." << endl;
}
return false;
}
else
{
if (debug || report)
{
Info<< " Failed " << noFailedChecks
<< " mesh checks." << endl;
}
return true;
}
}
// ************************************************************************* //

View File

@ -93,7 +93,7 @@ motionSmoother/motionSmoother.C
motionSmoother/motionSmootherAlgo.C
motionSmoother/motionSmootherAlgoCheck.C
motionSmoother/motionSmootherData.C
motionSmoother/polyMeshCheck/polyMeshCheck.C
motionSmoother/dynamicMeshCheck/dynamicMeshCheck.C
motionSmoother/badQualityToCell/badQualityToCell.C
motionSmoother/badQualityToFace/badQualityToFace.C

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "polyMeshCheck.H"
#include "dynamicMeshCheck.H"
#include "polyMeshTetDecomposition.H"
#include "pyramidPointFaceRef.H"
#include "tetPointRef.H"
@ -35,7 +35,7 @@ License
namespace Foam
{
namespace polyMeshCheck
namespace dynamicMeshCheck
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -136,7 +136,7 @@ bool checkFaceTet
{
if (report)
{
Pout<< "bool polyMeshCheck::checkFaceTets("
Pout<< "bool dynamicMeshCheck::checkFaceTets("
<< "const bool, const scalar, const pointField&"
<< ", const pointField&"
<< ", const labelList&, labelHashSet*) : "
@ -186,12 +186,12 @@ labelList getAffectedCells
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace polyMeshCheck
} // End namespace dynamicMeshCheck
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool Foam::polyMeshCheck::checkFaceDotProduct
bool Foam::dynamicMeshCheck::checkFaceDotProduct
(
const bool report,
const scalar orthWarn,
@ -373,7 +373,7 @@ bool Foam::polyMeshCheck::checkFaceDotProduct
}
bool Foam::polyMeshCheck::checkFacePyramids
bool Foam::dynamicMeshCheck::checkFacePyramids
(
const bool report,
const scalar minPyrVol,
@ -408,7 +408,7 @@ bool Foam::polyMeshCheck::checkFacePyramids
{
if (report)
{
Pout<< "bool polyMeshCheck::checkFacePyramids("
Pout<< "bool dynamicMeshCheck::checkFacePyramids("
<< "const bool, const scalar, const pointField&"
<< ", const labelList&, labelHashSet*): "
<< "face " << facei << " points the wrong way. " << endl
@ -439,7 +439,7 @@ bool Foam::polyMeshCheck::checkFacePyramids
{
if (report)
{
Pout<< "bool polyMeshCheck::checkFacePyramids("
Pout<< "bool dynamicMeshCheck::checkFacePyramids("
<< "const bool, const scalar, const pointField&"
<< ", const labelList&, labelHashSet*): "
<< "face " << facei << " points the wrong way. " << endl
@ -479,7 +479,7 @@ bool Foam::polyMeshCheck::checkFacePyramids
{
if (report)
{
Pout<< "bool polyMeshCheck::checkFacePyramids("
Pout<< "bool dynamicMeshCheck::checkFacePyramids("
<< "const bool, const scalar, const pointField&"
<< ", const labelList&, labelHashSet*): "
<< "face " << face0 << " points the wrong way. " << endl
@ -508,7 +508,7 @@ bool Foam::polyMeshCheck::checkFacePyramids
{
if (report)
{
Pout<< "bool polyMeshCheck::checkFacePyramids("
Pout<< "bool dynamicMeshCheck::checkFacePyramids("
<< "const bool, const scalar, const pointField&"
<< ", const labelList&, labelHashSet*): "
<< "face " << face0 << " points the wrong way. " << endl
@ -554,7 +554,7 @@ bool Foam::polyMeshCheck::checkFacePyramids
}
bool Foam::polyMeshCheck::checkFaceTets
bool Foam::dynamicMeshCheck::checkFaceTets
(
const bool report,
const scalar minTetQuality,
@ -783,7 +783,7 @@ bool Foam::polyMeshCheck::checkFaceTets
}
bool Foam::polyMeshCheck::checkFaceSkewness
bool Foam::dynamicMeshCheck::checkFaceSkewness
(
const bool report,
const scalar internalSkew,
@ -996,7 +996,7 @@ bool Foam::polyMeshCheck::checkFaceSkewness
}
bool Foam::polyMeshCheck::checkFaceWeights
bool Foam::dynamicMeshCheck::checkFaceWeights
(
const bool report,
const scalar warnWeight,
@ -1151,7 +1151,7 @@ bool Foam::polyMeshCheck::checkFaceWeights
}
bool Foam::polyMeshCheck::checkVolRatio
bool Foam::dynamicMeshCheck::checkVolRatio
(
const bool report,
const scalar warnRatio,
@ -1289,7 +1289,7 @@ bool Foam::polyMeshCheck::checkVolRatio
}
bool Foam::polyMeshCheck::checkFaceAngles
bool Foam::dynamicMeshCheck::checkFaceAngles
(
const bool report,
const scalar maxDeg,
@ -1420,7 +1420,7 @@ bool Foam::polyMeshCheck::checkFaceAngles
}
bool Foam::polyMeshCheck::checkFaceTwist
bool Foam::dynamicMeshCheck::checkFaceTwist
(
const bool report,
const scalar minTwist,
@ -1604,7 +1604,7 @@ bool Foam::polyMeshCheck::checkFaceTwist
}
bool Foam::polyMeshCheck::checkTriangleTwist
bool Foam::dynamicMeshCheck::checkTriangleTwist
(
const bool report,
const scalar minTwist,
@ -1754,7 +1754,7 @@ bool Foam::polyMeshCheck::checkTriangleTwist
}
bool Foam::polyMeshCheck::checkFaceFlatness
bool Foam::dynamicMeshCheck::checkFaceFlatness
(
const bool report,
const scalar minFlatness,
@ -1852,7 +1852,7 @@ bool Foam::polyMeshCheck::checkFaceFlatness
}
bool Foam::polyMeshCheck::checkFaceArea
bool Foam::dynamicMeshCheck::checkFaceArea
(
const bool report,
const scalar minArea,
@ -1913,7 +1913,7 @@ bool Foam::polyMeshCheck::checkFaceArea
}
bool Foam::polyMeshCheck::checkCellDeterminant
bool Foam::dynamicMeshCheck::checkCellDeterminant
(
const bool report,
const scalar warnDet,

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -27,12 +27,12 @@ Description
coupled faces are treated as internal).
SourceFiles
polyMeshCheck.C
dynamicMeshCheck.C
\*---------------------------------------------------------------------------*/
#ifndef polyMeshCheck_H
#define polyMeshCheck_H
#ifndef dynamicMeshCheck_H
#define dynamicMeshCheck_H
#include "pointFields.H"
#include "HashSet.H"
@ -41,7 +41,7 @@ SourceFiles
namespace Foam
{
namespace polyMeshCheck
namespace dynamicMeshCheck
{
//- Check face non-orthogonality
@ -204,7 +204,7 @@ bool checkCellDeterminant
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace polyMeshCheck
} // End namespace dynamicMeshCheck
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "motionSmootherAlgo.H"
#include "polyMeshCheck.H"
#include "dynamicMeshCheck.H"
#include "IOmanip.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -109,7 +109,7 @@ bool Foam::motionSmootherAlgo::checkMesh
if (maxNonOrtho < 180.0-small)
{
polyMeshCheck::checkFaceDotProduct
dynamicMeshCheck::checkFaceDotProduct
(
report,
maxNonOrtho,
@ -135,7 +135,7 @@ bool Foam::motionSmootherAlgo::checkMesh
{
const scalar refVol = pow3(mesh.bounds().minDim());
polyMeshCheck::checkFacePyramids
dynamicMeshCheck::checkFacePyramids
(
report,
minVol*refVol,
@ -158,7 +158,7 @@ bool Foam::motionSmootherAlgo::checkMesh
if (minTetQuality > -great)
{
polyMeshCheck::checkFaceTets
dynamicMeshCheck::checkFaceTets
(
report,
minTetQuality,
@ -182,7 +182,7 @@ bool Foam::motionSmootherAlgo::checkMesh
if (maxConcave < 180.0-small)
{
polyMeshCheck::checkFaceAngles
dynamicMeshCheck::checkFaceAngles
(
report,
maxConcave,
@ -205,7 +205,7 @@ bool Foam::motionSmootherAlgo::checkMesh
if (maxIntSkew > 0 || maxBounSkew > 0)
{
polyMeshCheck::checkFaceSkewness
dynamicMeshCheck::checkFaceSkewness
(
report,
maxIntSkew,
@ -232,7 +232,7 @@ bool Foam::motionSmootherAlgo::checkMesh
if (minWeight >= 0 && minWeight < 1)
{
polyMeshCheck::checkFaceWeights
dynamicMeshCheck::checkFaceWeights
(
report,
minWeight,
@ -257,7 +257,7 @@ bool Foam::motionSmootherAlgo::checkMesh
if (minVolRatio >= 0)
{
polyMeshCheck::checkVolRatio
dynamicMeshCheck::checkVolRatio
(
report,
minVolRatio,
@ -282,7 +282,7 @@ bool Foam::motionSmootherAlgo::checkMesh
{
// Pout<< "Checking face twist: dot product of face normal "
// << "with face triangle normals" << endl;
polyMeshCheck::checkFaceTwist
dynamicMeshCheck::checkFaceTwist
(
report,
minTwist,
@ -307,7 +307,7 @@ bool Foam::motionSmootherAlgo::checkMesh
if (minFaceFlatness > -small)
{
polyMeshCheck::checkFaceFlatness
dynamicMeshCheck::checkFaceFlatness
(
report,
minFaceFlatness,
@ -331,7 +331,7 @@ bool Foam::motionSmootherAlgo::checkMesh
if (minDet > -1)
{
polyMeshCheck::checkCellDeterminant
dynamicMeshCheck::checkCellDeterminant
(
report,
minDet,

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "attachPolyTopoChanger.H"
#include "polyMesh.H"
#include "polyMeshCheck.H"
#include "polyTopoChange.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -120,7 +120,7 @@ void Foam::attachPolyTopoChanger::attach(const bool removeEmptyPatches)
<< "Finished attaching mesh" << endl;
}
mesh_.checkMesh();
polyMeshCheck::checkMesh(mesh_);
}

View File

@ -25,6 +25,7 @@ License
#include "checkMesh.H"
#include "fvMesh.H"
#include "polyMeshCheck.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -66,7 +67,7 @@ bool Foam::functionObjects::checkMesh::execute()
{
if (mesh_.changing())
{
return mesh_.checkMesh(true);
return polyMeshCheck::checkMesh(mesh_, true);
}
else
{

View File

@ -33,7 +33,7 @@ License
#include "indirectPrimitivePatch.H"
#include "cellSet.H"
#include "searchableSurfaces.H"
#include "polyMeshCheck.H"
#include "dynamicMeshCheck.H"
#include "IOmanip.H"
#include "unitConversion.H"
#include "snappySnapDriver.H"
@ -1178,7 +1178,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCellsGeometric
// const scalar minV(motionDict.lookup<scalar>("minVol", true));
// if (minV > -great)
//{
// polyMeshCheck::checkFacePyramids
// dynamicMeshCheck::checkFacePyramids
// (
// false,
// minV,
@ -1207,7 +1207,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCellsGeometric
scalar minArea(motionDict.lookup<scalar>("minArea"));
if (minArea > -small)
{
polyMeshCheck::checkFaceArea
dynamicMeshCheck::checkFaceArea
(
false,
minArea,
@ -1234,7 +1234,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCellsGeometric
scalar minDet(motionDict.lookup<scalar>("minDeterminant"));
if (minDet > -1)
{
polyMeshCheck::checkCellDeterminant
dynamicMeshCheck::checkCellDeterminant
(
false,
minDet,