polyMeshGenChecks.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh 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 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "polyMeshGenChecks.H"
27 #include "polyMeshGenAddressing.H"
28 #include "pyramidPointFaceRef.H"
29 #include "tetrahedron.H"
30 #include "cell.H"
31 #include "mathematicalConstants.H"
32 #include "ListOps.H"
33 #include "Map.H"
34 
35 # ifdef USE_OMP
36 #include <omp.h>
37 # endif
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 namespace Foam
42 {
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
47 {
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 bool checkGeometry(const polyMeshGen& mesh, const bool report)
52 {
53  label noFailedChecks(0);
54 
55  if( checkClosedBoundary(mesh, report) ) ++noFailedChecks;
56  if( checkClosedCells(mesh, report) ) ++noFailedChecks;
57  if( checkFaceAreas(mesh, report) ) ++noFailedChecks;
58  if( checkCellVolumes(mesh, report) ) ++noFailedChecks;
59  if( checkFaceDotProduct(mesh, report) ) ++noFailedChecks;
60  if( checkFaceUniformity(mesh, report) ) ++noFailedChecks;
61  if( checkFacePyramids(mesh, report) ) ++noFailedChecks;
62  if( checkFaceSkewness(mesh, report) ) ++noFailedChecks;
63  if( checkCellPartTetrahedra(mesh, report) ) ++noFailedChecks;
64 
65  if( noFailedChecks == 0 )
66  {
67  if( report )
68  Info << "Mesh geometry OK." << endl;
69 
70  return false;
71  }
72  else
73  {
74  Info<< "Failed " << noFailedChecks << " mesh geometry checks." << endl;
75 
76  return true;
77  }
78 }
79 
80 bool checkTopology(const polyMeshGen& mesh, const bool report)
81 {
82  label noFailedChecks(0);
83 
84  if( checkPoints(mesh, report) ) ++noFailedChecks;
85  if( checkUpperTriangular(mesh, report) ) ++noFailedChecks;
86  if( checkCellsZipUp(mesh, report) ) ++noFailedChecks;
87  if( checkFaceVertices(mesh, report) ) ++noFailedChecks;
88 
89  if( noFailedChecks == 0 )
90  {
91  if( report )
92  Info << "Mesh topology OK." << endl;
93 
94  return false;
95  }
96  else
97  {
98  Info<< "Failed " << noFailedChecks << " mesh topology checks." << endl;
99 
100  return true;
101  }
102 }
103 
104 bool checkMesh(const polyMeshGen& mesh, const bool report)
105 {
106  bool failedChecks = checkTopology(mesh, report);
107  failedChecks |= checkGeometry(mesh, report);
108 
109  if( !failedChecks )
110  {
111  if( report )
112  Info << "Mesh OK." << endl;
113 
114  return false;
115  }
116  else
117  {
118  Info << "Failed some mesh checks." << endl;
119 
120  return true;
121  }
122 }
123 
124 } // End namespace polyMeshGenChecks
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 } // End namespace Foam
129 
130 // ************************************************************************* //
Foam::polyMeshGenChecks::checkClosedBoundary
bool checkClosedBoundary(const polyMeshGen &, const bool report=false)
Check boundary closedness.
Definition: polyMeshGenChecksGeometry.C:45
mathematicalConstants.H
cell.H
Foam::polyMeshGenChecks::checkGeometry
bool checkGeometry(const polyMeshGen &mesh, const bool report)
Check mesh geometry (& implicitly topology) for correctness.
Definition: polyMeshGenChecks.C:51
Foam::polyMeshGenChecks::checkMesh
bool checkMesh(const polyMeshGen &mesh, const bool report)
Check mesh for correctness. Returns false for no error.
Definition: polyMeshGenChecks.C:104
Foam::polyMeshGenChecks::checkFaceSkewness
void checkFaceSkewness(const polyMeshGen &, scalarField &, const boolList *changedFacePtr=NULL)
Check face skewness.
Definition: polyMeshGenChecksGeometry.C:1138
polyMeshGenChecks
A set of functions used for mesh checking mesh quality.
Foam::polyMeshGenChecks::checkUpperTriangular
bool checkUpperTriangular(const polyMeshGen &, const bool report=false, labelHashSet *setPtr=NULL)
Check face ordering.
Definition: polyMeshGenChecksTopology.C:118
Foam::polyMeshGen
Definition: polyMeshGen.H:46
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::polyMeshGenChecks::checkFaceAreas
bool checkFaceAreas(const polyMeshGen &, const bool report=false, const scalar minFaceArea=VSMALL, labelHashSet *setPtr=NULL, const boolList *changedFacePtr=NULL)
Check for negative face areas.
Definition: polyMeshGenChecksGeometry.C:362
polyMeshGenChecks.H
Foam::polyMeshGenChecks::checkFaceVertices
bool checkFaceVertices(const polyMeshGen &, const bool report=false, labelHashSet *setPtr=NULL)
Check uniqueness of face vertices.
Definition: polyMeshGenChecksTopology.C:373
Map.H
Foam::label
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
Foam::Info
messageStream Info
Foam::polyMeshGenChecks::checkCellsZipUp
bool checkCellsZipUp(const polyMeshGen &, const bool report=false, labelHashSet *setPtr=NULL)
Check cell zip-up.
Definition: polyMeshGenChecksTopology.C:254
Foam::polyMeshGenChecks::checkFaceDotProduct
void checkFaceDotProduct(const polyMeshGen &, scalarField &, const boolList *changedFacePtr=NULL)
Check for non-orthogonality.
Definition: polyMeshGenChecksGeometry.C:630
Foam::polyMeshGenChecks::checkPoints
bool checkPoints(const polyMeshGen &, const bool report=false, labelHashSet *setPtr=NULL)
Check for unused points.
Definition: polyMeshGenChecksTopology.C:46
Foam::polyMeshGenChecks::checkCellPartTetrahedra
bool checkCellPartTetrahedra(const polyMeshGen &, const bool report=false, const scalar minPartTet=VSMALL, labelHashSet *setPtr=NULL, const boolList *changedFacePtr=NULL)
Definition: polyMeshGenChecksGeometry.C:467
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::polyMeshGenChecks::checkTopology
bool checkTopology(const polyMeshGen &mesh, const bool report)
Check mesh topology for correctness. Returns false for no error.
Definition: polyMeshGenChecks.C:80
Foam::polyMeshGenChecks::checkFacePyramids
bool checkFacePyramids(const polyMeshGen &, const bool report=false, const scalar minPyrVol=-SMALL, labelHashSet *setPtr=NULL, const boolList *changedFacePtr=NULL)
Check face pyramid volume.
Definition: polyMeshGenChecksGeometry.C:962
Foam::polyMeshGenChecks::checkFaceUniformity
void checkFaceUniformity(const polyMeshGen &, scalarField &, const boolList *changedFacePtr=NULL)
Check face uniformity.
Definition: polyMeshGenChecksGeometry.C:1381
Foam::polyMeshGenChecks::checkCellVolumes
bool checkCellVolumes(const polyMeshGen &, const bool report=false, labelHashSet *setPtr=NULL)
Check for negative cell volumes.
Definition: polyMeshGenChecksGeometry.C:294
ListOps.H
Various functions to operate on Lists.
polyMeshGenAddressing.H
pyramidPointFaceRef.H
Foam::polyMeshGenChecks::checkClosedCells
bool checkClosedCells(const polyMeshGen &, const bool report=false, const scalar aspectWarn=1000, labelHashSet *setPtr=NULL)
Check cells for closedness.
Definition: polyMeshGenChecksGeometry.C:113
tetrahedron.H