00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "polyMeshGeometry.H"
00028 #include "pyramidPointFaceRef.H"
00029 #include "syncTools.H"
00030
00031 namespace Foam
00032 {
00033
00034
00035
00036 defineTypeNameAndDebug(polyMeshGeometry, 0);
00037
00038 }
00039
00040
00041
00042
00043 void Foam::polyMeshGeometry::updateFaceCentresAndAreas
00044 (
00045 const pointField& p,
00046 const labelList& changedFaces
00047 )
00048 {
00049 const faceList& fs = mesh_.faces();
00050
00051 forAll(changedFaces, i)
00052 {
00053 label facei = changedFaces[i];
00054
00055 const labelList& f = fs[facei];
00056 label nPoints = f.size();
00057
00058
00059
00060 if (nPoints == 3)
00061 {
00062 faceCentres_[facei] = (1.0/3.0)*(p[f[0]] + p[f[1]] + p[f[2]]);
00063 faceAreas_[facei] = 0.5*((p[f[1]] - p[f[0]])^(p[f[2]] - p[f[0]]));
00064 }
00065 else
00066 {
00067 vector sumN = vector::zero;
00068 scalar sumA = 0.0;
00069 vector sumAc = vector::zero;
00070
00071 point fCentre = p[f[0]];
00072 for (label pi = 1; pi < nPoints; pi++)
00073 {
00074 fCentre += p[f[pi]];
00075 }
00076
00077 fCentre /= nPoints;
00078
00079 for (label pi = 0; pi < nPoints; pi++)
00080 {
00081 const point& nextPoint = p[f[(pi + 1) % nPoints]];
00082
00083 vector c = p[f[pi]] + nextPoint + fCentre;
00084 vector n = (nextPoint - p[f[pi]])^(fCentre - p[f[pi]]);
00085 scalar a = mag(n);
00086
00087 sumN += n;
00088 sumA += a;
00089 sumAc += a*c;
00090 }
00091
00092 faceCentres_[facei] = (1.0/3.0)*sumAc/(sumA + VSMALL);
00093 faceAreas_[facei] = 0.5*sumN;
00094 }
00095 }
00096 }
00097
00098
00099 void Foam::polyMeshGeometry::updateCellCentresAndVols
00100 (
00101 const labelList& changedCells,
00102 const labelList& changedFaces
00103 )
00104 {
00105
00106 UIndirectList<vector>(cellCentres_, changedCells) = vector::zero;
00107 UIndirectList<scalar>(cellVolumes_, changedCells) = 0.0;
00108
00109 const labelList& own = mesh_.faceOwner();
00110 const labelList& nei = mesh_.faceNeighbour();
00111
00112
00113
00114 vectorField cEst(mesh_.nCells());
00115 UIndirectList<vector>(cEst, changedCells) = vector::zero;
00116 scalarField nCellFaces(mesh_.nCells());
00117 UIndirectList<scalar>(nCellFaces, changedCells) = 0.0;
00118
00119 forAll(changedFaces, i)
00120 {
00121 label faceI = changedFaces[i];
00122 cEst[own[faceI]] += faceCentres_[faceI];
00123 nCellFaces[own[faceI]] += 1;
00124
00125 if (mesh_.isInternalFace(faceI))
00126 {
00127 cEst[nei[faceI]] += faceCentres_[faceI];
00128 nCellFaces[nei[faceI]] += 1;
00129 }
00130 }
00131
00132 forAll(changedCells, i)
00133 {
00134 label cellI = changedCells[i];
00135 cEst[cellI] /= nCellFaces[cellI];
00136 }
00137
00138 forAll(changedFaces, i)
00139 {
00140 label faceI = changedFaces[i];
00141
00142
00143 scalar pyr3Vol = max
00144 (
00145 faceAreas_[faceI] & (faceCentres_[faceI] - cEst[own[faceI]]),
00146 VSMALL
00147 );
00148
00149
00150 vector pc = (3.0/4.0)*faceCentres_[faceI] + (1.0/4.0)*cEst[own[faceI]];
00151
00152
00153 cellCentres_[own[faceI]] += pyr3Vol*pc;
00154
00155
00156 cellVolumes_[own[faceI]] += pyr3Vol;
00157
00158 if (mesh_.isInternalFace(faceI))
00159 {
00160
00161 scalar pyr3Vol = max
00162 (
00163 faceAreas_[faceI] & (cEst[nei[faceI]] - faceCentres_[faceI]),
00164 VSMALL
00165 );
00166
00167
00168 vector pc =
00169 (3.0/4.0)*faceCentres_[faceI]
00170 + (1.0/4.0)*cEst[nei[faceI]];
00171
00172
00173 cellCentres_[nei[faceI]] += pyr3Vol*pc;
00174
00175
00176 cellVolumes_[nei[faceI]] += pyr3Vol;
00177 }
00178 }
00179
00180 forAll(changedCells, i)
00181 {
00182 label cellI = changedCells[i];
00183
00184 cellCentres_[cellI] /= cellVolumes_[cellI] + VSMALL;
00185 cellVolumes_[cellI] *= (1.0/3.0);
00186 }
00187 }
00188
00189
00190 Foam::labelList Foam::polyMeshGeometry::affectedCells
00191 (
00192 const polyMesh& mesh,
00193 const labelList& changedFaces
00194 )
00195 {
00196 const labelList& own = mesh.faceOwner();
00197 const labelList& nei = mesh.faceNeighbour();
00198
00199 labelHashSet affectedCells(2*changedFaces.size());
00200
00201 forAll(changedFaces, i)
00202 {
00203 label faceI = changedFaces[i];
00204
00205 affectedCells.insert(own[faceI]);
00206
00207 if (mesh.isInternalFace(faceI))
00208 {
00209 affectedCells.insert(nei[faceI]);
00210 }
00211 }
00212 return affectedCells.toc();
00213 }
00214
00215
00216 Foam::scalar Foam::polyMeshGeometry::checkNonOrtho
00217 (
00218 const polyMesh& mesh,
00219 const bool report,
00220 const scalar severeNonorthogonalityThreshold,
00221 const label faceI,
00222 const vector& s,
00223 const vector& d,
00224
00225 label& severeNonOrth,
00226 label& errorNonOrth,
00227 labelHashSet* setPtr
00228 )
00229 {
00230 scalar dDotS = (d & s)/(mag(d)*mag(s) + VSMALL);
00231
00232 if (dDotS < severeNonorthogonalityThreshold)
00233 {
00234 label nei = -1;
00235
00236 if (mesh.isInternalFace(faceI))
00237 {
00238 nei = mesh.faceNeighbour()[faceI];
00239 }
00240
00241 if (dDotS > SMALL)
00242 {
00243 if (report)
00244 {
00245
00246 Pout<< "Severe non-orthogonality for face " << faceI
00247 << " between cells " << mesh.faceOwner()[faceI]
00248 << " and " << nei
00249 << ": Angle = "
00250 << ::acos(dDotS)/mathematicalConstant::pi*180.0
00251 << " deg." << endl;
00252 }
00253
00254 severeNonOrth++;
00255 }
00256 else
00257 {
00258
00259 if (report)
00260 {
00261 WarningIn
00262 (
00263 "polyMeshGeometry::checkFaceDotProduct"
00264 "(const bool, const scalar, const labelList&"
00265 ", labelHashSet*)"
00266 ) << "Severe non-orthogonality detected for face "
00267 << faceI
00268 << " between cells " << mesh.faceOwner()[faceI]
00269 << " and " << nei
00270 << ": Angle = "
00271 << ::acos(dDotS)/mathematicalConstant::pi*180.0
00272 << " deg." << endl;
00273 }
00274
00275 errorNonOrth++;
00276 }
00277
00278 if (setPtr)
00279 {
00280 setPtr->insert(faceI);
00281 }
00282 }
00283 return dDotS;
00284 }
00285
00286
00287 Foam::scalar Foam::polyMeshGeometry::calcSkewness
00288 (
00289 const point& ownCc,
00290 const point& neiCc,
00291 const point& fc
00292 )
00293 {
00294 scalar dOwn = mag(fc - ownCc);
00295 scalar dNei = mag(fc - neiCc);
00296
00297 point faceIntersection =
00298 ownCc*dNei/(dOwn+dNei+VSMALL)
00299 + neiCc*dOwn/(dOwn+dNei+VSMALL);
00300
00301 return
00302 mag(fc - faceIntersection)
00303 / (
00304 mag(neiCc-ownCc)
00305 + VSMALL
00306 );
00307 }
00308
00309
00310
00311
00312
00313 Foam::polyMeshGeometry::polyMeshGeometry(const polyMesh& mesh)
00314 :
00315 mesh_(mesh)
00316 {
00317 correct();
00318 }
00319
00320
00321
00322
00323
00324
00325
00326
00327 void Foam::polyMeshGeometry::correct()
00328 {
00329 faceAreas_ = mesh_.faceAreas();
00330 faceCentres_ = mesh_.faceCentres();
00331 cellCentres_ = mesh_.cellCentres();
00332 cellVolumes_ = mesh_.cellVolumes();
00333 }
00334
00335
00336
00337 void Foam::polyMeshGeometry::correct
00338 (
00339 const pointField& p,
00340 const labelList& changedFaces
00341 )
00342 {
00343
00344 updateFaceCentresAndAreas(p, changedFaces);
00345
00346 updateCellCentresAndVols(affectedCells(mesh_, changedFaces), changedFaces);
00347 }
00348
00349
00350 bool Foam::polyMeshGeometry::checkFaceDotProduct
00351 (
00352 const bool report,
00353 const scalar orthWarn,
00354 const polyMesh& mesh,
00355 const vectorField& cellCentres,
00356 const vectorField& faceAreas,
00357 const labelList& checkFaces,
00358 const List<labelPair>& baffles,
00359 labelHashSet* setPtr
00360 )
00361 {
00362
00363
00364
00365 const labelList& own = mesh.faceOwner();
00366 const labelList& nei = mesh.faceNeighbour();
00367 const polyBoundaryMesh& patches = mesh.boundaryMesh();
00368
00369
00370 const scalar severeNonorthogonalityThreshold =
00371 ::cos(orthWarn/180.0*mathematicalConstant::pi);
00372
00373
00374
00375 vectorField neiCc(mesh.nFaces()-mesh.nInternalFaces());
00376
00377 for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
00378 {
00379 neiCc[faceI-mesh.nInternalFaces()] = cellCentres[own[faceI]];
00380 }
00381 syncTools::swapBoundaryFaceList(mesh, neiCc, true);
00382
00383
00384 scalar minDDotS = GREAT;
00385
00386 scalar sumDDotS = 0;
00387 label nDDotS = 0;
00388
00389 label severeNonOrth = 0;
00390
00391 label errorNonOrth = 0;
00392
00393 forAll(checkFaces, i)
00394 {
00395 label faceI = checkFaces[i];
00396
00397 const point& ownCc = cellCentres[own[faceI]];
00398
00399 if (mesh.isInternalFace(faceI))
00400 {
00401 scalar dDotS = checkNonOrtho
00402 (
00403 mesh,
00404 report,
00405 severeNonorthogonalityThreshold,
00406 faceI,
00407 faceAreas[faceI],
00408 cellCentres[nei[faceI]] - ownCc,
00409
00410 severeNonOrth,
00411 errorNonOrth,
00412 setPtr
00413 );
00414
00415 if (dDotS < minDDotS)
00416 {
00417 minDDotS = dDotS;
00418 }
00419
00420 sumDDotS += dDotS;
00421 nDDotS++;
00422 }
00423 else
00424 {
00425 label patchI = patches.whichPatch(faceI);
00426
00427 if (patches[patchI].coupled())
00428 {
00429 scalar dDotS = checkNonOrtho
00430 (
00431 mesh,
00432 report,
00433 severeNonorthogonalityThreshold,
00434 faceI,
00435 faceAreas[faceI],
00436 neiCc[faceI-mesh.nInternalFaces()] - ownCc,
00437
00438 severeNonOrth,
00439 errorNonOrth,
00440 setPtr
00441 );
00442
00443 if (dDotS < minDDotS)
00444 {
00445 minDDotS = dDotS;
00446 }
00447
00448 sumDDotS += dDotS;
00449 nDDotS++;
00450 }
00451 }
00452 }
00453
00454 forAll(baffles, i)
00455 {
00456 label face0 = baffles[i].first();
00457 label face1 = baffles[i].second();
00458
00459 const point& ownCc = cellCentres[own[face0]];
00460
00461 scalar dDotS = checkNonOrtho
00462 (
00463 mesh,
00464 report,
00465 severeNonorthogonalityThreshold,
00466 face0,
00467 faceAreas[face0],
00468 cellCentres[own[face1]] - ownCc,
00469
00470 severeNonOrth,
00471 errorNonOrth,
00472 setPtr
00473 );
00474
00475 if (dDotS < minDDotS)
00476 {
00477 minDDotS = dDotS;
00478 }
00479
00480 sumDDotS += dDotS;
00481 nDDotS++;
00482 }
00483
00484 reduce(minDDotS, minOp<scalar>());
00485 reduce(sumDDotS, sumOp<scalar>());
00486 reduce(nDDotS, sumOp<label>());
00487 reduce(severeNonOrth, sumOp<label>());
00488 reduce(errorNonOrth, sumOp<label>());
00489
00490
00491 if (nDDotS > 0)
00492 {
00493 if (report && minDDotS < severeNonorthogonalityThreshold)
00494 {
00495 Info<< "Number of non-orthogonality errors: " << errorNonOrth
00496 << ". Number of severely non-orthogonal faces: "
00497 << severeNonOrth << "." << endl;
00498 }
00499 }
00500
00501 if (report)
00502 {
00503 if (nDDotS > 0)
00504 {
00505 Info<< "Mesh non-orthogonality Max: "
00506 << ::acos(minDDotS)/mathematicalConstant::pi*180.0
00507 << " average: " <<
00508 ::acos(sumDDotS/nDDotS)/mathematicalConstant::pi*180.0
00509 << endl;
00510 }
00511 }
00512
00513 if (errorNonOrth > 0)
00514 {
00515 if (report)
00516 {
00517 SeriousErrorIn
00518 (
00519 "polyMeshGeometry::checkFaceDotProduct"
00520 "(const bool, const scalar, const labelList&, labelHashSet*)"
00521 ) << "Error in non-orthogonality detected" << endl;
00522 }
00523
00524 return true;
00525 }
00526 else
00527 {
00528 if (report)
00529 {
00530 Info<< "Non-orthogonality check OK.\n" << endl;
00531 }
00532
00533 return false;
00534 }
00535 }
00536
00537
00538 bool Foam::polyMeshGeometry::checkFacePyramids
00539 (
00540 const bool report,
00541 const scalar minPyrVol,
00542 const polyMesh& mesh,
00543 const vectorField& cellCentres,
00544 const pointField& p,
00545 const labelList& checkFaces,
00546 const List<labelPair>& baffles,
00547 labelHashSet* setPtr
00548 )
00549 {
00550
00551 const labelList& own = mesh.faceOwner();
00552 const labelList& nei = mesh.faceNeighbour();
00553
00554 const faceList& f = mesh.faces();
00555
00556 label nErrorPyrs = 0;
00557
00558 forAll(checkFaces, i)
00559 {
00560 label faceI = checkFaces[i];
00561
00562
00563 scalar pyrVol = pyramidPointFaceRef
00564 (
00565 f[faceI],
00566 cellCentres[own[faceI]]
00567 ).mag(p);
00568
00569 if (pyrVol > -minPyrVol)
00570 {
00571 if (report)
00572 {
00573 Pout<< "bool polyMeshGeometry::checkFacePyramids("
00574 << "const bool, const scalar, const pointField&"
00575 << ", const labelList&, labelHashSet*): "
00576 << "face " << faceI << " points the wrong way. " << endl
00577 << "Pyramid volume: " << -pyrVol
00578 << " Face " << f[faceI] << " area: " << f[faceI].mag(p)
00579 << " Owner cell: " << own[faceI] << endl
00580 << "Owner cell vertex labels: "
00581 << mesh.cells()[own[faceI]].labels(f)
00582 << endl;
00583 }
00584
00585
00586 if (setPtr)
00587 {
00588 setPtr->insert(faceI);
00589 }
00590
00591 nErrorPyrs++;
00592 }
00593
00594 if (mesh.isInternalFace(faceI))
00595 {
00596
00597 scalar pyrVol =
00598 pyramidPointFaceRef(f[faceI], cellCentres[nei[faceI]]).mag(p);
00599
00600 if (pyrVol < minPyrVol)
00601 {
00602 if (report)
00603 {
00604 Pout<< "bool polyMeshGeometry::checkFacePyramids("
00605 << "const bool, const scalar, const pointField&"
00606 << ", const labelList&, labelHashSet*): "
00607 << "face " << faceI << " points the wrong way. " << endl
00608 << "Pyramid volume: " << -pyrVol
00609 << " Face " << f[faceI] << " area: " << f[faceI].mag(p)
00610 << " Neighbour cell: " << nei[faceI] << endl
00611 << "Neighbour cell vertex labels: "
00612 << mesh.cells()[nei[faceI]].labels(f)
00613 << endl;
00614 }
00615
00616 if (setPtr)
00617 {
00618 setPtr->insert(faceI);
00619 }
00620
00621 nErrorPyrs++;
00622 }
00623 }
00624 }
00625
00626 forAll(baffles, i)
00627 {
00628 label face0 = baffles[i].first();
00629 label face1 = baffles[i].second();
00630
00631 const point& ownCc = cellCentres[own[face0]];
00632
00633
00634 scalar pyrVolOwn = pyramidPointFaceRef
00635 (
00636 f[face0],
00637 ownCc
00638 ).mag(p);
00639
00640 if (pyrVolOwn > -minPyrVol)
00641 {
00642 if (report)
00643 {
00644 Pout<< "bool polyMeshGeometry::checkFacePyramids("
00645 << "const bool, const scalar, const pointField&"
00646 << ", const labelList&, labelHashSet*): "
00647 << "face " << face0 << " points the wrong way. " << endl
00648 << "Pyramid volume: " << -pyrVolOwn
00649 << " Face " << f[face0] << " area: " << f[face0].mag(p)
00650 << " Owner cell: " << own[face0] << endl
00651 << "Owner cell vertex labels: "
00652 << mesh.cells()[own[face0]].labels(f)
00653 << endl;
00654 }
00655
00656
00657 if (setPtr)
00658 {
00659 setPtr->insert(face0);
00660 }
00661
00662 nErrorPyrs++;
00663 }
00664
00665
00666 scalar pyrVolNbr =
00667 pyramidPointFaceRef(f[face0], cellCentres[own[face1]]).mag(p);
00668
00669 if (pyrVolNbr < minPyrVol)
00670 {
00671 if (report)
00672 {
00673 Pout<< "bool polyMeshGeometry::checkFacePyramids("
00674 << "const bool, const scalar, const pointField&"
00675 << ", const labelList&, labelHashSet*): "
00676 << "face " << face0 << " points the wrong way. " << endl
00677 << "Pyramid volume: " << -pyrVolNbr
00678 << " Face " << f[face0] << " area: " << f[face0].mag(p)
00679 << " Neighbour cell: " << own[face1] << endl
00680 << "Neighbour cell vertex labels: "
00681 << mesh.cells()[own[face1]].labels(f)
00682 << endl;
00683 }
00684
00685 if (setPtr)
00686 {
00687 setPtr->insert(face0);
00688 }
00689
00690 nErrorPyrs++;
00691 }
00692 }
00693
00694 reduce(nErrorPyrs, sumOp<label>());
00695
00696 if (nErrorPyrs > 0)
00697 {
00698 if (report)
00699 {
00700 SeriousErrorIn
00701 (
00702 "polyMeshGeometry::checkFacePyramids("
00703 "const bool, const scalar, const pointField&"
00704 ", const labelList&, labelHashSet*)"
00705 ) << "Error in face pyramids: faces pointing the wrong way!"
00706 << endl;
00707 }
00708
00709 return true;
00710 }
00711 else
00712 {
00713 if (report)
00714 {
00715 Info<< "Face pyramids OK.\n" << endl;
00716 }
00717
00718 return false;
00719 }
00720 }
00721
00722
00723 bool Foam::polyMeshGeometry::checkFaceSkewness
00724 (
00725 const bool report,
00726 const scalar internalSkew,
00727 const scalar boundarySkew,
00728 const polyMesh& mesh,
00729 const vectorField& cellCentres,
00730 const vectorField& faceCentres,
00731 const vectorField& faceAreas,
00732 const labelList& checkFaces,
00733 const List<labelPair>& baffles,
00734 labelHashSet* setPtr
00735 )
00736 {
00737
00738
00739
00740 const labelList& own = mesh.faceOwner();
00741 const labelList& nei = mesh.faceNeighbour();
00742 const polyBoundaryMesh& patches = mesh.boundaryMesh();
00743
00744
00745 vectorField neiCc(mesh.nFaces()-mesh.nInternalFaces());
00746
00747 for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
00748 {
00749 neiCc[faceI-mesh.nInternalFaces()] = cellCentres[own[faceI]];
00750 }
00751 syncTools::swapBoundaryFaceList(mesh, neiCc, true);
00752
00753
00754 scalar maxSkew = 0;
00755
00756 label nWarnSkew = 0;
00757
00758 forAll(checkFaces, i)
00759 {
00760 label faceI = checkFaces[i];
00761
00762 if (mesh.isInternalFace(faceI))
00763 {
00764 scalar skewness = calcSkewness
00765 (
00766 cellCentres[own[faceI]],
00767 cellCentres[nei[faceI]],
00768 faceCentres[faceI]
00769 );
00770
00771
00772
00773
00774 if (skewness > internalSkew)
00775 {
00776 if (report)
00777 {
00778 Pout<< "Severe skewness for face " << faceI
00779 << " skewness = " << skewness << endl;
00780 }
00781
00782 if (setPtr)
00783 {
00784 setPtr->insert(faceI);
00785 }
00786
00787 nWarnSkew++;
00788 }
00789
00790 maxSkew = max(maxSkew, skewness);
00791 }
00792 else if (patches[patches.whichPatch(faceI)].coupled())
00793 {
00794 scalar skewness = calcSkewness
00795 (
00796 cellCentres[own[faceI]],
00797 neiCc[faceI-mesh.nInternalFaces()],
00798 faceCentres[faceI]
00799 );
00800
00801
00802
00803
00804 if (skewness > internalSkew)
00805 {
00806 if (report)
00807 {
00808 Pout<< "Severe skewness for coupled face " << faceI
00809 << " skewness = " << skewness << endl;
00810 }
00811
00812 if (setPtr)
00813 {
00814 setPtr->insert(faceI);
00815 }
00816
00817 nWarnSkew++;
00818 }
00819
00820 maxSkew = max(maxSkew, skewness);
00821 }
00822 else
00823 {
00824
00825
00826
00827 vector faceNormal = faceAreas[faceI];
00828 faceNormal /= mag(faceNormal) + VSMALL;
00829
00830 vector dOwn = faceCentres[faceI] - cellCentres[own[faceI]];
00831
00832 vector dWall = faceNormal*(faceNormal & dOwn);
00833
00834 point faceIntersection = cellCentres[own[faceI]] + dWall;
00835
00836 scalar skewness =
00837 mag(faceCentres[faceI] - faceIntersection)
00838 /(2*mag(dWall) + VSMALL);
00839
00840
00841
00842
00843 if (skewness > boundarySkew)
00844 {
00845 if (report)
00846 {
00847 Pout<< "Severe skewness for boundary face " << faceI
00848 << " skewness = " << skewness << endl;
00849 }
00850
00851 if (setPtr)
00852 {
00853 setPtr->insert(faceI);
00854 }
00855
00856 nWarnSkew++;
00857 }
00858
00859 maxSkew = max(maxSkew, skewness);
00860 }
00861 }
00862
00863 forAll(baffles, i)
00864 {
00865 label face0 = baffles[i].first();
00866 label face1 = baffles[i].second();
00867
00868 const point& ownCc = cellCentres[own[face0]];
00869
00870 scalar skewness = calcSkewness
00871 (
00872 ownCc,
00873 cellCentres[own[face1]],
00874 faceCentres[face0]
00875 );
00876
00877
00878
00879
00880 if (skewness > internalSkew)
00881 {
00882 if (report)
00883 {
00884 Pout<< "Severe skewness for face " << face0
00885 << " skewness = " << skewness << endl;
00886 }
00887
00888 if (setPtr)
00889 {
00890 setPtr->insert(face0);
00891 }
00892
00893 nWarnSkew++;
00894 }
00895
00896 maxSkew = max(maxSkew, skewness);
00897 }
00898
00899
00900 reduce(maxSkew, maxOp<scalar>());
00901 reduce(nWarnSkew, sumOp<label>());
00902
00903 if (nWarnSkew > 0)
00904 {
00905 if (report)
00906 {
00907 WarningIn
00908 (
00909 "polyMeshGeometry::checkFaceSkewness"
00910 "(const bool, const scalar, const labelList&, labelHashSet*)"
00911 ) << "Large face skewness detected. Max skewness = "
00912 << 100*maxSkew
00913 << " percent.\nThis may impair the quality of the result." << nl
00914 << nWarnSkew << " highly skew faces detected."
00915 << endl;
00916 }
00917
00918 return true;
00919 }
00920 else
00921 {
00922 if (report)
00923 {
00924 Info<< "Max skewness = " << 100*maxSkew
00925 << " percent. Face skewness OK.\n" << endl;
00926 }
00927
00928 return false;
00929 }
00930 }
00931
00932
00933 bool Foam::polyMeshGeometry::checkFaceWeights
00934 (
00935 const bool report,
00936 const scalar warnWeight,
00937 const polyMesh& mesh,
00938 const vectorField& cellCentres,
00939 const vectorField& faceCentres,
00940 const vectorField& faceAreas,
00941 const labelList& checkFaces,
00942 const List<labelPair>& baffles,
00943 labelHashSet* setPtr
00944 )
00945 {
00946
00947
00948 const labelList& own = mesh.faceOwner();
00949 const labelList& nei = mesh.faceNeighbour();
00950 const polyBoundaryMesh& patches = mesh.boundaryMesh();
00951
00952
00953 vectorField neiCc(mesh.nFaces()-mesh.nInternalFaces());
00954
00955 for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
00956 {
00957 neiCc[faceI-mesh.nInternalFaces()] = cellCentres[own[faceI]];
00958 }
00959 syncTools::swapBoundaryFaceList(mesh, neiCc, true);
00960
00961
00962 scalar minWeight = GREAT;
00963
00964 label nWarnWeight = 0;
00965
00966 forAll(checkFaces, i)
00967 {
00968 label faceI = checkFaces[i];
00969
00970 const point& fc = faceCentres[faceI];
00971 const vector& fa = faceAreas[faceI];
00972
00973 scalar dOwn = mag(fa & (fc-cellCentres[own[faceI]]));
00974
00975 if (mesh.isInternalFace(faceI))
00976 {
00977 scalar dNei = mag(fa & (cellCentres[nei[faceI]]-fc));
00978 scalar weight = min(dNei,dOwn)/(dNei+dOwn+VSMALL);
00979
00980 if (weight < warnWeight)
00981 {
00982 if (report)
00983 {
00984 Pout<< "Small weighting factor for face " << faceI
00985 << " weight = " << weight << endl;
00986 }
00987
00988 if (setPtr)
00989 {
00990 setPtr->insert(faceI);
00991 }
00992
00993 nWarnWeight++;
00994 }
00995
00996 minWeight = min(minWeight, weight);
00997 }
00998 else
00999 {
01000 label patchI = patches.whichPatch(faceI);
01001
01002 if (patches[patchI].coupled())
01003 {
01004 scalar dNei = mag(fa & (neiCc[faceI-mesh.nInternalFaces()]-fc));
01005 scalar weight = min(dNei,dOwn)/(dNei+dOwn+VSMALL);
01006
01007 if (weight < warnWeight)
01008 {
01009 if (report)
01010 {
01011 Pout<< "Small weighting factor for face " << faceI
01012 << " weight = " << weight << endl;
01013 }
01014
01015 if (setPtr)
01016 {
01017 setPtr->insert(faceI);
01018 }
01019
01020 nWarnWeight++;
01021 }
01022
01023 minWeight = min(minWeight, weight);
01024 }
01025 }
01026 }
01027
01028 forAll(baffles, i)
01029 {
01030 label face0 = baffles[i].first();
01031 label face1 = baffles[i].second();
01032
01033 const point& ownCc = cellCentres[own[face0]];
01034 const point& fc = faceCentres[face0];
01035 const vector& fa = faceAreas[face0];
01036
01037 scalar dOwn = mag(fa & (fc-ownCc));
01038 scalar dNei = mag(fa & (cellCentres[own[face1]]-fc));
01039 scalar weight = min(dNei,dOwn)/(dNei+dOwn+VSMALL);
01040
01041 if (weight < warnWeight)
01042 {
01043 if (report)
01044 {
01045 Pout<< "Small weighting factor for face " << face0
01046 << " weight = " << weight << endl;
01047 }
01048
01049 if (setPtr)
01050 {
01051 setPtr->insert(face0);
01052 }
01053
01054 nWarnWeight++;
01055 }
01056
01057 minWeight = min(minWeight, weight);
01058 }
01059
01060 reduce(minWeight, minOp<scalar>());
01061 reduce(nWarnWeight, sumOp<label>());
01062
01063 if (minWeight < warnWeight)
01064 {
01065 if (report)
01066 {
01067 WarningIn
01068 (
01069 "polyMeshGeometry::checkFaceWeights"
01070 "(const bool, const scalar, const labelList&, labelHashSet*)"
01071 ) << "Small interpolation weight detected. Min weight = "
01072 << minWeight << '.' << nl
01073 << nWarnWeight << " faces with small weights detected."
01074 << endl;
01075 }
01076
01077 return true;
01078 }
01079 else
01080 {
01081 if (report)
01082 {
01083 Info<< "Min weight = " << minWeight
01084 << ". Weights OK.\n" << endl;
01085 }
01086
01087 return false;
01088 }
01089 }
01090
01091
01092 bool Foam::polyMeshGeometry::checkVolRatio
01093 (
01094 const bool report,
01095 const scalar warnRatio,
01096 const polyMesh& mesh,
01097 const scalarField& cellVolumes,
01098 const labelList& checkFaces,
01099 const List<labelPair>& baffles,
01100 labelHashSet* setPtr
01101 )
01102 {
01103
01104
01105 const labelList& own = mesh.faceOwner();
01106 const labelList& nei = mesh.faceNeighbour();
01107 const polyBoundaryMesh& patches = mesh.boundaryMesh();
01108
01109
01110 scalarField neiVols(mesh.nFaces()-mesh.nInternalFaces());
01111
01112 for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
01113 {
01114 neiVols[faceI-mesh.nInternalFaces()] = cellVolumes[own[faceI]];
01115 }
01116 syncTools::swapBoundaryFaceList(mesh, neiVols, true);
01117
01118
01119 scalar minRatio = GREAT;
01120
01121 label nWarnRatio = 0;
01122
01123 forAll(checkFaces, i)
01124 {
01125 label faceI = checkFaces[i];
01126
01127 scalar ownVol = mag(cellVolumes[own[faceI]]);
01128
01129 scalar neiVol = -GREAT;
01130
01131 if (mesh.isInternalFace(faceI))
01132 {
01133 neiVol = mag(cellVolumes[nei[faceI]]);
01134 }
01135 else
01136 {
01137 label patchI = patches.whichPatch(faceI);
01138
01139 if (patches[patchI].coupled())
01140 {
01141 neiVol = mag(neiVols[faceI-mesh.nInternalFaces()]);
01142 }
01143 }
01144
01145 if (neiVol >= 0)
01146 {
01147 scalar ratio = min(ownVol, neiVol) / (max(ownVol, neiVol) + VSMALL);
01148
01149 if (ratio < warnRatio)
01150 {
01151 if (report)
01152 {
01153 Pout<< "Small ratio for face " << faceI
01154 << " ratio = " << ratio << endl;
01155 }
01156
01157 if (setPtr)
01158 {
01159 setPtr->insert(faceI);
01160 }
01161
01162 nWarnRatio++;
01163 }
01164
01165 minRatio = min(minRatio, ratio);
01166 }
01167 }
01168
01169 forAll(baffles, i)
01170 {
01171 label face0 = baffles[i].first();
01172 label face1 = baffles[i].second();
01173
01174 scalar ownVol = mag(cellVolumes[own[face0]]);
01175
01176 scalar neiVol = mag(cellVolumes[own[face1]]);
01177
01178 if (neiVol >= 0)
01179 {
01180 scalar ratio = min(ownVol, neiVol) / (max(ownVol, neiVol) + VSMALL);
01181
01182 if (ratio < warnRatio)
01183 {
01184 if (report)
01185 {
01186 Pout<< "Small ratio for face " << face0
01187 << " ratio = " << ratio << endl;
01188 }
01189
01190 if (setPtr)
01191 {
01192 setPtr->insert(face0);
01193 }
01194
01195 nWarnRatio++;
01196 }
01197
01198 minRatio = min(minRatio, ratio);
01199 }
01200 }
01201
01202 reduce(minRatio, minOp<scalar>());
01203 reduce(nWarnRatio, sumOp<label>());
01204
01205 if (minRatio < warnRatio)
01206 {
01207 if (report)
01208 {
01209 WarningIn
01210 (
01211 "polyMeshGeometry::checkVolRatio"
01212 "(const bool, const scalar, const labelList&, labelHashSet*)"
01213 ) << "Small volume ratio detected. Min ratio = "
01214 << minRatio << '.' << nl
01215 << nWarnRatio << " faces with small ratios detected."
01216 << endl;
01217 }
01218
01219 return true;
01220 }
01221 else
01222 {
01223 if (report)
01224 {
01225 Info<< "Min ratio = " << minRatio
01226 << ". Ratios OK.\n" << endl;
01227 }
01228
01229 return false;
01230 }
01231 }
01232
01233
01234
01235
01236
01237
01238 bool Foam::polyMeshGeometry::checkFaceAngles
01239 (
01240 const bool report,
01241 const scalar maxDeg,
01242 const polyMesh& mesh,
01243 const vectorField& faceAreas,
01244 const pointField& p,
01245 const labelList& checkFaces,
01246 labelHashSet* setPtr
01247 )
01248 {
01249 if (maxDeg < -SMALL || maxDeg > 180+SMALL)
01250 {
01251 FatalErrorIn
01252 (
01253 "polyMeshGeometry::checkFaceAngles"
01254 "(const bool, const scalar, const pointField&, const labelList&"
01255 ", labelHashSet*)"
01256 ) << "maxDeg should be [0..180] but is now " << maxDeg
01257 << abort(FatalError);
01258 }
01259
01260 const scalar maxSin = Foam::sin(maxDeg/180.0*mathematicalConstant::pi);
01261
01262 const faceList& fcs = mesh.faces();
01263
01264 scalar maxEdgeSin = 0.0;
01265
01266 label nConcave = 0;
01267
01268 label errorFaceI = -1;
01269
01270 forAll(checkFaces, i)
01271 {
01272 label faceI = checkFaces[i];
01273
01274 const face& f = fcs[faceI];
01275
01276 vector faceNormal = faceAreas[faceI];
01277 faceNormal /= mag(faceNormal) + VSMALL;
01278
01279
01280 vector ePrev(p[f[0]] - p[f[f.size()-1]]);
01281 scalar magEPrev = mag(ePrev);
01282 ePrev /= magEPrev + VSMALL;
01283
01284 forAll(f, fp0)
01285 {
01286
01287 label fp1 = f.fcIndex(fp0);
01288
01289
01290 vector e10(p[f[fp1]] - p[f[fp0]]);
01291 scalar magE10 = mag(e10);
01292 e10 /= magE10 + VSMALL;
01293
01294 if (magEPrev > SMALL && magE10 > SMALL)
01295 {
01296 vector edgeNormal = ePrev ^ e10;
01297 scalar magEdgeNormal = mag(edgeNormal);
01298
01299 if (magEdgeNormal < maxSin)
01300 {
01301
01302 }
01303 else
01304 {
01305
01306 edgeNormal /= magEdgeNormal;
01307
01308 if ((edgeNormal & faceNormal) < SMALL)
01309 {
01310 if (faceI != errorFaceI)
01311 {
01312
01313 errorFaceI = faceI;
01314 nConcave++;
01315 }
01316
01317 if (setPtr)
01318 {
01319 setPtr->insert(faceI);
01320 }
01321
01322 maxEdgeSin = max(maxEdgeSin, magEdgeNormal);
01323 }
01324 }
01325 }
01326
01327 ePrev = e10;
01328 magEPrev = magE10;
01329 }
01330 }
01331
01332 reduce(nConcave, sumOp<label>());
01333 reduce(maxEdgeSin, maxOp<scalar>());
01334
01335 if (report)
01336 {
01337 if (maxEdgeSin > SMALL)
01338 {
01339 scalar maxConcaveDegr =
01340 Foam::asin(Foam::min(1.0, maxEdgeSin))
01341 * 180.0/mathematicalConstant::pi;
01342
01343 Info<< "There are " << nConcave
01344 << " faces with concave angles between consecutive"
01345 << " edges. Max concave angle = " << maxConcaveDegr
01346 << " degrees.\n" << endl;
01347 }
01348 else
01349 {
01350 Info<< "All angles in faces are convex or less than " << maxDeg
01351 << " degrees concave.\n" << endl;
01352 }
01353 }
01354
01355 if (nConcave > 0)
01356 {
01357 if (report)
01358 {
01359 WarningIn
01360 (
01361 "polyMeshGeometry::checkFaceAngles"
01362 "(const bool, const scalar, const pointField&"
01363 ", const labelList&, labelHashSet*)"
01364 ) << nConcave << " face points with severe concave angle (> "
01365 << maxDeg << " deg) found.\n"
01366 << endl;
01367 }
01368
01369 return true;
01370 }
01371 else
01372 {
01373 return false;
01374 }
01375 }
01376
01377
01378
01379
01380 bool Foam::polyMeshGeometry::checkFaceTwist
01381 (
01382 const bool report,
01383 const scalar minTwist,
01384 const polyMesh& mesh,
01385 const vectorField& cellCentres,
01386 const vectorField& faceAreas,
01387 const vectorField& faceCentres,
01388 const pointField& p,
01389 const labelList& checkFaces,
01390 labelHashSet* setPtr
01391 )
01392 {
01393 if (minTwist < -1-SMALL || minTwist > 1+SMALL)
01394 {
01395 FatalErrorIn
01396 (
01397 "polyMeshGeometry::checkFaceTwist"
01398 "(const bool, const scalar, const polyMesh&, const pointField&"
01399 ", const pointField&, const pointField&, const pointField&"
01400 ", const labelList&, labelHashSet*)"
01401 ) << "minTwist should be [-1..1] but is now " << minTwist
01402 << abort(FatalError);
01403 }
01404
01405
01406 const faceList& fcs = mesh.faces();
01407
01408
01409 label nWarped = 0;
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455 const labelList& own = mesh.faceOwner();
01456 const labelList& nei = mesh.faceNeighbour();
01457 const polyBoundaryMesh& patches = mesh.boundaryMesh();
01458
01459
01460 vectorField neiCc(mesh.nFaces()-mesh.nInternalFaces());
01461
01462 for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
01463 {
01464 neiCc[faceI-mesh.nInternalFaces()] = cellCentres[own[faceI]];
01465 }
01466 syncTools::swapBoundaryFaceList(mesh, neiCc, true);
01467
01468 forAll(checkFaces, i)
01469 {
01470 label faceI = checkFaces[i];
01471
01472 const face& f = fcs[faceI];
01473
01474 if (f.size() > 3)
01475 {
01476 vector nf(vector::zero);
01477
01478 if (mesh.isInternalFace(faceI))
01479 {
01480 nf = cellCentres[nei[faceI]] - cellCentres[own[faceI]];
01481 nf /= mag(nf) + VSMALL;
01482 }
01483 else if (patches[patches.whichPatch(faceI)].coupled())
01484 {
01485 nf =
01486 neiCc[faceI-mesh.nInternalFaces()]
01487 - cellCentres[own[faceI]];
01488 nf /= mag(nf) + VSMALL;
01489 }
01490 else
01491 {
01492 nf = faceCentres[faceI] - cellCentres[own[faceI]];
01493 nf /= mag(nf) + VSMALL;
01494 }
01495
01496 if (nf != vector::zero)
01497 {
01498 const point& fc = faceCentres[faceI];
01499
01500 forAll(f, fpI)
01501 {
01502 vector triArea
01503 (
01504 triPointRef
01505 (
01506 p[f[fpI]],
01507 p[f.nextLabel(fpI)],
01508 fc
01509 ).normal()
01510 );
01511
01512 scalar magTri = mag(triArea);
01513
01514 if (magTri > VSMALL && ((nf & triArea/magTri) < minTwist))
01515 {
01516 nWarped++;
01517
01518 if (setPtr)
01519 {
01520 setPtr->insert(faceI);
01521 }
01522
01523 break;
01524 }
01525 }
01526 }
01527 }
01528 }
01529
01530 reduce(nWarped, sumOp<label>());
01531
01532 if (report)
01533 {
01534 if (nWarped> 0)
01535 {
01536 Info<< "There are " << nWarped
01537 << " faces with cosine of the angle"
01538 << " between triangle normal and face normal less than "
01539 << minTwist << nl << endl;
01540 }
01541 else
01542 {
01543 Info<< "All faces are flat in that the cosine of the angle"
01544 << " between triangle normal and face normal less than "
01545 << minTwist << nl << endl;
01546 }
01547 }
01548
01549 if (nWarped > 0)
01550 {
01551 if (report)
01552 {
01553 WarningIn
01554 (
01555 "polyMeshGeometry::checkFaceTwist"
01556 "(const bool, const scalar, const polyMesh&, const pointField&"
01557 ", const pointField&, const pointField&, const pointField&"
01558 ", const labelList&, labelHashSet*)"
01559 ) << nWarped << " faces with severe warpage "
01560 << "(cosine of the angle between triangle normal and face normal"
01561 << " < " << minTwist << ") found.\n"
01562 << endl;
01563 }
01564
01565 return true;
01566 }
01567 else
01568 {
01569 return false;
01570 }
01571 }
01572
01573
01574
01575 bool Foam::polyMeshGeometry::checkTriangleTwist
01576 (
01577 const bool report,
01578 const scalar minTwist,
01579 const polyMesh& mesh,
01580 const vectorField& faceAreas,
01581 const vectorField& faceCentres,
01582 const pointField& p,
01583 const labelList& checkFaces,
01584 labelHashSet* setPtr
01585 )
01586 {
01587 if (minTwist < -1-SMALL || minTwist > 1+SMALL)
01588 {
01589 FatalErrorIn
01590 (
01591 "polyMeshGeometry::checkTriangleTwist"
01592 "(const bool, const scalar, const polyMesh&, const pointField&"
01593 ", const labelList&, labelHashSet*)"
01594 ) << "minTwist should be [-1..1] but is now " << minTwist
01595 << abort(FatalError);
01596 }
01597
01598 const faceList& fcs = mesh.faces();
01599
01600 label nWarped = 0;
01601
01602 forAll(checkFaces, i)
01603 {
01604 label faceI = checkFaces[i];
01605
01606 const face& f = fcs[faceI];
01607
01608 if (f.size() > 3)
01609 {
01610 const point& fc = faceCentres[faceI];
01611
01612
01613 label startFp = -1;
01614 vector prevN;
01615
01616 forAll(f, fp)
01617 {
01618 prevN = triPointRef
01619 (
01620 p[f[fp]],
01621 p[f.nextLabel(fp)],
01622 fc
01623 ).normal();
01624
01625 scalar magTri = mag(prevN);
01626
01627 if (magTri > VSMALL)
01628 {
01629 startFp = fp;
01630 prevN /= magTri;
01631 break;
01632 }
01633 }
01634
01635 if (startFp != -1)
01636 {
01637 label fp = startFp;
01638
01639 do
01640 {
01641 fp = f.fcIndex(fp);
01642
01643 vector triN
01644 (
01645 triPointRef
01646 (
01647 p[f[fp]],
01648 p[f.nextLabel(fp)],
01649 fc
01650 ).normal()
01651 );
01652 scalar magTri = mag(triN);
01653
01654 if (magTri > VSMALL)
01655 {
01656 triN /= magTri;
01657
01658 if ((prevN & triN) < minTwist)
01659 {
01660 nWarped++;
01661
01662 if (setPtr)
01663 {
01664 setPtr->insert(faceI);
01665 }
01666
01667 break;
01668 }
01669
01670 prevN = triN;
01671 }
01672 else if (minTwist > 0)
01673 {
01674 nWarped++;
01675
01676 if (setPtr)
01677 {
01678 setPtr->insert(faceI);
01679 }
01680
01681 break;
01682 }
01683 }
01684 while (fp != startFp);
01685 }
01686 }
01687 }
01688
01689
01690 reduce(nWarped, sumOp<label>());
01691
01692 if (report)
01693 {
01694 if (nWarped> 0)
01695 {
01696 Info<< "There are " << nWarped
01697 << " faces with cosine of the angle"
01698 << " between consecutive triangle normals less than "
01699 << minTwist << nl << endl;
01700 }
01701 else
01702 {
01703 Info<< "All faces are flat in that the cosine of the angle"
01704 << " between consecutive triangle normals is less than "
01705 << minTwist << nl << endl;
01706 }
01707 }
01708
01709 if (nWarped > 0)
01710 {
01711 if (report)
01712 {
01713 WarningIn
01714 (
01715 "polyMeshGeometry::checkTriangleTwist"
01716 "(const bool, const scalar, const polyMesh&"
01717 ", const pointField&, const labelList&, labelHashSet*)"
01718 ) << nWarped << " faces with severe warpage "
01719 << "(cosine of the angle between consecutive triangle normals"
01720 << " < " << minTwist << ") found.\n"
01721 << endl;
01722 }
01723
01724 return true;
01725 }
01726 else
01727 {
01728 return false;
01729 }
01730 }
01731
01732
01733 bool Foam::polyMeshGeometry::checkFaceArea
01734 (
01735 const bool report,
01736 const scalar minArea,
01737 const polyMesh& mesh,
01738 const vectorField& faceAreas,
01739 const labelList& checkFaces,
01740 labelHashSet* setPtr
01741 )
01742 {
01743 label nZeroArea = 0;
01744
01745 forAll(checkFaces, i)
01746 {
01747 label faceI = checkFaces[i];
01748
01749 if (mag(faceAreas[faceI]) < minArea)
01750 {
01751 if (setPtr)
01752 {
01753 setPtr->insert(faceI);
01754 }
01755 nZeroArea++;
01756 }
01757 }
01758
01759
01760 reduce(nZeroArea, sumOp<label>());
01761
01762 if (report)
01763 {
01764 if (nZeroArea > 0)
01765 {
01766 Info<< "There are " << nZeroArea
01767 << " faces with area < " << minArea << '.' << nl << endl;
01768 }
01769 else
01770 {
01771 Info<< "All faces have area > " << minArea << '.' << nl << endl;
01772 }
01773 }
01774
01775 if (nZeroArea > 0)
01776 {
01777 if (report)
01778 {
01779 WarningIn
01780 (
01781 "polyMeshGeometry::checkFaceArea"
01782 "(const bool, const scalar, const polyMesh&"
01783 ", const pointField&, const labelList&, labelHashSet*)"
01784 ) << nZeroArea << " faces with area < " << minArea
01785 << " found.\n"
01786 << endl;
01787 }
01788
01789 return true;
01790 }
01791 else
01792 {
01793 return false;
01794 }
01795 }
01796
01797
01798 bool Foam::polyMeshGeometry::checkCellDeterminant
01799 (
01800 const bool report,
01801 const scalar warnDet,
01802 const polyMesh& mesh,
01803 const vectorField& faceAreas,
01804 const labelList& checkFaces,
01805 const labelList& affectedCells,
01806 labelHashSet* setPtr
01807 )
01808 {
01809 const cellList& cells = mesh.cells();
01810
01811 scalar minDet = GREAT;
01812 scalar sumDet = 0.0;
01813 label nSumDet = 0;
01814 label nWarnDet = 0;
01815
01816 forAll(affectedCells, i)
01817 {
01818 const cell& cFaces = cells[affectedCells[i]];
01819
01820 tensor areaSum(tensor::zero);
01821 scalar magAreaSum = 0;
01822
01823 forAll(cFaces, cFaceI)
01824 {
01825 label faceI = cFaces[cFaceI];
01826
01827 scalar magArea = mag(faceAreas[faceI]);
01828
01829 magAreaSum += magArea;
01830 areaSum += faceAreas[faceI]*(faceAreas[faceI]/(magArea+VSMALL));
01831 }
01832
01833 scalar scaledDet = det(areaSum/(magAreaSum+VSMALL))/0.037037037037037;
01834
01835 minDet = min(minDet, scaledDet);
01836 sumDet += scaledDet;
01837 nSumDet++;
01838
01839 if (scaledDet < warnDet)
01840 {
01841 if (setPtr)
01842 {
01843
01844 forAll(cFaces, cFaceI)
01845 {
01846 label faceI = cFaces[cFaceI];
01847 setPtr->insert(faceI);
01848 }
01849 }
01850 nWarnDet++;
01851 }
01852 }
01853
01854 reduce(minDet, minOp<scalar>());
01855 reduce(sumDet, sumOp<scalar>());
01856 reduce(nSumDet, sumOp<label>());
01857 reduce(nWarnDet, sumOp<label>());
01858
01859 if (report)
01860 {
01861 if (nSumDet > 0)
01862 {
01863 Info<< "Cell determinant (1 = uniform cube) : average = "
01864 << sumDet / nSumDet << " min = " << minDet << endl;
01865 }
01866
01867 if (nWarnDet > 0)
01868 {
01869 Info<< "There are " << nWarnDet
01870 << " cells with determinant < " << warnDet << '.' << nl
01871 << endl;
01872 }
01873 else
01874 {
01875 Info<< "All faces have determinant > " << warnDet << '.' << nl
01876 << endl;
01877 }
01878 }
01879
01880 if (nWarnDet > 0)
01881 {
01882 if (report)
01883 {
01884 WarningIn
01885 (
01886 "polyMeshGeometry::checkCellDeterminant"
01887 "(const bool, const scalar, const polyMesh&"
01888 ", const pointField&, const labelList&, const labelList&"
01889 ", labelHashSet*)"
01890 ) << nWarnDet << " cells with determinant < " << warnDet
01891 << " found.\n"
01892 << endl;
01893 }
01894
01895 return true;
01896 }
01897 else
01898 {
01899 return false;
01900 }
01901 }
01902
01903
01904 bool Foam::polyMeshGeometry::checkFaceDotProduct
01905 (
01906 const bool report,
01907 const scalar orthWarn,
01908 const labelList& checkFaces,
01909 const List<labelPair>& baffles,
01910 labelHashSet* setPtr
01911 ) const
01912 {
01913 return checkFaceDotProduct
01914 (
01915 report,
01916 orthWarn,
01917 mesh_,
01918 cellCentres_,
01919 faceAreas_,
01920 checkFaces,
01921 baffles,
01922 setPtr
01923 );
01924 }
01925
01926
01927 bool Foam::polyMeshGeometry::checkFacePyramids
01928 (
01929 const bool report,
01930 const scalar minPyrVol,
01931 const pointField& p,
01932 const labelList& checkFaces,
01933 const List<labelPair>& baffles,
01934 labelHashSet* setPtr
01935 ) const
01936 {
01937 return checkFacePyramids
01938 (
01939 report,
01940 minPyrVol,
01941 mesh_,
01942 cellCentres_,
01943 p,
01944 checkFaces,
01945 baffles,
01946 setPtr
01947 );
01948 }
01949
01950
01951 bool Foam::polyMeshGeometry::checkFaceSkewness
01952 (
01953 const bool report,
01954 const scalar internalSkew,
01955 const scalar boundarySkew,
01956 const labelList& checkFaces,
01957 const List<labelPair>& baffles,
01958 labelHashSet* setPtr
01959 ) const
01960 {
01961 return checkFaceSkewness
01962 (
01963 report,
01964 internalSkew,
01965 boundarySkew,
01966 mesh_,
01967 cellCentres_,
01968 faceCentres_,
01969 faceAreas_,
01970 checkFaces,
01971 baffles,
01972 setPtr
01973 );
01974 }
01975
01976
01977 bool Foam::polyMeshGeometry::checkFaceWeights
01978 (
01979 const bool report,
01980 const scalar warnWeight,
01981 const labelList& checkFaces,
01982 const List<labelPair>& baffles,
01983 labelHashSet* setPtr
01984 ) const
01985 {
01986 return checkFaceWeights
01987 (
01988 report,
01989 warnWeight,
01990 mesh_,
01991 cellCentres_,
01992 faceCentres_,
01993 faceAreas_,
01994 checkFaces,
01995 baffles,
01996 setPtr
01997 );
01998 }
01999
02000
02001 bool Foam::polyMeshGeometry::checkVolRatio
02002 (
02003 const bool report,
02004 const scalar warnRatio,
02005 const labelList& checkFaces,
02006 const List<labelPair>& baffles,
02007 labelHashSet* setPtr
02008 ) const
02009 {
02010 return checkVolRatio
02011 (
02012 report,
02013 warnRatio,
02014 mesh_,
02015 cellVolumes_,
02016 checkFaces,
02017 baffles,
02018 setPtr
02019 );
02020 }
02021
02022
02023 bool Foam::polyMeshGeometry::checkFaceAngles
02024 (
02025 const bool report,
02026 const scalar maxDeg,
02027 const pointField& p,
02028 const labelList& checkFaces,
02029 labelHashSet* setPtr
02030 ) const
02031 {
02032 return checkFaceAngles
02033 (
02034 report,
02035 maxDeg,
02036 mesh_,
02037 faceAreas_,
02038 p,
02039 checkFaces,
02040 setPtr
02041 );
02042 }
02043
02044
02045 bool Foam::polyMeshGeometry::checkFaceTwist
02046 (
02047 const bool report,
02048 const scalar minTwist,
02049 const pointField& p,
02050 const labelList& checkFaces,
02051 labelHashSet* setPtr
02052 ) const
02053 {
02054 return checkFaceTwist
02055 (
02056 report,
02057 minTwist,
02058 mesh_,
02059 cellCentres_,
02060 faceAreas_,
02061 faceCentres_,
02062 p,
02063 checkFaces,
02064 setPtr
02065 );
02066 }
02067
02068
02069 bool Foam::polyMeshGeometry::checkTriangleTwist
02070 (
02071 const bool report,
02072 const scalar minTwist,
02073 const pointField& p,
02074 const labelList& checkFaces,
02075 labelHashSet* setPtr
02076 ) const
02077 {
02078 return checkTriangleTwist
02079 (
02080 report,
02081 minTwist,
02082 mesh_,
02083 faceAreas_,
02084 faceCentres_,
02085 p,
02086 checkFaces,
02087 setPtr
02088 );
02089 }
02090
02091
02092 bool Foam::polyMeshGeometry::checkFaceArea
02093 (
02094 const bool report,
02095 const scalar minArea,
02096 const labelList& checkFaces,
02097 labelHashSet* setPtr
02098 ) const
02099 {
02100 return checkFaceArea
02101 (
02102 report,
02103 minArea,
02104 mesh_,
02105 faceAreas_,
02106 checkFaces,
02107 setPtr
02108 );
02109 }
02110
02111
02112 bool Foam::polyMeshGeometry::checkCellDeterminant
02113 (
02114 const bool report,
02115 const scalar warnDet,
02116 const labelList& checkFaces,
02117 const labelList& affectedCells,
02118 labelHashSet* setPtr
02119 ) const
02120 {
02121 return checkCellDeterminant
02122 (
02123 report,
02124 warnDet,
02125 mesh_,
02126 faceAreas_,
02127 checkFaces,
02128 affectedCells,
02129 setPtr
02130 );
02131 }
02132
02133
02134