36 bool Foam::polyMesh::checkFaceOrthogonality
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>());
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;
161 Info<<
" Non-orthogonality check OK." <<
endl;
168 bool Foam::polyMesh::checkFaceSkewness
175 const bool detailedReport,
207 if (
skew[facei] > skewThreshold_)
211 setPtr->insert(facei);
213 if (detailedReport && nWarnSkew == 0)
216 if (isInternalFace(facei))
219 <<
"Severe skewness " <<
skew[facei]
220 <<
" for face " << facei
221 <<
" between cells " << own[facei]
222 <<
" and " << nei[facei];
227 <<
"Severe skewness " <<
skew[facei]
228 <<
" for boundary face " << facei
229 <<
" on cell " << own[facei];
233 if (isMasterFace.test(facei))
240 reduce(maxSkew, maxOp<scalar>());
241 reduce(nWarnSkew, sumOp<label>());
247 Info<<
" ***Max skewness = " << maxSkew
248 <<
", " << nWarnSkew <<
" highly skew faces detected"
249 " which may impair the quality of the results"
258 Info<<
" Max skewness = " << maxSkew <<
" OK." <<
endl;
265 bool Foam::polyMesh::checkEdgeAlignment
269 const Vector<label>& directions,
285 if (directions[cmpt] == 1)
289 else if (directions[cmpt] != 0)
292 <<
"directions should contain 0 or 1 but is now " << directions
305 EdgeMap<label> edgesInError;
309 const face&
f = fcs[facei];
314 label p1 =
f.nextLabel(fp);
318 scalar magD =
mag(d);
320 if (magD > ROOTVSMALL)
325 label nEmptyDirs = 0;
326 label nNonEmptyDirs = 0;
329 if (
mag(d[cmpt]) > 1
e-6)
331 if (directions[cmpt] == 0)
346 else if (nEmptyDirs == 1)
349 if (nNonEmptyDirs > 0)
351 edgesInError.insert(edge(
p0, p1), facei);
354 else if (nEmptyDirs > 1)
357 edgesInError.insert(edge(
p0, p1), facei);
364 label nErrorEdges =
returnReduce(edgesInError.size(), sumOp<label>());
370 Info<<
" ***Number of edges not aligned with or perpendicular to "
371 <<
"non-empty directions: " << nErrorEdges <<
endl;
376 setPtr->resize(2*edgesInError.size());
379 setPtr->insert(iter.key()[0]);
380 setPtr->insert(iter.key()[1]);
389 Info<<
" All edges aligned with or perpendicular to "
390 <<
"non-empty directions." <<
endl;
397 bool Foam::polyMesh::checkCellDeterminant
402 const Vector<label>& meshD
405 const scalar warnDet = 1
e-3;
416 scalarField& cellDeterminant = tcellDeterminant.ref();
419 label nErrorCells = 0;
420 scalar minDet =
min(cellDeterminant);
421 scalar sumDet =
sum(cellDeterminant);
423 forAll(cellDeterminant, celli)
425 if (cellDeterminant[celli] < warnDet)
429 setPtr->insert(celli);
436 reduce(nErrorCells, sumOp<label>());
437 reduce(minDet, minOp<scalar>());
438 reduce(sumDet, sumOp<scalar>());
439 label nSummed =
returnReduce(cellDeterminant.size(), sumOp<label>());
445 Info<<
" Cell determinant (wellposedness) : minimum: " << minDet
446 <<
" average: " << sumDet/nSummed
455 Info<<
" ***Cells with small determinant (< "
456 << warnDet <<
") found, number of cells: "
457 << nErrorCells <<
endl;
465 Info<<
" Cell determinant check OK." <<
endl;
472 bool Foam::polyMesh::checkFaceWeight
478 const scalar minWeight,
494 label nErrorFaces = 0;
495 scalar minDet = GREAT;
504 if (faceWght[facei] < minWeight)
509 setPtr->insert(facei);
516 if (isMasterFace.test(facei))
518 minDet =
min(minDet, faceWght[facei]);
519 sumDet += faceWght[facei];
524 reduce(nErrorFaces, sumOp<label>());
525 reduce(minDet, minOp<scalar>());
526 reduce(sumDet, sumOp<scalar>());
527 reduce(nSummed, sumOp<label>());
533 Info<<
" Face interpolation weight : minimum: " << minDet
534 <<
" average: " << sumDet/nSummed
543 Info<<
" ***Faces with small interpolation weight (< " << minWeight
544 <<
") found, number of faces: "
545 << nErrorFaces <<
endl;
553 Info<<
" Face interpolation weight check OK." <<
endl;
560 bool Foam::polyMesh::checkVolRatio
564 const scalar minRatio,
574 label nErrorFaces = 0;
575 scalar minDet = GREAT;
584 if (volRatio[facei] < minRatio)
589 setPtr->insert(facei);
596 if (isMasterFace.test(facei))
598 minDet =
min(minDet, volRatio[facei]);
599 sumDet += volRatio[facei];
604 reduce(nErrorFaces, sumOp<label>());
605 reduce(minDet, minOp<scalar>());
606 reduce(sumDet, sumOp<scalar>());
607 reduce(nSummed, sumOp<label>());
613 Info<<
" Face volume ratio : minimum: " << minDet
614 <<
" average: " << sumDet/nSummed
623 Info<<
" ***Faces with small volume ratio (< " << minRatio
624 <<
") found, number of faces: "
625 << nErrorFaces <<
endl;
633 Info<<
" Face volume ratio check OK." <<
endl;
640 bool Foam::polyMesh::checkFaceOrthogonality
646 return checkFaceOrthogonality
657 bool Foam::polyMesh::checkFaceSkewness
663 return checkFaceSkewness
676 bool Foam::polyMesh::checkEdgeAlignment
683 return checkEdgeAlignment
693 bool Foam::polyMesh::checkCellDeterminant
699 return checkCellDeterminant
709 bool Foam::polyMesh::checkFaceWeight
712 const scalar minWeight,
716 return checkFaceWeight
728 bool Foam::polyMesh::checkVolRatio
731 const scalar minRatio,
735 return checkVolRatio(cellVolumes(), report, minRatio, setPtr);
743 const bool detailedReport
748 Pout<<
"bool polyMesh::checkMeshMotion("
749 <<
"const pointField&, const bool, const bool) const: "
750 <<
"checking mesh motion" <<
endl;
756 makeFaceCentresAndAreas(newPoints, fCtrs, fAreas);
762 makeCellCentresAndVols(fCtrs, fAreas, cellCtrs,
cellVols);
765 bool error = checkCellVolumes
775 bool areaError = checkFaceAreas
786 bool pyrVolError = checkFacePyramids
799 bool nonOrthoError = checkFaceOrthogonality
812 Pout<<
"Mesh motion check OK." <<
endl;