1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "primitiveMeshGeometry.H"
27 #include "pyramidPointFaceRef.H"
28 #include "unitConversion.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(primitiveMeshGeometry, 0);
38 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 void Foam::primitiveMeshGeometry::updateFaceCentresAndAreas
43 const labelList& changedFaces
46 const faceList& fs = mesh_.faces();
48 forAll(changedFaces, i)
50 label facei = changedFaces[i];
52 const labelList& f = fs[facei];
53 label nPoints = f.size();
55 // If the face is a triangle, do a direct calculation for efficiency
56 // and to avoid round-off error-related problems
59 faceCentres_[facei] = (1.0/3.0)*(p[f[0]] + p[f[1]] + p[f[2]]);
60 faceAreas_[facei] = 0.5*((p[f[1]] - p[f[0]])^(p[f[2]] - p[f[0]]));
64 vector sumN = vector::zero;
66 vector sumAc = vector::zero;
68 point fCentre = p[f[0]];
69 for (label pi = 1; pi < nPoints; pi++)
76 for (label pi = 0; pi < nPoints; pi++)
78 const point& nextPoint = p[f[(pi + 1) % nPoints]];
80 vector c = p[f[pi]] + nextPoint + fCentre;
81 vector n = (nextPoint - p[f[pi]])^(fCentre - p[f[pi]]);
89 faceCentres_[facei] = (1.0/3.0)*sumAc/(sumA + VSMALL);
90 faceAreas_[facei] = 0.5*sumN;
96 void Foam::primitiveMeshGeometry::updateCellCentresAndVols
98 const labelList& changedCells,
99 const labelList& changedFaces
102 // Clear the fields for accumulation
103 UIndirectList<vector>(cellCentres_, changedCells) = vector::zero;
104 UIndirectList<scalar>(cellVolumes_, changedCells) = 0.0;
106 const labelList& own = mesh_.faceOwner();
107 const labelList& nei = mesh_.faceNeighbour();
109 // first estimate the approximate cell centre as the average of face centres
111 vectorField cEst(mesh_.nCells());
112 UIndirectList<vector>(cEst, changedCells) = vector::zero;
113 scalarField nCellFaces(mesh_.nCells());
114 UIndirectList<scalar>(nCellFaces, changedCells) = 0.0;
116 forAll(changedFaces, i)
118 label faceI = changedFaces[i];
119 cEst[own[faceI]] += faceCentres_[faceI];
120 nCellFaces[own[faceI]] += 1;
122 if (mesh_.isInternalFace(faceI))
124 cEst[nei[faceI]] += faceCentres_[faceI];
125 nCellFaces[nei[faceI]] += 1;
129 forAll(changedCells, i)
131 label cellI = changedCells[i];
132 cEst[cellI] /= nCellFaces[cellI];
135 forAll(changedFaces, i)
137 label faceI = changedFaces[i];
139 // Calculate 3*face-pyramid volume
142 faceAreas_[faceI] & (faceCentres_[faceI] - cEst[own[faceI]]),
146 // Calculate face-pyramid centre
147 vector pc = (3.0/4.0)*faceCentres_[faceI] + (1.0/4.0)*cEst[own[faceI]];
149 // Accumulate volume-weighted face-pyramid centre
150 cellCentres_[own[faceI]] += pyr3Vol*pc;
152 // Accumulate face-pyramid volume
153 cellVolumes_[own[faceI]] += pyr3Vol;
155 if (mesh_.isInternalFace(faceI))
157 // Calculate 3*face-pyramid volume
160 faceAreas_[faceI] & (cEst[nei[faceI]] - faceCentres_[faceI]),
164 // Calculate face-pyramid centre
166 (3.0/4.0)*faceCentres_[faceI]
167 + (1.0/4.0)*cEst[nei[faceI]];
169 // Accumulate volume-weighted face-pyramid centre
170 cellCentres_[nei[faceI]] += pyr3Vol*pc;
172 // Accumulate face-pyramid volume
173 cellVolumes_[nei[faceI]] += pyr3Vol;
177 forAll(changedCells, i)
179 label cellI = changedCells[i];
181 cellCentres_[cellI] /= cellVolumes_[cellI];
182 cellVolumes_[cellI] *= (1.0/3.0);
187 Foam::labelList Foam::primitiveMeshGeometry::affectedCells
189 const labelList& changedFaces
192 const labelList& own = mesh_.faceOwner();
193 const labelList& nei = mesh_.faceNeighbour();
195 labelHashSet affectedCells(2*changedFaces.size());
197 forAll(changedFaces, i)
199 label faceI = changedFaces[i];
201 affectedCells.insert(own[faceI]);
203 if (mesh_.isInternalFace(faceI))
205 affectedCells.insert(nei[faceI]);
208 return affectedCells.toc();
213 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
215 // Construct from components
216 Foam::primitiveMeshGeometry::primitiveMeshGeometry
218 const primitiveMesh& mesh
227 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
230 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
232 //- Take over properties from mesh
233 void Foam::primitiveMeshGeometry::correct()
235 faceAreas_ = mesh_.faceAreas();
236 faceCentres_ = mesh_.faceCentres();
237 cellCentres_ = mesh_.cellCentres();
238 cellVolumes_ = mesh_.cellVolumes();
242 //- Recalculate on selected faces
243 void Foam::primitiveMeshGeometry::correct
246 const labelList& changedFaces
249 // Update face quantities
250 updateFaceCentresAndAreas(p, changedFaces);
251 // Update cell quantities from face quantities
252 updateCellCentresAndVols(affectedCells(changedFaces), changedFaces);
256 bool Foam::primitiveMeshGeometry::checkFaceDotProduct
259 const scalar orthWarn,
260 const primitiveMesh& mesh,
261 const vectorField& cellCentres,
262 const vectorField& faceAreas,
263 const labelList& checkFaces,
267 // for all internal faces check theat the d dot S product is positive
269 const labelList& own = mesh.faceOwner();
270 const labelList& nei = mesh.faceNeighbour();
272 // Severe nonorthogonality threshold
273 const scalar severeNonorthogonalityThreshold = ::cos(degToRad(orthWarn));
275 scalar minDDotS = GREAT;
279 label severeNonOrth = 0;
281 label errorNonOrth = 0;
283 forAll(checkFaces, i)
285 label faceI = checkFaces[i];
287 if (mesh.isInternalFace(faceI))
289 vector d = cellCentres[nei[faceI]] - cellCentres[own[faceI]];
290 const vector& s = faceAreas[faceI];
292 scalar dDotS = (d & s)/(mag(d)*mag(s) + VSMALL);
294 if (dDotS < severeNonorthogonalityThreshold)
300 // Severe non-orthogonality but mesh still OK
301 Pout<< "Severe non-orthogonality for face " << faceI
302 << " between cells " << own[faceI]
303 << " and " << nei[faceI]
304 << ": Angle = " << radToDeg(::acos(dDotS))
310 setPtr->insert(faceI);
317 // Non-orthogonality greater than 90 deg
322 "primitiveMeshGeometry::checkFaceDotProduct"
323 "(const bool, const scalar, const labelList&"
325 ) << "Severe non-orthogonality detected for face "
327 << " between cells " << own[faceI] << " and "
329 << ": Angle = " << radToDeg(::acos(dDotS))
337 setPtr->insert(faceI);
342 if (dDotS < minDDotS)
351 reduce(minDDotS, minOp<scalar>());
352 reduce(sumDDotS, sumOp<scalar>());
353 reduce(severeNonOrth, sumOp<label>());
354 reduce(errorNonOrth, sumOp<label>());
356 label neiSize = nei.size();
357 reduce(neiSize, sumOp<label>());
359 // Only report if there are some internal faces
362 if (report && minDDotS < severeNonorthogonalityThreshold)
364 Info<< "Number of non-orthogonality errors: " << errorNonOrth
365 << ". Number of severely non-orthogonal faces: "
366 << severeNonOrth << "." << endl;
374 Info<< "Mesh non-orthogonality Max: "
375 << radToDeg(::acos(minDDotS))
376 << " average: " << radToDeg(::acos(sumDDotS/neiSize))
381 if (errorNonOrth > 0)
387 "primitiveMeshGeometry::checkFaceDotProduct"
388 "(const bool, const scalar, const labelList&, labelHashSet*)"
389 ) << "Error in non-orthogonality detected" << endl;
398 Info<< "Non-orthogonality check OK.\n" << endl;
406 bool Foam::primitiveMeshGeometry::checkFacePyramids
409 const scalar minPyrVol,
410 const primitiveMesh& mesh,
411 const vectorField& cellCentres,
413 const labelList& checkFaces,
417 // check whether face area vector points to the cell with higher label
418 const labelList& own = mesh.faceOwner();
419 const labelList& nei = mesh.faceNeighbour();
421 const faceList& f = mesh.faces();
423 label nErrorPyrs = 0;
425 forAll(checkFaces, i)
427 label faceI = checkFaces[i];
429 // Create the owner pyramid - it will have negative volume
430 scalar pyrVol = pyramidPointFaceRef
433 cellCentres[own[faceI]]
436 if (pyrVol > -minPyrVol)
440 Pout<< "bool primitiveMeshGeometry::checkFacePyramids("
441 << "const bool, const scalar, const pointField&"
442 << ", const labelList&, labelHashSet*): "
443 << "face " << faceI << " points the wrong way. " << endl
444 << "Pyramid volume: " << -pyrVol
445 << " Face " << f[faceI] << " area: " << f[faceI].mag(p)
446 << " Owner cell: " << own[faceI] << endl
447 << "Owner cell vertex labels: "
448 << mesh.cells()[own[faceI]].labels(f)
455 setPtr->insert(faceI);
461 if (mesh.isInternalFace(faceI))
463 // Create the neighbour pyramid - it will have positive volume
465 pyramidPointFaceRef(f[faceI], cellCentres[nei[faceI]]).mag(p);
467 if (pyrVol < minPyrVol)
471 Pout<< "bool primitiveMeshGeometry::checkFacePyramids("
472 << "const bool, const scalar, const pointField&"
473 << ", const labelList&, labelHashSet*): "
474 << "face " << faceI << " points the wrong way. " << endl
475 << "Pyramid volume: " << -pyrVol
476 << " Face " << f[faceI] << " area: " << f[faceI].mag(p)
477 << " Neighbour cell: " << nei[faceI] << endl
478 << "Neighbour cell vertex labels: "
479 << mesh.cells()[nei[faceI]].labels(f)
485 setPtr->insert(faceI);
493 reduce(nErrorPyrs, sumOp<label>());
501 "primitiveMeshGeometry::checkFacePyramids("
502 "const bool, const scalar, const pointField&"
503 ", const labelList&, labelHashSet*)"
504 ) << "Error in face pyramids: faces pointing the wrong way!"
514 Info<< "Face pyramids OK.\n" << endl;
522 bool Foam::primitiveMeshGeometry::checkFaceSkewness
525 const scalar internalSkew,
526 const scalar boundarySkew,
527 const primitiveMesh& mesh,
528 const vectorField& cellCentres,
529 const vectorField& faceCentres,
530 const vectorField& faceAreas,
531 const labelList& checkFaces,
535 // Warn if the skew correction vector is more than skew times
536 // larger than the face area vector
538 const labelList& own = mesh.faceOwner();
539 const labelList& nei = mesh.faceNeighbour();
545 forAll(checkFaces, i)
547 label faceI = checkFaces[i];
549 if (mesh.isInternalFace(faceI))
551 scalar dOwn = mag(faceCentres[faceI] - cellCentres[own[faceI]]);
552 scalar dNei = mag(faceCentres[faceI] - cellCentres[nei[faceI]]);
554 point faceIntersection =
555 cellCentres[own[faceI]]*dNei/(dOwn+dNei)
556 + cellCentres[nei[faceI]]*dOwn/(dOwn+dNei);
559 mag(faceCentres[faceI] - faceIntersection)
561 mag(cellCentres[nei[faceI]]-cellCentres[own[faceI]])
565 // Check if the skewness vector is greater than the PN vector.
566 // This does not cause trouble but is a good indication of a poor
568 if (skewness > internalSkew)
572 Pout<< "Severe skewness for face " << faceI
573 << " skewness = " << skewness << endl;
578 setPtr->insert(faceI);
584 if (skewness > maxSkew)
591 // Boundary faces: consider them to have only skewness error.
592 // (i.e. treat as if mirror cell on other side)
594 vector faceNormal = faceAreas[faceI];
595 faceNormal /= mag(faceNormal) + VSMALL;
597 vector dOwn = faceCentres[faceI] - cellCentres[own[faceI]];
599 vector dWall = faceNormal*(faceNormal & dOwn);
601 point faceIntersection = cellCentres[own[faceI]] + dWall;
604 mag(faceCentres[faceI] - faceIntersection)
605 /(2*mag(dWall) + VSMALL);
607 // Check if the skewness vector is greater than the PN vector.
608 // This does not cause trouble but is a good indication of a poor
610 if (skewness > boundarySkew)
614 Pout<< "Severe skewness for boundary face " << faceI
615 << " skewness = " << skewness << endl;
620 setPtr->insert(faceI);
626 if (skewness > maxSkew)
633 reduce(maxSkew, maxOp<scalar>());
634 reduce(nWarnSkew, sumOp<label>());
642 "primitiveMeshGeometry::checkFaceSkewness"
643 "(const bool, const scalar, const labelList&, labelHashSet*)"
644 ) << "Large face skewness detected. Max skewness = "
646 << " percent.\nThis may impair the quality of the result." << nl
647 << nWarnSkew << " highly skew faces detected."
657 Info<< "Max skewness = " << 100*maxSkew
658 << " percent. Face skewness OK.\n" << endl;
666 bool Foam::primitiveMeshGeometry::checkFaceWeights
669 const scalar warnWeight,
670 const primitiveMesh& mesh,
671 const vectorField& cellCentres,
672 const vectorField& faceCentres,
673 const vectorField& faceAreas,
674 const labelList& checkFaces,
678 // Warn if the delta factor (0..1) is too large.
680 const labelList& own = mesh.faceOwner();
681 const labelList& nei = mesh.faceNeighbour();
683 scalar minWeight = GREAT;
685 label nWarnWeight = 0;
687 forAll(checkFaces, i)
689 label faceI = checkFaces[i];
691 if (mesh.isInternalFace(faceI))
693 const point& fc = faceCentres[faceI];
695 scalar dOwn = mag(faceAreas[faceI] & (fc-cellCentres[own[faceI]]));
696 scalar dNei = mag(faceAreas[faceI] & (cellCentres[nei[faceI]]-fc));
698 scalar weight = min(dNei,dOwn)/(dNei+dOwn);
700 if (weight < warnWeight)
704 Pout<< "Small weighting factor for face " << faceI
705 << " weight = " << weight << endl;
710 setPtr->insert(faceI);
716 minWeight = min(minWeight, weight);
720 reduce(minWeight, minOp<scalar>());
721 reduce(nWarnWeight, sumOp<label>());
723 if (minWeight < warnWeight)
729 "primitiveMeshGeometry::checkFaceWeights"
730 "(const bool, const scalar, const labelList&, labelHashSet*)"
731 ) << "Small interpolation weight detected. Min weight = "
732 << minWeight << '.' << nl
733 << nWarnWeight << " faces with small weights detected."
743 Info<< "Min weight = " << minWeight
744 << " percent. Weights OK.\n" << endl;
752 // Check convexity of angles in a face. Allow a slight non-convexity.
753 // E.g. maxDeg = 10 allows for angles < 190 (or 10 degrees concavity)
754 // (if truly concave and points not visible from face centre the face-pyramid
755 // check in checkMesh will fail)
756 bool Foam::primitiveMeshGeometry::checkFaceAngles
760 const primitiveMesh& mesh,
761 const vectorField& faceAreas,
763 const labelList& checkFaces,
767 if (maxDeg < -SMALL || maxDeg > 180+SMALL)
771 "primitiveMeshGeometry::checkFaceAngles"
772 "(const bool, const scalar, const pointField&, const labelList&"
774 ) << "maxDeg should be [0..180] but is now " << maxDeg
775 << abort(FatalError);
778 const scalar maxSin = Foam::sin(degToRad(maxDeg));
780 const faceList& fcs = mesh.faces();
782 scalar maxEdgeSin = 0.0;
786 label errorFaceI = -1;
788 forAll(checkFaces, i)
790 label faceI = checkFaces[i];
792 const face& f = fcs[faceI];
794 vector faceNormal = faceAreas[faceI];
795 faceNormal /= mag(faceNormal) + VSMALL;
797 // Get edge from f[0] to f[size-1];
798 vector ePrev(p[f.first()] - p[f.last()]);
799 scalar magEPrev = mag(ePrev);
800 ePrev /= magEPrev + VSMALL;
804 // Get vertex after fp
805 label fp1 = f.fcIndex(fp0);
807 // Normalized vector between two consecutive points
808 vector e10(p[f[fp1]] - p[f[fp0]]);
809 scalar magE10 = mag(e10);
810 e10 /= magE10 + VSMALL;
812 if (magEPrev > SMALL && magE10 > SMALL)
814 vector edgeNormal = ePrev ^ e10;
815 scalar magEdgeNormal = mag(edgeNormal);
817 if (magEdgeNormal < maxSin)
819 // Edges (almost) aligned -> face is ok.
824 edgeNormal /= magEdgeNormal;
826 if ((edgeNormal & faceNormal) < SMALL)
828 if (faceI != errorFaceI)
830 // Count only one error per face.
837 setPtr->insert(faceI);
840 maxEdgeSin = max(maxEdgeSin, magEdgeNormal);
850 reduce(nConcave, sumOp<label>());
851 reduce(maxEdgeSin, maxOp<scalar>());
855 if (maxEdgeSin > SMALL)
857 scalar maxConcaveDegr =
858 radToDeg(Foam::asin(Foam::min(1.0, maxEdgeSin)));
860 Info<< "There are " << nConcave
861 << " faces with concave angles between consecutive"
862 << " edges. Max concave angle = " << maxConcaveDegr
863 << " degrees.\n" << endl;
867 Info<< "All angles in faces are convex or less than " << maxDeg
868 << " degrees concave.\n" << endl;
878 "primitiveMeshGeometry::checkFaceAngles"
879 "(const bool, const scalar, const pointField&"
880 ", const labelList&, labelHashSet*)"
881 ) << nConcave << " face points with severe concave angle (> "
882 << maxDeg << " deg) found.\n"
895 //// Check warpage of faces. Is calculated as the difference between areas of
896 //// individual triangles and the overall area of the face (which ifself is
897 //// is the average of the areas of the individual triangles).
898 //bool Foam::primitiveMeshGeometry::checkFaceFlatness
900 // const bool report,
901 // const scalar warnFlatness,
902 // const primitiveMesh& mesh,
903 // const vectorField& faceAreas,
904 // const vectorField& faceCentres,
905 // const pointField& p,
906 // const labelList& checkFaces,
907 // labelHashSet* setPtr
910 // if (warnFlatness < 0 || warnFlatness > 1)
914 // "primitiveMeshGeometry::checkFaceFlatness"
915 // "(const bool, const scalar, const pointField&"
916 // ", const labelList&, labelHashSet*)"
917 // ) << "warnFlatness should be [0..1] but is now " << warnFlatness
918 // << abort(FatalError);
922 // const faceList& fcs = mesh.faces();
924 // // Areas are calculated as the sum of areas. (see
925 // // primitiveMeshFaceCentresAndAreas.C)
927 // label nWarped = 0;
929 // scalar minFlatness = GREAT;
930 // scalar sumFlatness = 0;
931 // label nSummed = 0;
933 // forAll(checkFaces, i)
935 // label faceI = checkFaces[i];
937 // const face& f = fcs[faceI];
939 // scalar magArea = mag(faceAreas[faceI]);
941 // if (f.size() > 3 && magArea > VSMALL)
943 // const point& fc = faceCentres[faceI];
945 // // Calculate the sum of magnitude of areas and compare to
946 // // magnitude of sum of areas.
948 // scalar sumA = 0.0;
952 // const point& thisPoint = p[f[fp]];
953 // const point& nextPoint = p[f.nextLabel(fp)];
955 // // Triangle around fc.
956 // vector n = 0.5*((nextPoint - thisPoint)^(fc - thisPoint));
960 // scalar flatness = magArea / (sumA+VSMALL);
962 // sumFlatness += flatness;
965 // minFlatness = min(minFlatness, flatness);
967 // if (flatness < warnFlatness)
973 // setPtr->insert(faceI);
980 // reduce(nWarped, sumOp<label>());
981 // reduce(minFlatness, minOp<scalar>());
983 // reduce(nSummed, sumOp<label>());
984 // reduce(sumFlatness, sumOp<scalar>());
990 // Info<< "Face flatness (1 = flat, 0 = butterfly) : average = "
991 // << sumFlatness / nSummed << " min = " << minFlatness << endl;
996 // Info<< "There are " << nWarped
997 // << " faces with ratio between projected and actual area < "
999 // << ".\nMinimum ratio (minimum flatness, maximum warpage) = "
1000 // << minFlatness << nl << endl;
1004 // Info<< "All faces are flat in that the ratio between projected"
1005 // << " and actual area is > " << warnFlatness << nl << endl;
1015 // "primitiveMeshGeometry::checkFaceFlatness"
1016 // "(const bool, const scalar, const pointField&"
1017 // ", const labelList&, labelHashSet*)"
1018 // ) << nWarped << " faces with severe warpage (flatness < "
1019 // << warnFlatness << ") found.\n"
1032 // Check twist of faces. Is calculated as the difference between areas of
1033 // individual triangles and the overall area of the face (which ifself is
1034 // is the average of the areas of the individual triangles).
1035 bool Foam::primitiveMeshGeometry::checkFaceTwist
1038 const scalar minTwist,
1039 const primitiveMesh& mesh,
1040 const vectorField& faceAreas,
1041 const vectorField& faceCentres,
1042 const pointField& p,
1043 const labelList& checkFaces,
1044 labelHashSet* setPtr
1047 if (minTwist < -1-SMALL || minTwist > 1+SMALL)
1051 "primitiveMeshGeometry::checkFaceTwist"
1052 "(const bool, const scalar, const primitiveMesh&, const pointField&"
1053 ", const labelList&, labelHashSet*)"
1054 ) << "minTwist should be [-1..1] but is now " << minTwist
1055 << abort(FatalError);
1059 const faceList& fcs = mesh.faces();
1061 // Areas are calculated as the sum of areas. (see
1062 // primitiveMeshFaceCentresAndAreas.C)
1066 forAll(checkFaces, i)
1068 label faceI = checkFaces[i];
1070 const face& f = fcs[faceI];
1072 scalar magArea = mag(faceAreas[faceI]);
1074 if (f.size() > 3 && magArea > VSMALL)
1076 const vector nf = faceAreas[faceI] / magArea;
1078 const point& fc = faceCentres[faceI];
1087 p[f.nextLabel(fpI)],
1092 scalar magTri = mag(triArea);
1094 if (magTri > VSMALL && ((nf & triArea/magTri) < minTwist))
1100 setPtr->insert(faceI);
1108 reduce(nWarped, sumOp<label>());
1114 Info<< "There are " << nWarped
1115 << " faces with cosine of the angle"
1116 << " between triangle normal and face normal less than "
1117 << minTwist << nl << endl;
1121 Info<< "All faces are flat in that the cosine of the angle"
1122 << " between triangle normal and face normal less than "
1123 << minTwist << nl << endl;
1133 "primitiveMeshGeometry::checkFaceTwist"
1134 "(const bool, const scalar, const primitiveMesh&"
1135 ", const pointField&, const labelList&, labelHashSet*)"
1136 ) << nWarped << " faces with severe warpage "
1137 << "(cosine of the angle between triangle normal and "
1138 << "face normal < " << minTwist << ") found.\n"
1151 bool Foam::primitiveMeshGeometry::checkFaceArea
1154 const scalar minArea,
1155 const primitiveMesh& mesh,
1156 const vectorField& faceAreas,
1157 const labelList& checkFaces,
1158 labelHashSet* setPtr
1161 label nZeroArea = 0;
1163 forAll(checkFaces, i)
1165 label faceI = checkFaces[i];
1167 if (mag(faceAreas[faceI]) < minArea)
1171 setPtr->insert(faceI);
1178 reduce(nZeroArea, sumOp<label>());
1184 Info<< "There are " << nZeroArea
1185 << " faces with area < " << minArea << '.' << nl << endl;
1189 Info<< "All faces have area > " << minArea << '.' << nl << endl;
1199 "primitiveMeshGeometry::checkFaceArea"
1200 "(const bool, const scalar, const primitiveMesh&"
1201 ", const pointField&, const labelList&, labelHashSet*)"
1202 ) << nZeroArea << " faces with area < " << minArea
1216 bool Foam::primitiveMeshGeometry::checkCellDeterminant
1219 const scalar warnDet,
1220 const primitiveMesh& mesh,
1221 const vectorField& faceAreas,
1222 const labelList& checkFaces,
1223 const labelList& affectedCells,
1224 labelHashSet* setPtr
1227 const cellList& cells = mesh.cells();
1229 scalar minDet = GREAT;
1230 scalar sumDet = 0.0;
1234 forAll(affectedCells, i)
1236 const cell& cFaces = cells[affectedCells[i]];
1238 tensor areaSum(tensor::zero);
1239 scalar magAreaSum = 0;
1241 forAll(cFaces, cFaceI)
1243 label faceI = cFaces[cFaceI];
1245 scalar magArea = mag(faceAreas[faceI]);
1247 magAreaSum += magArea;
1248 areaSum += faceAreas[faceI]*(faceAreas[faceI]/magArea);
1251 scalar scaledDet = det(areaSum/magAreaSum)/0.037037037037037;
1253 minDet = min(minDet, scaledDet);
1254 sumDet += scaledDet;
1257 if (scaledDet < warnDet)
1261 // Insert all faces of the cell.
1262 forAll(cFaces, cFaceI)
1264 label faceI = cFaces[cFaceI];
1265 setPtr->insert(faceI);
1272 reduce(minDet, minOp<scalar>());
1273 reduce(sumDet, sumOp<scalar>());
1274 reduce(nSumDet, sumOp<label>());
1275 reduce(nWarnDet, sumOp<label>());
1281 Info<< "Cell determinant (1 = uniform cube) : average = "
1282 << sumDet / nSumDet << " min = " << minDet << endl;
1287 Info<< "There are " << nWarnDet
1288 << " cells with determinant < " << warnDet << '.' << nl
1293 Info<< "All faces have determinant > " << warnDet << '.' << nl
1304 "primitiveMeshGeometry::checkCellDeterminant"
1305 "(const bool, const scalar, const primitiveMesh&"
1306 ", const pointField&, const labelList&, const labelList&"
1308 ) << nWarnDet << " cells with determinant < " << warnDet
1322 bool Foam::primitiveMeshGeometry::checkFaceDotProduct
1325 const scalar orthWarn,
1326 const labelList& checkFaces,
1327 labelHashSet* setPtr
1330 return checkFaceDotProduct
1343 bool Foam::primitiveMeshGeometry::checkFacePyramids
1346 const scalar minPyrVol,
1347 const pointField& p,
1348 const labelList& checkFaces,
1349 labelHashSet* setPtr
1352 return checkFacePyramids
1365 bool Foam::primitiveMeshGeometry::checkFaceSkewness
1368 const scalar internalSkew,
1369 const scalar boundarySkew,
1370 const labelList& checkFaces,
1371 labelHashSet* setPtr
1374 return checkFaceSkewness
1389 bool Foam::primitiveMeshGeometry::checkFaceWeights
1392 const scalar warnWeight,
1393 const labelList& checkFaces,
1394 labelHashSet* setPtr
1397 return checkFaceWeights
1411 bool Foam::primitiveMeshGeometry::checkFaceAngles
1414 const scalar maxDeg,
1415 const pointField& p,
1416 const labelList& checkFaces,
1417 labelHashSet* setPtr
1420 return checkFaceAngles
1433 //bool Foam::primitiveMeshGeometry::checkFaceFlatness
1435 // const bool report,
1436 // const scalar warnFlatness,
1437 // const pointField& p,
1438 // const labelList& checkFaces,
1439 // labelHashSet* setPtr
1442 // return checkFaceFlatness
1456 bool Foam::primitiveMeshGeometry::checkFaceTwist
1459 const scalar minTwist,
1460 const pointField& p,
1461 const labelList& checkFaces,
1462 labelHashSet* setPtr
1465 return checkFaceTwist
1479 bool Foam::primitiveMeshGeometry::checkFaceArea
1482 const scalar minArea,
1483 const labelList& checkFaces,
1484 labelHashSet* setPtr
1487 return checkFaceArea
1499 bool Foam::primitiveMeshGeometry::checkCellDeterminant
1502 const scalar warnDet,
1503 const labelList& checkFaces,
1504 const labelList& affectedCells,
1505 labelHashSet* setPtr
1508 return checkCellDeterminant
1521 // ************************************************************************* //