33 bool Foam::polyMesh::checkFaceOrthogonality
38 const bool detailedReport,
44 Info<<
"bool polyMesh::checkFaceOrthogonality(" 45 <<
"const bool, labelHashSet*) const: " 46 <<
"checking mesh non-orthogonality" <<
endl;
63 const scalar severeNonorthogonalityThreshold =
67 scalar minDDotS = GREAT;
68 scalar sumDDotS = 0.0;
70 label severeNonOrth = 0;
71 label errorNonOrth = 0;
79 if (ortho[faceI] < severeNonorthogonalityThreshold)
81 if (ortho[faceI] > SMALL)
85 setPtr->insert(faceI);
95 setPtr->insert(faceI);
97 if (detailedReport && errorNonOrth == 0)
102 "polyMesh::checkFaceOrthogonality" 103 "(const pointField&, const bool) const" 104 ) <<
"Severe non-orthogonality for face " 106 <<
" between cells " << own[faceI]
107 <<
" and " << nei[faceI]
117 if (isMasterFace[faceI])
119 minDDotS =
min(minDDotS, ortho[faceI]);
120 sumDDotS += ortho[faceI];
125 reduce(minDDotS, minOp<scalar>());
126 reduce(sumDDotS, sumOp<scalar>());
127 reduce(nSummed, sumOp<label>());
128 reduce(severeNonOrth, sumOp<label>());
129 reduce(errorNonOrth, sumOp<label>());
137 Info<<
" Mesh non-orthogonality Max: " 145 if (severeNonOrth > 0)
147 Info<<
" *Number of severely non-orthogonal (> " 149 << severeNonOrth <<
"." <<
endl;
153 if (errorNonOrth > 0)
157 Info<<
" ***Number of non-orthogonality errors: " 158 << errorNonOrth <<
"." <<
endl;
167 Info<<
" Non-orthogonality check OK." <<
endl;
175 bool Foam::polyMesh::checkFaceSkewness
182 const bool detailedReport,
188 Info<<
"bool polyMesh::checkFaceSkewnesss(" 189 <<
"const bool, labelHashSet*) const: " 190 <<
"checking face skewness" <<
endl;
209 scalar maxSkew =
max(skew);
223 setPtr->insert(faceI);
225 if (detailedReport && nWarnSkew == 0)
232 "polyMesh::checkFaceSkewnesss" 233 "(const pointField&, const bool) const" 234 ) <<
"Severe skewness " << skew[faceI]
235 <<
" for face " << faceI
236 <<
" between cells " << own[faceI]
237 <<
" and " << nei[faceI];
243 "polyMesh::checkFaceSkewnesss" 244 "(const pointField&, const bool) const" 245 ) <<
"Severe skewness " << skew[faceI]
246 <<
" for boundary face " << faceI
247 <<
" on cell " << own[faceI];
251 if (isMasterFace[faceI])
258 reduce(maxSkew, maxOp<scalar>());
259 reduce(nWarnSkew, sumOp<label>());
265 Info<<
" ***Max skewness = " << maxSkew
266 <<
", " << nWarnSkew <<
" highly skew faces detected" 267 " which may impair the quality of the results" 277 Info<<
" Max skewness = " << maxSkew <<
" OK." <<
endl;
291 bool Foam::polyMesh::checkEdgeAlignment
295 const Vector<label>& directions,
301 Info<<
"bool polyMesh::checkEdgeAlignment(" 302 <<
"const bool, const Vector<label>&, labelHashSet*) const: " 303 <<
"checking edge alignment" <<
endl;
309 if (directions[cmpt] == 1)
313 else if (directions[cmpt] != 0)
317 "polyMesh::checkEdgeAlignment" 318 "(const bool, const Vector<label>&, labelHashSet*)" 319 ) <<
"directions should contain 0 or 1 but is now " << directions
324 if (nDirs == vector::nComponents)
332 EdgeMap<label> edgesInError;
336 const face& f = fcs[faceI];
341 label p1 = f.nextLabel(fp);
345 scalar magD =
mag(d);
347 if (magD > ROOTVSMALL)
352 label nEmptyDirs = 0;
353 label nNonEmptyDirs = 0;
356 if (
mag(d[cmpt]) > 1
e-6)
358 if (directions[cmpt] == 0)
373 else if (nEmptyDirs == 1)
376 if (nNonEmptyDirs > 0)
378 edgesInError.insert(edge(p0, p1), faceI);
381 else if (nEmptyDirs > 1)
384 edgesInError.insert(edge(p0, p1), faceI);
397 Info<<
" ***Number of edges not aligned with or perpendicular to " 398 <<
"non-empty directions: " << nErrorEdges <<
endl;
403 setPtr->resize(2*edgesInError.size());
406 setPtr->insert(iter.key()[0]);
407 setPtr->insert(iter.key()[1]);
417 Info<<
" All edges aligned with or perpendicular to " 418 <<
"non-empty directions." <<
endl;
425 bool Foam::polyMesh::checkCellDeterminant
430 const Vector<label>& meshD
433 const scalar warnDet = 1
e-3;
437 Info<<
"bool polyMesh::checkCellDeterminant(const bool" 438 <<
", labelHashSet*) const: " 439 <<
"checking for under-determined cells" <<
endl;
452 label nErrorCells = 0;
453 scalar minDet =
min(cellDeterminant);
454 scalar sumDet =
sum(cellDeterminant);
456 forAll (cellDeterminant, cellI)
458 if (cellDeterminant[cellI] < warnDet)
462 setPtr->insert(cellI);
469 reduce(nErrorCells, sumOp<label>());
470 reduce(minDet, minOp<scalar>());
471 reduce(sumDet, sumOp<scalar>());
478 Info<<
" Cell determinant (wellposedness) : minimum: " << minDet
479 <<
" average: " << sumDet/nSummed
488 Info<<
" ***Cells with small determinant (< " 489 << warnDet <<
") found, number of cells: " 490 << nErrorCells <<
endl;
499 Info<<
" Cell determinant check OK." <<
endl;
509 bool Foam::polyMesh::checkFaceWeight
515 const scalar minWeight,
521 Info<<
"bool polyMesh::checkFaceWeight(const bool" 522 <<
", labelHashSet*) const: " 523 <<
"checking for low face interpolation weights" <<
endl;
536 label nErrorFaces = 0;
537 scalar minDet = GREAT;
546 if (faceWght[faceI] < minWeight)
551 setPtr->insert(faceI);
558 if (isMasterFace[faceI])
560 minDet =
min(minDet, faceWght[faceI]);
561 sumDet += faceWght[faceI];
566 reduce(nErrorFaces, sumOp<label>());
567 reduce(minDet, minOp<scalar>());
568 reduce(sumDet, sumOp<scalar>());
569 reduce(nSummed, sumOp<label>());
575 Info<<
" Face interpolation weight : minimum: " << minDet
576 <<
" average: " << sumDet/nSummed
585 Info<<
" ***Faces with small interpolation weight (< " << minWeight
586 <<
") found, number of faces: " 587 << nErrorFaces <<
endl;
596 Info<<
" Face interpolation weight check OK." <<
endl;
606 bool Foam::polyMesh::checkVolRatio
610 const scalar minRatio,
616 Info<<
"bool polyMesh::checkVolRatio(const bool" 617 <<
", labelHashSet*) const: " 618 <<
"checking for volume ratio < " << minRatio <<
endl;
625 label nErrorFaces = 0;
626 scalar minDet = GREAT;
635 if (volRatio[faceI] < minRatio)
640 setPtr->insert(faceI);
647 if (isMasterFace[faceI])
649 minDet =
min(minDet, volRatio[faceI]);
650 sumDet += volRatio[faceI];
655 reduce(nErrorFaces, sumOp<label>());
656 reduce(minDet, minOp<scalar>());
657 reduce(sumDet, sumOp<scalar>());
658 reduce(nSummed, sumOp<label>());
664 Info<<
" Face volume ratio : minimum: " << minDet
665 <<
" average: " << sumDet/nSummed
674 Info<<
" ***Faces with small volume ratio (< " << minRatio
675 <<
") found, number of faces: " 676 << nErrorFaces <<
endl;
685 Info<<
" Face volume ratio check OK." <<
endl;
708 bool Foam::polyMesh::checkFaceOrthogonality
714 return checkFaceOrthogonality
725 bool Foam::polyMesh::checkFaceSkewness
731 return checkFaceSkewness
744 bool Foam::polyMesh::checkEdgeAlignment
751 return checkEdgeAlignment
761 bool Foam::polyMesh::checkCellDeterminant
767 return checkCellDeterminant
777 bool Foam::polyMesh::checkFaceWeight
780 const scalar minWeight,
784 return checkFaceWeight
796 bool Foam::polyMesh::checkVolRatio
799 const scalar minRatio,
803 return checkVolRatio(
cellVolumes(), report, minRatio, setPtr);
811 const bool detailedReport
816 Pout<<
"bool polyMesh::checkMeshMotion(" 817 <<
"const pointField&, const bool, const bool) const: " 818 <<
"checking mesh motion" <<
endl;
850 error = error || areaError;
863 error = error || pyrVolError;
867 bool nonOrthoError = checkFaceOrthogonality
875 error = error || nonOrthoError;
878 if (!error && (debug || report))
880 Pout<<
"Mesh motion check OK." <<
endl;
const vectorField & faceAreas() const
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
bool checkFaceAreas(const vectorField &faceAreas, const bool report, const bool detailedReport, labelHashSet *setPtr) const
Check for negative face areas.
void makeCellCentresAndVols(const vectorField &fCtrs, const vectorField &fAreas, vectorField &cellCtrs, scalarField &cellVols) const
static PackedBoolList getMasterFaces(const polyMesh &)
Get per face whether it is uncoupled or a master of a.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
bool checkFacePyramids(const pointField &points, const vectorField &ctrs, const bool report, const bool detailedReport, const scalar minPyrVol, labelHashSet *setPtr) const
Check face pyramid volume.
dimensioned< scalar > mag(const dimensioned< Type > &)
bool checkCellVolumes(const scalarField &vols, const bool report, const bool detailedReport, labelHashSet *setPtr) const
Check for negative cell volumes.
static tmp< scalarField > faceOrthogonality(const polyMesh &mesh, const vectorField &fAreas, const vectorField &cellCtrs)
Generate orthogonality field. (1 for fully orthogonal, < 1 for.
static PackedBoolList getInternalOrMasterFaces(const polyMesh &)
Get per face whether it is internal or a master of a.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual bool checkMeshMotion(const pointField &newPoints, const bool report=false, const bool detailedReport=false) const
Check mesh motion for correctness given motion points.
static tmp< scalarField > faceSkewness(const polyMesh &mesh, const pointField &points, const vectorField &fCtrs, const vectorField &fAreas, const vectorField &cellCtrs)
Generate skewness field.
const scalarField & cellVols
const vectorField & cellCentres() const
static PackedBoolList getInternalOrCoupledFaces(const polyMesh &)
Get per face whether it is internal or coupled.
vectorField pointField
pointField is a vectorField.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Number of components in this vector space.
const double e
Elementary charge.
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define WarningIn(functionName)
Report a warning using Foam::Warning.
void makeFaceCentresAndAreas(const pointField &p, vectorField &fCtrs, vectorField &fAreas) const
virtual const pointField & points() const
Return raw points.
volVectorField vectorField(fieldObject, mesh)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static scalar skewThreshold_
Skewness warning threshold.
dimensionedScalar cos(const dimensionedScalar &ds)
static scalar nonOrthThreshold_
Non-orthogonality warning threshold in deg.
scalar radToDeg(const scalar rad)
Conversion from radians to degrees.
static tmp< scalarField > faceWeights(const polyMesh &mesh, const vectorField &fCtrs, const vectorField &fAreas, const vectorField &cellCtrs)
Generate interpolation factors field.
Unit conversion functions.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
dimensionedScalar acos(const dimensionedScalar &ds)
virtual const labelList & faceOwner() const
Return face owner.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
static tmp< scalarField > volRatio(const polyMesh &mesh, const scalarField &vol)
Generate volume ratio field.
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.
List< label > labelList
A List of labels.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
Vector< scalar > vector
A scalar version of the templated Vector.
virtual const faceList & faces() const
Return raw faces.
static tmp< scalarField > cellDeterminant(const primitiveMesh &mesh, const Vector< label > &directions, const vectorField &faceAreas, const PackedBoolList &internalOrCoupledFace)
Generate cell determinant field.
const scalarField & cellVolumes() const
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
virtual const labelList & faceNeighbour() const
Return face neighbour.
prefixOSstream Pout(cout,"Pout")
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
const vectorField & faceCentres() const