1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "motionSmoother.H"
28 #include "polyMeshGeometry.H"
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
33 bool Foam::motionSmoother::checkMesh
37 const dictionary& dict,
38 const labelList& checkFaces,
39 labelHashSet& wrongFaces
42 List<labelPair> emptyBaffles;
54 bool Foam::motionSmoother::checkMesh
58 const dictionary& dict,
59 const labelList& checkFaces,
60 const List<labelPair>& baffles,
61 labelHashSet& wrongFaces
64 const scalar maxNonOrtho
66 readScalar(dict.lookup("maxNonOrtho", true))
70 readScalar(dict.lookup("minVol", true))
72 const scalar maxConcave
74 readScalar(dict.lookup("maxConcave", true))
78 readScalar(dict.lookup("minArea", true))
80 const scalar maxIntSkew
82 readScalar(dict.lookup("maxInternalSkewness", true))
84 const scalar maxBounSkew
86 readScalar(dict.lookup("maxBoundarySkewness", true))
88 const scalar minWeight
90 readScalar(dict.lookup("minFaceWeight", true))
92 const scalar minVolRatio
94 readScalar(dict.lookup("minVolRatio", true))
98 readScalar(dict.lookup("minTwist", true))
100 const scalar minTriangleTwist
102 readScalar(dict.lookup("minTriangleTwist", true))
106 readScalar(dict.lookup("minDeterminant", true))
109 label nWrongFaces = 0;
111 Info<< "Checking faces in error :" << endl;
112 //Pout.setf(ios_base::left);
114 if (maxNonOrtho < 180.0-SMALL)
116 polyMeshGeometry::checkFaceDotProduct
128 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
130 Info<< " non-orthogonality > "
131 << setw(3) << maxNonOrtho
133 << nNewWrongFaces-nWrongFaces << endl;
135 nWrongFaces = nNewWrongFaces;
140 polyMeshGeometry::checkFacePyramids
152 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
154 Info<< " faces with face pyramid volume < "
155 << setw(5) << minVol << " : "
156 << nNewWrongFaces-nWrongFaces << endl;
158 nWrongFaces = nNewWrongFaces;
161 if (maxConcave < 180.0-SMALL)
163 polyMeshGeometry::checkFaceAngles
174 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
176 Info<< " faces with concavity > "
177 << setw(3) << maxConcave
179 << nNewWrongFaces-nWrongFaces << endl;
181 nWrongFaces = nNewWrongFaces;
184 if (minArea > -SMALL)
186 polyMeshGeometry::checkFaceArea
196 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
198 Info<< " faces with area < "
199 << setw(5) << minArea
201 << nNewWrongFaces-nWrongFaces << endl;
203 nWrongFaces = nNewWrongFaces;
206 if (maxIntSkew > 0 || maxBounSkew > 0)
208 polyMeshGeometry::checkFaceSkewness
222 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
224 Info<< " faces with skewness > "
225 << setw(3) << maxIntSkew
226 << " (internal) or " << setw(3) << maxBounSkew
227 << " (boundary) : " << nNewWrongFaces-nWrongFaces << endl;
229 nWrongFaces = nNewWrongFaces;
232 if (minWeight >= 0 && minWeight < 1)
234 polyMeshGeometry::checkFaceWeights
247 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
249 Info<< " faces with interpolation weights (0..1) < "
250 << setw(5) << minWeight
252 << nNewWrongFaces-nWrongFaces << endl;
254 nWrongFaces = nNewWrongFaces;
257 if (minVolRatio >= 0)
259 polyMeshGeometry::checkVolRatio
270 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
272 Info<< " faces with volume ratio of neighbour cells < "
273 << setw(5) << minVolRatio
275 << nNewWrongFaces-nWrongFaces << endl;
277 nWrongFaces = nNewWrongFaces;
282 //Pout<< "Checking face twist: dot product of face normal "
283 // << "with face triangle normals" << endl;
284 polyMeshGeometry::checkFaceTwist
297 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
299 Info<< " faces with face twist < "
300 << setw(5) << minTwist
302 << nNewWrongFaces-nWrongFaces << endl;
304 nWrongFaces = nNewWrongFaces;
307 if (minTriangleTwist > -1)
309 //Pout<< "Checking triangle twist: dot product of consecutive triangle"
310 // << " normals resulting from face-centre decomposition" << endl;
311 polyMeshGeometry::checkTriangleTwist
323 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
325 Info<< " faces with triangle twist < "
326 << setw(5) << minTriangleTwist
328 << nNewWrongFaces-nWrongFaces << endl;
330 nWrongFaces = nNewWrongFaces;
335 polyMeshGeometry::checkCellDeterminant
342 polyMeshGeometry::affectedCells(mesh, checkFaces),
346 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
348 Info<< " faces on cells with determinant < "
349 << setw(5) << minDet << " : "
350 << nNewWrongFaces-nWrongFaces << endl;
352 nWrongFaces = nNewWrongFaces;
355 //Pout.setf(ios_base::right);
357 return nWrongFaces > 0;
361 bool Foam::motionSmoother::checkMesh
364 const polyMesh& mesh,
365 const dictionary& dict,
366 labelHashSet& wrongFaces
374 identity(mesh.nFaces()),
379 bool Foam::motionSmoother::checkMesh
382 const dictionary& dict,
383 const polyMeshGeometry& meshGeom,
384 const labelList& checkFaces,
385 labelHashSet& wrongFaces
388 List<labelPair> emptyBaffles;
402 bool Foam::motionSmoother::checkMesh
405 const dictionary& dict,
406 const polyMeshGeometry& meshGeom,
407 const labelList& checkFaces,
408 const List<labelPair>& baffles,
409 labelHashSet& wrongFaces
412 const scalar maxNonOrtho
414 readScalar(dict.lookup("maxNonOrtho", true))
418 readScalar(dict.lookup("minVol", true))
420 const scalar maxConcave
422 readScalar(dict.lookup("maxConcave", true))
426 readScalar(dict.lookup("minArea", true))
428 const scalar maxIntSkew
430 readScalar(dict.lookup("maxInternalSkewness", true))
432 const scalar maxBounSkew
434 readScalar(dict.lookup("maxBoundarySkewness", true))
436 const scalar minWeight
438 readScalar(dict.lookup("minFaceWeight", true))
440 const scalar minVolRatio
442 readScalar(dict.lookup("minVolRatio", true))
444 const scalar minTwist
446 readScalar(dict.lookup("minTwist", true))
448 const scalar minTriangleTwist
450 readScalar(dict.lookup("minTriangleTwist", true))
454 readScalar(dict.lookup("minDeterminant", true))
457 label nWrongFaces = 0;
459 Info<< "Checking faces in error :" << endl;
460 //Pout.setf(ios_base::left);
462 if (maxNonOrtho < 180.0-SMALL)
464 meshGeom.checkFaceDotProduct
473 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
475 Info<< " non-orthogonality > "
476 << setw(3) << maxNonOrtho
478 << nNewWrongFaces-nWrongFaces << endl;
480 nWrongFaces = nNewWrongFaces;
485 meshGeom.checkFacePyramids
489 meshGeom.mesh().points(),
495 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
497 Info<< " faces with face pyramid volume < "
498 << setw(5) << minVol << " : "
499 << nNewWrongFaces-nWrongFaces << endl;
501 nWrongFaces = nNewWrongFaces;
504 if (maxConcave < 180.0-SMALL)
506 meshGeom.checkFaceAngles
510 meshGeom.mesh().points(),
515 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
517 Info<< " faces with concavity > "
518 << setw(3) << maxConcave
520 << nNewWrongFaces-nWrongFaces << endl;
522 nWrongFaces = nNewWrongFaces;
525 if (minArea > -SMALL)
527 meshGeom.checkFaceArea(report, minArea, checkFaces, &wrongFaces);
529 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
531 Info<< " faces with area < "
532 << setw(5) << minArea
534 << nNewWrongFaces-nWrongFaces << endl;
536 nWrongFaces = nNewWrongFaces;
539 if (maxIntSkew > 0 || maxBounSkew > 0)
541 meshGeom.checkFaceSkewness
551 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
553 Info<< " faces with skewness > "
554 << setw(3) << maxIntSkew
555 << " (internal) or " << setw(3) << maxBounSkew
556 << " (boundary) : " << nNewWrongFaces-nWrongFaces << endl;
558 nWrongFaces = nNewWrongFaces;
561 if (minWeight >= 0 && minWeight < 1)
563 meshGeom.checkFaceWeights
572 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
574 Info<< " faces with interpolation weights (0..1) < "
575 << setw(5) << minWeight
577 << nNewWrongFaces-nWrongFaces << endl;
579 nWrongFaces = nNewWrongFaces;
582 if (minVolRatio >= 0)
584 meshGeom.checkVolRatio
593 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
595 Info<< " faces with volume ratio of neighbour cells < "
596 << setw(5) << minVolRatio
598 << nNewWrongFaces-nWrongFaces << endl;
600 nWrongFaces = nNewWrongFaces;
605 //Pout<< "Checking face twist: dot product of face normal "
606 // << "with face triangle normals" << endl;
607 meshGeom.checkFaceTwist
611 meshGeom.mesh().points(),
616 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
618 Info<< " faces with face twist < "
619 << setw(5) << minTwist
621 << nNewWrongFaces-nWrongFaces << endl;
623 nWrongFaces = nNewWrongFaces;
626 if (minTriangleTwist > -1)
628 //Pout<< "Checking triangle twist: dot product of consecutive triangle"
629 // << " normals resulting from face-centre decomposition" << endl;
630 meshGeom.checkTriangleTwist
634 meshGeom.mesh().points(),
639 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
641 Info<< " faces with triangle twist < "
642 << setw(5) << minTriangleTwist
644 << nNewWrongFaces-nWrongFaces << endl;
646 nWrongFaces = nNewWrongFaces;
651 meshGeom.checkCellDeterminant
656 meshGeom.affectedCells(meshGeom.mesh(), checkFaces),
660 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
662 Info<< " faces on cells with determinant < "
663 << setw(5) << minDet << " : "
664 << nNewWrongFaces-nWrongFaces << endl;
666 nWrongFaces = nNewWrongFaces;
669 //Pout.setf(ios_base::right);
671 return nWrongFaces > 0;
675 // ************************************************************************* //