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 "motionSmoother.H"
00028 #include "polyMeshGeometry.H"
00029 #include "IOmanip.H"
00030
00031
00032
00033 bool Foam::motionSmoother::checkMesh
00034 (
00035 const bool report,
00036 const polyMesh& mesh,
00037 const dictionary& dict,
00038 const labelList& checkFaces,
00039 labelHashSet& wrongFaces
00040 )
00041 {
00042 List<labelPair> emptyBaffles;
00043 return checkMesh
00044 (
00045 report,
00046 mesh,
00047 dict,
00048 checkFaces,
00049 emptyBaffles,
00050 wrongFaces
00051 );
00052 }
00053
00054 bool Foam::motionSmoother::checkMesh
00055 (
00056 const bool report,
00057 const polyMesh& mesh,
00058 const dictionary& dict,
00059 const labelList& checkFaces,
00060 const List<labelPair>& baffles,
00061 labelHashSet& wrongFaces
00062 )
00063 {
00064 const scalar maxNonOrtho
00065 (
00066 readScalar(dict.lookup("maxNonOrtho", true))
00067 );
00068 const scalar minVol
00069 (
00070 readScalar(dict.lookup("minVol", true))
00071 );
00072 const scalar maxConcave
00073 (
00074 readScalar(dict.lookup("maxConcave", true))
00075 );
00076 const scalar minArea
00077 (
00078 readScalar(dict.lookup("minArea", true))
00079 );
00080 const scalar maxIntSkew
00081 (
00082 readScalar(dict.lookup("maxInternalSkewness", true))
00083 );
00084 const scalar maxBounSkew
00085 (
00086 readScalar(dict.lookup("maxBoundarySkewness", true))
00087 );
00088 const scalar minWeight
00089 (
00090 readScalar(dict.lookup("minFaceWeight", true))
00091 );
00092 const scalar minVolRatio
00093 (
00094 readScalar(dict.lookup("minVolRatio", true))
00095 );
00096 const scalar minTwist
00097 (
00098 readScalar(dict.lookup("minTwist", true))
00099 );
00100 const scalar minTriangleTwist
00101 (
00102 readScalar(dict.lookup("minTriangleTwist", true))
00103 );
00104 const scalar minDet
00105 (
00106 readScalar(dict.lookup("minDeterminant", true))
00107 );
00108
00109 label nWrongFaces = 0;
00110
00111 Info<< "Checking faces in error :" << endl;
00112
00113
00114 if (maxNonOrtho < 180.0-SMALL)
00115 {
00116 polyMeshGeometry::checkFaceDotProduct
00117 (
00118 report,
00119 maxNonOrtho,
00120 mesh,
00121 mesh.cellCentres(),
00122 mesh.faceAreas(),
00123 checkFaces,
00124 baffles,
00125 &wrongFaces
00126 );
00127
00128 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00129
00130 Info<< " non-orthogonality > "
00131 << setw(3) << maxNonOrtho
00132 << " degrees : "
00133 << nNewWrongFaces-nWrongFaces << endl;
00134
00135 nWrongFaces = nNewWrongFaces;
00136 }
00137
00138 if (minVol > -GREAT)
00139 {
00140 polyMeshGeometry::checkFacePyramids
00141 (
00142 report,
00143 minVol,
00144 mesh,
00145 mesh.cellCentres(),
00146 mesh.points(),
00147 checkFaces,
00148 baffles,
00149 &wrongFaces
00150 );
00151
00152 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00153
00154 Info<< " faces with face pyramid volume < "
00155 << setw(5) << minVol << " : "
00156 << nNewWrongFaces-nWrongFaces << endl;
00157
00158 nWrongFaces = nNewWrongFaces;
00159 }
00160
00161 if (maxConcave < 180.0-SMALL)
00162 {
00163 polyMeshGeometry::checkFaceAngles
00164 (
00165 report,
00166 maxConcave,
00167 mesh,
00168 mesh.faceAreas(),
00169 mesh.points(),
00170 checkFaces,
00171 &wrongFaces
00172 );
00173
00174 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00175
00176 Info<< " faces with concavity > "
00177 << setw(3) << maxConcave
00178 << " degrees : "
00179 << nNewWrongFaces-nWrongFaces << endl;
00180
00181 nWrongFaces = nNewWrongFaces;
00182 }
00183
00184 if (minArea > -SMALL)
00185 {
00186 polyMeshGeometry::checkFaceArea
00187 (
00188 report,
00189 minArea,
00190 mesh,
00191 mesh.faceAreas(),
00192 checkFaces,
00193 &wrongFaces
00194 );
00195
00196 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00197
00198 Info<< " faces with area < "
00199 << setw(5) << minArea
00200 << " m^2 : "
00201 << nNewWrongFaces-nWrongFaces << endl;
00202
00203 nWrongFaces = nNewWrongFaces;
00204 }
00205
00206 if (maxIntSkew > 0 || maxBounSkew > 0)
00207 {
00208 polyMeshGeometry::checkFaceSkewness
00209 (
00210 report,
00211 maxIntSkew,
00212 maxBounSkew,
00213 mesh,
00214 mesh.cellCentres(),
00215 mesh.faceCentres(),
00216 mesh.faceAreas(),
00217 checkFaces,
00218 baffles,
00219 &wrongFaces
00220 );
00221
00222 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00223
00224 Info<< " faces with skewness > "
00225 << setw(3) << maxIntSkew
00226 << " (internal) or " << setw(3) << maxBounSkew
00227 << " (boundary) : " << nNewWrongFaces-nWrongFaces << endl;
00228
00229 nWrongFaces = nNewWrongFaces;
00230 }
00231
00232 if (minWeight >= 0 && minWeight < 1)
00233 {
00234 polyMeshGeometry::checkFaceWeights
00235 (
00236 report,
00237 minWeight,
00238 mesh,
00239 mesh.cellCentres(),
00240 mesh.faceCentres(),
00241 mesh.faceAreas(),
00242 checkFaces,
00243 baffles,
00244 &wrongFaces
00245 );
00246
00247 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00248
00249 Info<< " faces with interpolation weights (0..1) < "
00250 << setw(5) << minWeight
00251 << " : "
00252 << nNewWrongFaces-nWrongFaces << endl;
00253
00254 nWrongFaces = nNewWrongFaces;
00255 }
00256
00257 if (minVolRatio >= 0)
00258 {
00259 polyMeshGeometry::checkVolRatio
00260 (
00261 report,
00262 minVolRatio,
00263 mesh,
00264 mesh.cellVolumes(),
00265 checkFaces,
00266 baffles,
00267 &wrongFaces
00268 );
00269
00270 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00271
00272 Info<< " faces with volume ratio of neighbour cells < "
00273 << setw(5) << minVolRatio
00274 << " : "
00275 << nNewWrongFaces-nWrongFaces << endl;
00276
00277 nWrongFaces = nNewWrongFaces;
00278 }
00279
00280 if (minTwist > -1)
00281 {
00282
00283
00284 polyMeshGeometry::checkFaceTwist
00285 (
00286 report,
00287 minTwist,
00288 mesh,
00289 mesh.cellCentres(),
00290 mesh.faceAreas(),
00291 mesh.faceCentres(),
00292 mesh.points(),
00293 checkFaces,
00294 &wrongFaces
00295 );
00296
00297 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00298
00299 Info<< " faces with face twist < "
00300 << setw(5) << minTwist
00301 << " : "
00302 << nNewWrongFaces-nWrongFaces << endl;
00303
00304 nWrongFaces = nNewWrongFaces;
00305 }
00306
00307 if (minTriangleTwist > -1)
00308 {
00309
00310
00311 polyMeshGeometry::checkTriangleTwist
00312 (
00313 report,
00314 minTriangleTwist,
00315 mesh,
00316 mesh.faceAreas(),
00317 mesh.faceCentres(),
00318 mesh.points(),
00319 checkFaces,
00320 &wrongFaces
00321 );
00322
00323 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00324
00325 Info<< " faces with triangle twist < "
00326 << setw(5) << minTriangleTwist
00327 << " : "
00328 << nNewWrongFaces-nWrongFaces << endl;
00329
00330 nWrongFaces = nNewWrongFaces;
00331 }
00332
00333 if (minDet > -1)
00334 {
00335 polyMeshGeometry::checkCellDeterminant
00336 (
00337 report,
00338 minDet,
00339 mesh,
00340 mesh.faceAreas(),
00341 checkFaces,
00342 polyMeshGeometry::affectedCells(mesh, checkFaces),
00343 &wrongFaces
00344 );
00345
00346 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00347
00348 Info<< " faces on cells with determinant < "
00349 << setw(5) << minDet << " : "
00350 << nNewWrongFaces-nWrongFaces << endl;
00351
00352 nWrongFaces = nNewWrongFaces;
00353 }
00354
00355
00356
00357 return nWrongFaces > 0;
00358 }
00359
00360
00361 bool Foam::motionSmoother::checkMesh
00362 (
00363 const bool report,
00364 const polyMesh& mesh,
00365 const dictionary& dict,
00366 labelHashSet& wrongFaces
00367 )
00368 {
00369 return checkMesh
00370 (
00371 report,
00372 mesh,
00373 dict,
00374 identity(mesh.nFaces()),
00375 wrongFaces
00376 );
00377 }
00378
00379 bool Foam::motionSmoother::checkMesh
00380 (
00381 const bool report,
00382 const dictionary& dict,
00383 const polyMeshGeometry& meshGeom,
00384 const labelList& checkFaces,
00385 labelHashSet& wrongFaces
00386 )
00387 {
00388 List<labelPair> emptyBaffles;
00389
00390 return checkMesh
00391 (
00392 report,
00393 dict,
00394 meshGeom,
00395 checkFaces,
00396 emptyBaffles,
00397 wrongFaces
00398 );
00399 }
00400
00401
00402 bool Foam::motionSmoother::checkMesh
00403 (
00404 const bool report,
00405 const dictionary& dict,
00406 const polyMeshGeometry& meshGeom,
00407 const labelList& checkFaces,
00408 const List<labelPair>& baffles,
00409 labelHashSet& wrongFaces
00410 )
00411 {
00412 const scalar maxNonOrtho
00413 (
00414 readScalar(dict.lookup("maxNonOrtho", true))
00415 );
00416 const scalar minVol
00417 (
00418 readScalar(dict.lookup("minVol", true))
00419 );
00420 const scalar maxConcave
00421 (
00422 readScalar(dict.lookup("maxConcave", true))
00423 );
00424 const scalar minArea
00425 (
00426 readScalar(dict.lookup("minArea", true))
00427 );
00428 const scalar maxIntSkew
00429 (
00430 readScalar(dict.lookup("maxInternalSkewness", true))
00431 );
00432 const scalar maxBounSkew
00433 (
00434 readScalar(dict.lookup("maxBoundarySkewness", true))
00435 );
00436 const scalar minWeight
00437 (
00438 readScalar(dict.lookup("minFaceWeight", true))
00439 );
00440 const scalar minVolRatio
00441 (
00442 readScalar(dict.lookup("minVolRatio", true))
00443 );
00444 const scalar minTwist
00445 (
00446 readScalar(dict.lookup("minTwist", true))
00447 );
00448 const scalar minTriangleTwist
00449 (
00450 readScalar(dict.lookup("minTriangleTwist", true))
00451 );
00452 const scalar minDet
00453 (
00454 readScalar(dict.lookup("minDeterminant", true))
00455 );
00456
00457 label nWrongFaces = 0;
00458
00459 Info<< "Checking faces in error :" << endl;
00460
00461
00462 if (maxNonOrtho < 180.0-SMALL)
00463 {
00464 meshGeom.checkFaceDotProduct
00465 (
00466 report,
00467 maxNonOrtho,
00468 checkFaces,
00469 baffles,
00470 &wrongFaces
00471 );
00472
00473 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00474
00475 Info<< " non-orthogonality > "
00476 << setw(3) << maxNonOrtho
00477 << " degrees : "
00478 << nNewWrongFaces-nWrongFaces << endl;
00479
00480 nWrongFaces = nNewWrongFaces;
00481 }
00482
00483 if (minVol > -GREAT)
00484 {
00485 meshGeom.checkFacePyramids
00486 (
00487 report,
00488 minVol,
00489 meshGeom.mesh().points(),
00490 checkFaces,
00491 baffles,
00492 &wrongFaces
00493 );
00494
00495 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00496
00497 Info<< " faces with face pyramid volume < "
00498 << setw(5) << minVol << " : "
00499 << nNewWrongFaces-nWrongFaces << endl;
00500
00501 nWrongFaces = nNewWrongFaces;
00502 }
00503
00504 if (maxConcave < 180.0-SMALL)
00505 {
00506 meshGeom.checkFaceAngles
00507 (
00508 report,
00509 maxConcave,
00510 meshGeom.mesh().points(),
00511 checkFaces,
00512 &wrongFaces
00513 );
00514
00515 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00516
00517 Info<< " faces with concavity > "
00518 << setw(3) << maxConcave
00519 << " degrees : "
00520 << nNewWrongFaces-nWrongFaces << endl;
00521
00522 nWrongFaces = nNewWrongFaces;
00523 }
00524
00525 if (minArea > -SMALL)
00526 {
00527 meshGeom.checkFaceArea(report, minArea, checkFaces, &wrongFaces);
00528
00529 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00530
00531 Info<< " faces with area < "
00532 << setw(5) << minArea
00533 << " m^2 : "
00534 << nNewWrongFaces-nWrongFaces << endl;
00535
00536 nWrongFaces = nNewWrongFaces;
00537 }
00538
00539 if (maxIntSkew > 0 || maxBounSkew > 0)
00540 {
00541 meshGeom.checkFaceSkewness
00542 (
00543 report,
00544 maxIntSkew,
00545 maxBounSkew,
00546 checkFaces,
00547 baffles,
00548 &wrongFaces
00549 );
00550
00551 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00552
00553 Info<< " faces with skewness > "
00554 << setw(3) << maxIntSkew
00555 << " (internal) or " << setw(3) << maxBounSkew
00556 << " (boundary) : " << nNewWrongFaces-nWrongFaces << endl;
00557
00558 nWrongFaces = nNewWrongFaces;
00559 }
00560
00561 if (minWeight >= 0 && minWeight < 1)
00562 {
00563 meshGeom.checkFaceWeights
00564 (
00565 report,
00566 minWeight,
00567 checkFaces,
00568 baffles,
00569 &wrongFaces
00570 );
00571
00572 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00573
00574 Info<< " faces with interpolation weights (0..1) < "
00575 << setw(5) << minWeight
00576 << " : "
00577 << nNewWrongFaces-nWrongFaces << endl;
00578
00579 nWrongFaces = nNewWrongFaces;
00580 }
00581
00582 if (minVolRatio >= 0)
00583 {
00584 meshGeom.checkVolRatio
00585 (
00586 report,
00587 minVolRatio,
00588 checkFaces,
00589 baffles,
00590 &wrongFaces
00591 );
00592
00593 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00594
00595 Info<< " faces with volume ratio of neighbour cells < "
00596 << setw(5) << minVolRatio
00597 << " : "
00598 << nNewWrongFaces-nWrongFaces << endl;
00599
00600 nWrongFaces = nNewWrongFaces;
00601 }
00602
00603 if (minTwist > -1)
00604 {
00605
00606
00607 meshGeom.checkFaceTwist
00608 (
00609 report,
00610 minTwist,
00611 meshGeom.mesh().points(),
00612 checkFaces,
00613 &wrongFaces
00614 );
00615
00616 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00617
00618 Info<< " faces with face twist < "
00619 << setw(5) << minTwist
00620 << " : "
00621 << nNewWrongFaces-nWrongFaces << endl;
00622
00623 nWrongFaces = nNewWrongFaces;
00624 }
00625
00626 if (minTriangleTwist > -1)
00627 {
00628
00629
00630 meshGeom.checkTriangleTwist
00631 (
00632 report,
00633 minTriangleTwist,
00634 meshGeom.mesh().points(),
00635 checkFaces,
00636 &wrongFaces
00637 );
00638
00639 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00640
00641 Info<< " faces with triangle twist < "
00642 << setw(5) << minTriangleTwist
00643 << " : "
00644 << nNewWrongFaces-nWrongFaces << endl;
00645
00646 nWrongFaces = nNewWrongFaces;
00647 }
00648
00649 if (minDet > -1)
00650 {
00651 meshGeom.checkCellDeterminant
00652 (
00653 report,
00654 minDet,
00655 checkFaces,
00656 meshGeom.affectedCells(meshGeom.mesh(), checkFaces),
00657 &wrongFaces
00658 );
00659
00660 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
00661
00662 Info<< " faces on cells with determinant < "
00663 << setw(5) << minDet << " : "
00664 << nNewWrongFaces-nWrongFaces << endl;
00665
00666 nWrongFaces = nNewWrongFaces;
00667 }
00668
00669
00670
00671 return nWrongFaces > 0;
00672 }
00673
00674
00675