checkMeshQuality.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "checkMeshQuality.H"
27 #include "polyMesh.H"
28 #include "cellSet.H"
29 #include "faceSet.H"
30 #include "motionSmoother.H"
31 #include "surfaceWriter.H"
32 #include "checkTools.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
37 (
38  const polyMesh& mesh,
39  const dictionary& dict,
40  const autoPtr<surfaceWriter>& writer
41 )
42 {
43  label noFailedChecks = 0;
44 
45  {
46  faceSet faces(mesh, "meshQualityFaces", mesh.nFaces()/100+1);
47  motionSmoother::checkMesh(false, mesh, dict, faces);
48 
49  label nFaces = returnReduce(faces.size(), sumOp<label>());
50 
51  if (nFaces > 0)
52  {
53  noFailedChecks++;
54 
55  Info<< " <<Writing " << nFaces
56  << " faces in error to set " << faces.name() << endl;
57  faces.instance() = mesh.pointsInstance();
58  faces.write();
59  if (writer.valid())
60  {
61  mergeAndWrite(writer(), faces);
62  }
63  }
64  }
65 
66  return noFailedChecks;
67 }
68 
69 
70 // ************************************************************************* //
Routines for checking mesh quality.
Tools for checking the mesh.
virtual Ostream & write(const char)=0
Write character.
bool checkMesh(const polyMesh &mesh, const bool report=false)
Check mesh for correctness. Returns false for no error.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
void mergeAndWrite(const polyMesh &mesh, const surfaceWriter &setWriter, const word &name, const indirectPrimitivePatch setPatch, const fileName &outputDir)
Generate merged surface on master and write. Needs input patch.
messageStream Info
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
label checkMeshQuality(const polyMesh &, const dictionary &, const autoPtr< surfaceWriter > &)
dictionary dict