1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 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
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 "motionSmoother.H"
27 #include <dynamicMesh/polyMeshGeometry.H>
28 #include <OpenFOAM/IOmanip.H>
30 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 bool Foam::motionSmoother::checkMesh
36 const dictionary& dict,
37 const labelList& checkFaces,
38 labelHashSet& wrongFaces
41 List<labelPair> emptyBaffles;
53 bool Foam::motionSmoother::checkMesh
57 const dictionary& dict,
58 const labelList& checkFaces,
59 const List<labelPair>& baffles,
60 labelHashSet& wrongFaces
63 const scalar maxNonOrtho
65 readScalar(dict.lookup("maxNonOrtho", true))
69 readScalar(dict.lookup("minVol", true))
71 const scalar maxConcave
73 readScalar(dict.lookup("maxConcave", true))
77 readScalar(dict.lookup("minArea", true))
79 const scalar maxIntSkew
81 readScalar(dict.lookup("maxInternalSkewness", true))
83 const scalar maxBounSkew
85 readScalar(dict.lookup("maxBoundarySkewness", true))
87 const scalar minWeight
89 readScalar(dict.lookup("minFaceWeight", true))
91 const scalar minVolRatio
93 readScalar(dict.lookup("minVolRatio", true))
97 readScalar(dict.lookup("minTwist", true))
99 const scalar minTriangleTwist
101 readScalar(dict.lookup("minTriangleTwist", true))
105 readScalar(dict.lookup("minDeterminant", true))
108 label nWrongFaces = 0;
110 Info<< "Checking faces in error :" << endl;
111 //Pout.setf(ios_base::left);
113 if (maxNonOrtho < 180.0-SMALL)
115 polyMeshGeometry::checkFaceDotProduct
127 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
129 Info<< " non-orthogonality > "
130 << setw(3) << maxNonOrtho
132 << nNewWrongFaces-nWrongFaces << endl;
134 nWrongFaces = nNewWrongFaces;
139 polyMeshGeometry::checkFacePyramids
151 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
153 Info<< " faces with face pyramid volume < "
154 << setw(5) << minVol << " : "
155 << nNewWrongFaces-nWrongFaces << endl;
157 nWrongFaces = nNewWrongFaces;
160 if (maxConcave < 180.0-SMALL)
162 polyMeshGeometry::checkFaceAngles
173 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
175 Info<< " faces with concavity > "
176 << setw(3) << maxConcave
178 << nNewWrongFaces-nWrongFaces << endl;
180 nWrongFaces = nNewWrongFaces;
183 if (minArea > -SMALL)
185 polyMeshGeometry::checkFaceArea
195 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
197 Info<< " faces with area < "
198 << setw(5) << minArea
200 << nNewWrongFaces-nWrongFaces << endl;
202 nWrongFaces = nNewWrongFaces;
205 if (maxIntSkew > 0 || maxBounSkew > 0)
207 polyMeshGeometry::checkFaceSkewness
221 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
223 Info<< " faces with skewness > "
224 << setw(3) << maxIntSkew
225 << " (internal) or " << setw(3) << maxBounSkew
226 << " (boundary) : " << nNewWrongFaces-nWrongFaces << endl;
228 nWrongFaces = nNewWrongFaces;
231 if (minWeight >= 0 && minWeight < 1)
233 polyMeshGeometry::checkFaceWeights
246 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
248 Info<< " faces with interpolation weights (0..1) < "
249 << setw(5) << minWeight
251 << nNewWrongFaces-nWrongFaces << endl;
253 nWrongFaces = nNewWrongFaces;
256 if (minVolRatio >= 0)
258 polyMeshGeometry::checkVolRatio
269 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
271 Info<< " faces with volume ratio of neighbour cells < "
272 << setw(5) << minVolRatio
274 << nNewWrongFaces-nWrongFaces << endl;
276 nWrongFaces = nNewWrongFaces;
281 //Pout<< "Checking face twist: dot product of face normal "
282 // << "with face triangle normals" << endl;
283 polyMeshGeometry::checkFaceTwist
296 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
298 Info<< " faces with face twist < "
299 << setw(5) << minTwist
301 << nNewWrongFaces-nWrongFaces << endl;
303 nWrongFaces = nNewWrongFaces;
306 if (minTriangleTwist > -1)
308 //Pout<< "Checking triangle twist: dot product of consecutive triangle"
309 // << " normals resulting from face-centre decomposition" << endl;
310 polyMeshGeometry::checkTriangleTwist
322 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
324 Info<< " faces with triangle twist < "
325 << setw(5) << minTriangleTwist
327 << nNewWrongFaces-nWrongFaces << endl;
329 nWrongFaces = nNewWrongFaces;
334 polyMeshGeometry::checkCellDeterminant
341 polyMeshGeometry::affectedCells(mesh, checkFaces),
345 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
347 Info<< " faces on cells with determinant < "
348 << setw(5) << minDet << " : "
349 << nNewWrongFaces-nWrongFaces << endl;
351 nWrongFaces = nNewWrongFaces;
354 //Pout.setf(ios_base::right);
356 return nWrongFaces > 0;
360 bool Foam::motionSmoother::checkMesh
363 const polyMesh& mesh,
364 const dictionary& dict,
365 labelHashSet& wrongFaces
373 identity(mesh.nFaces()),
378 bool Foam::motionSmoother::checkMesh
381 const dictionary& dict,
382 const polyMeshGeometry& meshGeom,
383 const labelList& checkFaces,
384 labelHashSet& wrongFaces
387 List<labelPair> emptyBaffles;
401 bool Foam::motionSmoother::checkMesh
404 const dictionary& dict,
405 const polyMeshGeometry& meshGeom,
406 const labelList& checkFaces,
407 const List<labelPair>& baffles,
408 labelHashSet& wrongFaces
411 const scalar maxNonOrtho
413 readScalar(dict.lookup("maxNonOrtho", true))
417 readScalar(dict.lookup("minVol", true))
419 const scalar maxConcave
421 readScalar(dict.lookup("maxConcave", true))
425 readScalar(dict.lookup("minArea", true))
427 const scalar maxIntSkew
429 readScalar(dict.lookup("maxInternalSkewness", true))
431 const scalar maxBounSkew
433 readScalar(dict.lookup("maxBoundarySkewness", true))
435 const scalar minWeight
437 readScalar(dict.lookup("minFaceWeight", true))
439 const scalar minVolRatio
441 readScalar(dict.lookup("minVolRatio", true))
443 const scalar minTwist
445 readScalar(dict.lookup("minTwist", true))
447 const scalar minTriangleTwist
449 readScalar(dict.lookup("minTriangleTwist", true))
453 readScalar(dict.lookup("minDeterminant", true))
456 label nWrongFaces = 0;
458 Info<< "Checking faces in error :" << endl;
459 //Pout.setf(ios_base::left);
461 if (maxNonOrtho < 180.0-SMALL)
463 meshGeom.checkFaceDotProduct
472 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
474 Info<< " non-orthogonality > "
475 << setw(3) << maxNonOrtho
477 << nNewWrongFaces-nWrongFaces << endl;
479 nWrongFaces = nNewWrongFaces;
484 meshGeom.checkFacePyramids
488 meshGeom.mesh().points(),
494 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
496 Info<< " faces with face pyramid volume < "
497 << setw(5) << minVol << " : "
498 << nNewWrongFaces-nWrongFaces << endl;
500 nWrongFaces = nNewWrongFaces;
503 if (maxConcave < 180.0-SMALL)
505 meshGeom.checkFaceAngles
509 meshGeom.mesh().points(),
514 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
516 Info<< " faces with concavity > "
517 << setw(3) << maxConcave
519 << nNewWrongFaces-nWrongFaces << endl;
521 nWrongFaces = nNewWrongFaces;
524 if (minArea > -SMALL)
526 meshGeom.checkFaceArea(report, minArea, checkFaces, &wrongFaces);
528 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
530 Info<< " faces with area < "
531 << setw(5) << minArea
533 << nNewWrongFaces-nWrongFaces << endl;
535 nWrongFaces = nNewWrongFaces;
538 if (maxIntSkew > 0 || maxBounSkew > 0)
540 meshGeom.checkFaceSkewness
550 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
552 Info<< " faces with skewness > "
553 << setw(3) << maxIntSkew
554 << " (internal) or " << setw(3) << maxBounSkew
555 << " (boundary) : " << nNewWrongFaces-nWrongFaces << endl;
557 nWrongFaces = nNewWrongFaces;
560 if (minWeight >= 0 && minWeight < 1)
562 meshGeom.checkFaceWeights
571 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
573 Info<< " faces with interpolation weights (0..1) < "
574 << setw(5) << minWeight
576 << nNewWrongFaces-nWrongFaces << endl;
578 nWrongFaces = nNewWrongFaces;
581 if (minVolRatio >= 0)
583 meshGeom.checkVolRatio
592 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
594 Info<< " faces with volume ratio of neighbour cells < "
595 << setw(5) << minVolRatio
597 << nNewWrongFaces-nWrongFaces << endl;
599 nWrongFaces = nNewWrongFaces;
604 //Pout<< "Checking face twist: dot product of face normal "
605 // << "with face triangle normals" << endl;
606 meshGeom.checkFaceTwist
610 meshGeom.mesh().points(),
615 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
617 Info<< " faces with face twist < "
618 << setw(5) << minTwist
620 << nNewWrongFaces-nWrongFaces << endl;
622 nWrongFaces = nNewWrongFaces;
625 if (minTriangleTwist > -1)
627 //Pout<< "Checking triangle twist: dot product of consecutive triangle"
628 // << " normals resulting from face-centre decomposition" << endl;
629 meshGeom.checkTriangleTwist
633 meshGeom.mesh().points(),
638 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
640 Info<< " faces with triangle twist < "
641 << setw(5) << minTriangleTwist
643 << nNewWrongFaces-nWrongFaces << endl;
645 nWrongFaces = nNewWrongFaces;
650 meshGeom.checkCellDeterminant
655 meshGeom.affectedCells(meshGeom.mesh(), checkFaces),
659 label nNewWrongFaces = returnReduce(wrongFaces.size(), sumOp<label>());
661 Info<< " faces on cells with determinant < "
662 << setw(5) << minDet << " : "
663 << nNewWrongFaces-nWrongFaces << endl;
665 nWrongFaces = nNewWrongFaces;
668 //Pout.setf(ios_base::right);
670 return nWrongFaces > 0;
674 // ************************ vim: set sw=4 sts=4 et: ************************ //