33 bool Foam::polyMesh::checkFaceOrthogonality
38 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[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>());
132 Info<<
" Mesh non-orthogonality Max: " 140 if (severeNonOrth > 0)
142 Info<<
" *Number of severely non-orthogonal (> " 144 << severeNonOrth <<
"." <<
endl;
148 if (errorNonOrth > 0)
152 Info<<
" ***Number of non-orthogonality errors: " 153 << errorNonOrth <<
"." <<
endl;
162 Info<<
" Non-orthogonality check OK." <<
endl;
170 bool Foam::polyMesh::checkFaceSkewness
177 const bool detailedReport,
202 scalar maxSkew =
max(skew);
216 setPtr->insert(facei);
218 if (detailedReport && nWarnSkew == 0)
224 <<
"Severe skewness " << skew[facei]
225 <<
" for face " << facei
226 <<
" between cells " << own[facei]
227 <<
" and " << nei[facei];
232 <<
"Severe skewness " << skew[facei]
233 <<
" for boundary face " << facei
234 <<
" on cell " << own[facei];
238 if (isMasterFace[facei])
245 reduce(maxSkew, maxOp<scalar>());
246 reduce(nWarnSkew, sumOp<label>());
252 Info<<
" ***Max skewness = " << maxSkew
253 <<
", " << nWarnSkew <<
" highly skew faces detected" 254 " which may impair the quality of the results" 264 Info<<
" Max skewness = " << maxSkew <<
" OK." <<
endl;
272 bool Foam::polyMesh::checkEdgeAlignment
276 const Vector<label>& directions,
295 if (directions[cmpt] == 1)
299 else if (directions[cmpt] != 0)
302 <<
"directions should contain 0 or 1 but is now " << directions
307 if (nDirs == vector::nComponents)
315 EdgeMap<label> edgesInError;
319 const face& f = fcs[facei];
324 label p1 = f.nextLabel(fp);
328 scalar magD =
mag(d);
330 if (magD > rootVSmall)
335 label nEmptyDirs = 0;
336 label nNonEmptyDirs = 0;
339 if (
mag(d[cmpt]) > 1
e-6)
341 if (directions[cmpt] == 0)
356 else if (nEmptyDirs == 1)
359 if (nNonEmptyDirs > 0)
361 edgesInError.insert(edge(p0, p1), facei);
364 else if (nEmptyDirs > 1)
367 edgesInError.insert(edge(p0, p1), facei);
380 Info<<
" ***Number of edges not aligned with or perpendicular to " 381 <<
"non-empty directions: " << nErrorEdges <<
endl;
386 setPtr->resize(2*edgesInError.size());
389 setPtr->insert(iter.key()[0]);
390 setPtr->insert(iter.key()[1]);
400 Info<<
" All edges aligned with or perpendicular to " 401 <<
"non-empty directions." <<
endl;
408 bool Foam::polyMesh::checkCellDeterminant
413 const Vector<label>& meshD
416 const scalar warnDet = 1
e-3;
430 scalarField& cellDeterminant = tcellDeterminant.ref();
433 label nErrorCells = 0;
434 scalar minDet =
min(cellDeterminant);
435 scalar sumDet =
sum(cellDeterminant);
437 forAll(cellDeterminant, celli)
439 if (cellDeterminant[celli] < warnDet)
443 setPtr->insert(celli);
450 reduce(nErrorCells, sumOp<label>());
451 reduce(minDet, minOp<scalar>());
452 reduce(sumDet, sumOp<scalar>());
459 Info<<
" Cell determinant (wellposedness) : minimum: " << minDet
460 <<
" average: " << sumDet/nSummed
469 Info<<
" ***Cells with small determinant (< " 470 << warnDet <<
") found, number of cells: " 471 << nErrorCells <<
endl;
480 Info<<
" Cell determinant check OK." <<
endl;
490 bool Foam::polyMesh::checkFaceWeight
496 const scalar minWeight,
515 label nErrorFaces = 0;
516 scalar minDet = great;
525 if (faceWght[facei] < minWeight)
530 setPtr->insert(facei);
537 if (isMasterFace[facei])
539 minDet =
min(minDet, faceWght[facei]);
540 sumDet += faceWght[facei];
545 reduce(nErrorFaces, sumOp<label>());
546 reduce(minDet, minOp<scalar>());
547 reduce(sumDet, sumOp<scalar>());
548 reduce(nSummed, sumOp<label>());
554 Info<<
" Face interpolation weight : minimum: " << minDet
555 <<
" average: " << sumDet/nSummed
564 Info<<
" ***Faces with small interpolation weight (< " << minWeight
565 <<
") found, number of faces: " 566 << nErrorFaces <<
endl;
575 Info<<
" Face interpolation weight check OK." <<
endl;
585 bool Foam::polyMesh::checkVolRatio
589 const scalar minRatio,
602 label nErrorFaces = 0;
603 scalar minDet = great;
612 if (volRatio[facei] < minRatio)
617 setPtr->insert(facei);
624 if (isMasterFace[facei])
626 minDet =
min(minDet, volRatio[facei]);
627 sumDet += volRatio[facei];
632 reduce(nErrorFaces, sumOp<label>());
633 reduce(minDet, minOp<scalar>());
634 reduce(sumDet, sumOp<scalar>());
635 reduce(nSummed, sumOp<label>());
641 Info<<
" Face volume ratio : minimum: " << minDet
642 <<
" average: " << sumDet/nSummed
651 Info<<
" ***Faces with small volume ratio (< " << minRatio
652 <<
") found, number of faces: " 653 << nErrorFaces <<
endl;
662 Info<<
" Face volume ratio check OK." <<
endl;
672 bool Foam::polyMesh::checkFaceOrthogonality
678 return checkFaceOrthogonality
689 bool Foam::polyMesh::checkFaceSkewness
695 return checkFaceSkewness
708 bool Foam::polyMesh::checkEdgeAlignment
715 return checkEdgeAlignment
725 bool Foam::polyMesh::checkCellDeterminant
731 return checkCellDeterminant
741 bool Foam::polyMesh::checkFaceWeight
744 const scalar minWeight,
748 return checkFaceWeight
760 bool Foam::polyMesh::checkVolRatio
763 const scalar minRatio,
767 return checkVolRatio(
cellVolumes(), report, minRatio, setPtr);
775 const bool detailedReport
780 Pout<<
"bool polyMesh::checkMeshMotion(" 781 <<
"const pointField&, const bool, const bool) const: " 782 <<
"checking mesh motion" <<
endl;
815 error = error || areaError;
828 error = error || pyrVolError;
832 bool nonOrthoError = checkFaceOrthogonality
840 error = error || nonOrthoError;
843 if (!error && (debug || report))
845 Pout<<
"Mesh motion check OK." <<
endl;
bool checkFaceAreas(const vectorField &faceAreas, const bool report, const bool detailedReport, labelHashSet *setPtr) const
Check for negative face areas.
dimensionedScalar acos(const dimensionedScalar &ds)
#define forAll(list, i)
Loop across all elements in list.
void makeFaceCentresAndAreas(const pointField &p, vectorField &fCtrs, vectorField &fAreas, scalarField &magfAreas) const
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
scalar radToDeg(const scalar rad)
Conversion from radians to degrees.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
virtual const labelList & faceNeighbour() const
Return face neighbour.
Unit conversion functions.
Ostream & endl(Ostream &os)
Add newline and flush stream.
volVectorField vectorField(fieldObject, mesh)
Vector< scalar > vector
A scalar version of the templated Vector.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
virtual const pointField & points() const
Return raw points.
Class to handle errors and exceptions in a simple, consistent stream-based manner.
const Vector< label > & geometricD() const
Return the vector of geometric directions in mesh.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
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 const direction nComponents
Number of components in this vector space.
vectorField pointField
pointField is a vectorField.
dimensionedScalar cos(const dimensionedScalar &ds)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual const labelList & faceOwner() const
Return face owner.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< label > labelList
A List of labels.
void makeCellCentresAndVols(const vectorField &fCtrs, const vectorField &fAreas, vectorField &cellCtrs, scalarField &cellVols) const
virtual const faceList & faces() const
Return raw faces.
const vectorField & cellCentres() const
bool checkCellVolumes(const scalarField &vols, const bool report, const bool detailedReport, labelHashSet *setPtr) const
Check for negative cell volumes.
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross product operators.
const scalarField & cellVols
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const vectorField & faceCentres() const
#define WarningInFunction
Report a warning using Foam::Warning.
prefixOSstream Pout(cout, "Pout")
const vectorField & faceAreas() const
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
const doubleScalar e
Elementary charge.
static scalar skewThreshold_
Skewness warning threshold.
static scalar nonOrthThreshold_
Non-orthogonality warning threshold in deg.
virtual bool checkMeshMotion(const pointField &newPoints, const bool report=false, const bool detailedReport=false) const
Check mesh motion for correctness given motion points.
const scalarField & cellVolumes() const
#define InfoInFunction
Report an information message using Foam::Info.