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-2023 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 "meshCheck.H"
31 #include "surfaceWriter.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
36 (
37  const polyMesh& mesh,
38  const dictionary& dict,
39  const autoPtr<surfaceWriter>& writer
40 )
41 {
42  label noFailedChecks = 0;
43 
44  {
45  faceSet faces(mesh, "meshQualityFaces", mesh.nFaces()/100+1);
46  meshCheck::checkMesh(false, mesh, dict, faces);
47 
48  label nFaces = returnReduce(faces.size(), sumOp<label>());
49 
50  if (nFaces > 0)
51  {
52  noFailedChecks++;
53 
54  Info<< " <<Writing " << nFaces
55  << " faces in error to set " << faces.name() << endl;
56  faces.instance() = mesh.pointsInstance();
57  faces.write();
58  if (writer.valid())
59  {
60  meshCheck::mergeAndWrite(writer(), faces);
61  }
62  }
63  }
64 
65  return noFailedChecks;
66 }
67 
68 
69 // ************************************************************************* //
Routines for checking mesh quality.
virtual Ostream & write(const char)=0
Write character.
Functions for checking mesh topology and geometry.
bool checkMesh(const bool report, const polyMesh &mesh, const dictionary &dict, const labelList &checkFaces, const List< labelPair > &baffles, labelHashSet &wrongFaces)
Check (subset of mesh including baffles) with mesh settings in dict.
Definition: checkMesh.C:33
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.
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:257
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