36bool Foam::polyMesh::checkFaceOrthogonality
38 const vectorField& fAreas,
39 const vectorField& cellCtrs,
41 const bool detailedReport,
61 const scalar severeNonorthogonalityThreshold =
65 scalar minDDotS = GREAT;
66 scalar sumDDotS = 0.0;
68 label severeNonOrth = 0;
69 label errorNonOrth = 0;
77 if (ortho[facei] < severeNonorthogonalityThreshold)
79 if (ortho[facei] > SMALL)
83 setPtr->insert(facei);
93 setPtr->insert(facei);
95 if (detailedReport && errorNonOrth == 0)
99 <<
"Severe non-orthogonality for face "
101 <<
" between cells " << own[facei]
102 <<
" and " << nei[facei]
112 if (isMasterFace.test(facei))
114 minDDotS =
min(minDDotS, ortho[facei]);
115 sumDDotS += ortho[facei];
120 reduce(minDDotS, minOp<scalar>());
121 reduce(sumDDotS, sumOp<scalar>());
122 reduce(nSummed, sumOp<label>());
123 reduce(severeNonOrth, sumOp<label>());
124 reduce(errorNonOrth, sumOp<label>());
133 meshDict.set(
"maxNonOrth", maxNonOrth);
134 meshDict.set(
"aveNonOrth", aveNonOrth);
138 Info<<
" Mesh non-orthogonality Max: " << maxNonOrth
139 <<
" average: " << aveNonOrth
144 if (severeNonOrth > 0)
147 meshDict.set(
"severeNonOrth", severeNonOrth);
151 Info<<
" *Number of severely non-orthogonal (> "
153 << severeNonOrth <<
"." <<
endl;
157 if (errorNonOrth > 0)
159 meshDict.set(
"errorNonOrth", errorNonOrth);
163 Info<<
" ***Number of non-orthogonality errors: "
164 << errorNonOrth <<
"." <<
endl;
172 Info<<
" Non-orthogonality check OK." <<
endl;
179bool Foam::polyMesh::checkFaceSkewness
186 const bool detailedReport,
218 if (
skew[facei] > skewThreshold_)
222 setPtr->insert(facei);
224 if (detailedReport && nWarnSkew == 0)
227 if (isInternalFace(facei))
230 <<
"Severe skewness " <<
skew[facei]
231 <<
" for face " << facei
232 <<
" between cells " << own[facei]
233 <<
" and " << nei[facei];
238 <<
"Severe skewness " <<
skew[facei]
239 <<
" for boundary face " << facei
240 <<
" on cell " << own[facei];
244 if (isMasterFace.test(facei))
263 Info<<
" ***Max skewness = " << maxSkew
264 <<
", " << nWarnSkew <<
" highly skew faces detected"
265 " which may impair the quality of the results"
274 Info<<
" Max skewness = " << maxSkew <<
" OK." <<
endl;
281bool Foam::polyMesh::checkEdgeAlignment
308 <<
"directions should contain 0 or 1 but is now " <<
directions
325 const face&
f = fcs[facei];
330 label p1 =
f.nextLabel(fp);
334 scalar magD =
mag(d);
336 if (magD > ROOTVSMALL)
341 label nEmptyDirs = 0;
342 label nNonEmptyDirs = 0;
345 if (
mag(d[cmpt]) > 1
e-6)
362 else if (nEmptyDirs == 1)
365 if (nNonEmptyDirs > 0)
367 edgesInError.insert(
edge(
p0, p1), facei);
370 else if (nEmptyDirs > 1)
373 edgesInError.insert(
edge(
p0, p1), facei);
389 Info<<
" ***Number of edges not aligned with or perpendicular to "
390 <<
"non-empty directions: " << nErrorEdges <<
endl;
395 setPtr->reserve(2*edgesInError.size());
398 setPtr->insert(iter.key().first());
399 setPtr->insert(iter.key().second());
408 Info<<
" All edges aligned with or perpendicular to "
409 <<
"non-empty directions." <<
endl;
416bool Foam::polyMesh::checkCellDeterminant
424 const scalar warnDet = 1
e-3;
435 scalarField& cellDeterminant = tcellDeterminant.ref();
438 label nErrorCells = 0;
439 scalar minDet =
min(cellDeterminant);
440 scalar sumDet =
sum(cellDeterminant);
442 forAll(cellDeterminant, celli)
444 if (cellDeterminant[celli] < warnDet)
448 setPtr->insert(celli);
469 Info<<
" Cell determinant (wellposedness) : minimum: " << minDet
470 <<
" average: " << sumDet/nSummed
482 Info<<
" ***Cells with small determinant (< "
483 << warnDet <<
") found, number of cells: "
484 << nErrorCells <<
endl;
492 Info<<
" Cell determinant check OK." <<
endl;
499bool Foam::polyMesh::checkFaceWeight
505 const scalar minWeight,
521 label nErrorFaces = 0;
522 scalar minDet = GREAT;
531 if (faceWght[facei] < minWeight)
536 setPtr->insert(facei);
543 if (isMasterFace.test(facei))
545 minDet =
min(minDet, faceWght[facei]);
546 sumDet += faceWght[facei];
565 Info<<
" Face interpolation weight : minimum: " << minDet
566 <<
" average: " << sumDet/nSummed
578 Info<<
" ***Faces with small interpolation weight (< " << minWeight
579 <<
") found, number of faces: "
580 << nErrorFaces <<
endl;
588 Info<<
" Face interpolation weight check OK." <<
endl;
595bool Foam::polyMesh::checkVolRatio
599 const scalar minRatio,
609 label nErrorFaces = 0;
610 scalar minDet = GREAT;
619 if (volRatio[facei] < minRatio)
624 setPtr->insert(facei);
631 if (isMasterFace.test(facei))
633 minDet =
min(minDet, volRatio[facei]);
634 sumDet += volRatio[facei];
649 meshDict.
set(
"aveFaceVolumeRatio", sumDet/nSummed);
653 Info<<
" Face volume ratio : minimum: " << minDet
654 <<
" average: " << sumDet/nSummed
661 meshDict.
set(
"thresholdFaceVolumeRatio", minRatio);
662 meshDict.
set(
"nErrorFaceVolumeRatio", nErrorFaces);
666 Info<<
" ***Faces with small volume ratio (< " << minRatio
667 <<
") found, number of faces: "
668 << nErrorFaces <<
endl;
683bool Foam::polyMesh::checkFaceOrthogonality
689 return checkFaceOrthogonality
700bool Foam::polyMesh::checkFaceSkewness
706 return checkFaceSkewness
719bool Foam::polyMesh::checkEdgeAlignment
726 return checkEdgeAlignment
736bool Foam::polyMesh::checkCellDeterminant
742 return checkCellDeterminant
752bool Foam::polyMesh::checkFaceWeight
755 const scalar minWeight,
759 return checkFaceWeight
771bool Foam::polyMesh::checkVolRatio
774 const scalar minRatio,
778 return checkVolRatio(
cellVolumes(), report, minRatio, setPtr);
786 const bool detailedReport
791 Pout<<
"bool polyMesh::checkMeshMotion("
792 <<
"const pointField&, const bool, const bool) const: "
793 <<
"checking mesh motion" <<
endl;
821 bool error = checkCellVolumes
831 bool areaError = checkFaceAreas
838 error = error || areaError;
842 bool pyrVolError = checkFacePyramids
851 error = error || pyrVolError;
855 bool nonOrthoError = checkFaceOrthogonality
863 error = error || nonOrthoError;
866 if (!error && (debug || report))
868 Pout<<
"Mesh motion check OK." <<
endl;
Map from edge (expressed as its endpoints) to value. Hashing (and ==) on an edge is symmetric.
static constexpr direction nComponents
Number of components in this vector space.
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Class to handle errors and exceptions in a simple, consistent stream-based manner.
A face is a list of labels corresponding to mesh vertices.
dictionary & meshDict()
Return the dictionary of mesh data, typically populated by the polyMesh::checkXXX functions,...
virtual const labelList & faceOwner() const
Return face owner.
virtual const meshState & data() const noexcept
Const reference to the mesh and solver state data.
virtual const labelList & faceNeighbour() const
Return face neighbour.
virtual bool checkMeshMotion(const pointField &newPoints, const bool report=false, const bool detailedReport=false) const
Check mesh motion for correctness given motion points.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
const vectorField & faceCentres() const
const scalarField & cellVolumes() const
const vectorField & cellCentres() const
bool checkFacePyramids(const pointField &points, const vectorField &ctrs, const bool report, const bool detailedReport, const scalar minPyrVol, labelHashSet *setPtr) const
Check face pyramid volume.
static scalar nonOrthThreshold_
Non-orthogonality warning threshold in deg.
bool checkCellVolumes(const scalarField &vols, const bool report, const bool detailedReport, labelHashSet *setPtr) const
Check for negative cell volumes.
bool checkFaceAreas(const vectorField &faceAreas, const bool report, const bool detailedReport, labelHashSet *setPtr) const
Check for negative face areas.
label nCells() const noexcept
Number of mesh cells.
label nFaces() const noexcept
Number of mesh faces.
const vectorField & faceAreas() const
A class for managing temporary objects.
const volScalarField & p0
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const IOdictionary & meshDict
#define WarningInFunction
Report a warning using Foam::Warning.
#define DebugInFunction
Report an information message using Foam::Info.
Namespace for handling debugging switches.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
messageStream Info
Information stream (stdout output on master, null elsewhere).
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
List< face > faceList
List of faces.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
constexpr scalar degToRad() noexcept
Multiplication factor for degrees to radians conversion.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
constexpr scalar radToDeg() noexcept
Multiplication factor for radians to degrees conversion.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Field< vector > vectorField
Specialisation of Field<T> for vector.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensionedScalar cos(const dimensionedScalar &ds)
dimensionedTensor skew(const dimensionedTensor &dt)
dimensionedScalar acos(const dimensionedScalar &ds)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
const scalarField & cellVols
Unit conversion functions.