All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
primitiveMeshCheck.H
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) 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 Namespace
25  Foam::meshCheck
26 
27 Description
28  Collection of functions checking primitiveMesh
29 
30 SourceFiles
31  primitiveMeshCheck.C
32 
33 \*---------------------------------------------------------------------------*/
34 #ifndef primitiveMeshCheck_H
35 #define primitiveMeshCheck_H
36 
37 #include "primitiveMesh.H"
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 namespace Foam
42 {
43 
44 /*---------------------------------------------------------------------------*\
45  Namespace meshCheck Declaration
46 \*---------------------------------------------------------------------------*/
47 
48 namespace meshCheck
49 {
50  // Topological checks
51 
52  //- Check face ordering
54  (
55  const primitiveMesh& mesh,
56  const bool report = false,
57  labelHashSet* setPtr = nullptr
58  );
59 
60  //- Check cell zip-up
61  bool checkCellsZipUp
62  (
63  const primitiveMesh& mesh,
64  const bool report = false,
65  labelHashSet* setPtr = nullptr
66  );
67 
68  //- Check uniqueness of face vertices
70  (
71  const primitiveMesh& mesh,
72  const bool report = false,
73  labelHashSet* setPtr = nullptr
74  );
75 
76  //- Check for unused points
77  bool checkPoints
78  (
79  const primitiveMesh& mesh,
80  const bool report = false,
81  labelHashSet* setPtr = nullptr
82  );
83 
84  //- Check if all points on face are shared with another face.
86  (
87  const primitiveMesh& mesh,
88  const label,
89  const Map<label>&,
90  label& nBaffleFaces,
92  );
93 
94  //- Check that shared points are in consecutive order.
95  bool checkCommonOrder
96  (
97  const primitiveMesh& mesh,
98  const label,
99  const Map<label>&,
100  labelHashSet*
101  );
102 
103  //- Check face-face connectivity
104  bool checkFaceFaces
105  (
106  const primitiveMesh& mesh,
107  const bool report = false,
108  labelHashSet* setPtr = nullptr
109  );
110 
111 
112  // Geometric checks
113 
114  //- Generate non-orthogonality field (internal faces only)
115  tmp<scalarField> faceOrthogonality
116  (
117  const primitiveMesh& mesh,
118  const vectorField& fAreas,
119  const vectorField& cellCtrs
120  );
121 
122  //- Generate face pyramid volume fields
123  void facePyramidVolume
124  (
125  const primitiveMesh& mesh,
126  const pointField& points,
127  const vectorField& cellCtrs,
128  scalarField& ownPyrVol,
129  scalarField& neiPyrVol
130  );
131 
132  //- Generate skewness field
133  tmp<scalarField> faceSkewness
134  (
135  const primitiveMesh& mesh,
136  const pointField& points,
137  const vectorField& fCtrs,
138  const vectorField& fAreas,
139  const vectorField& cellCtrs
140  );
141 
142  //- Generate cell openness and cell aspect ratio field
143  void cellClosedness
144  (
145  const primitiveMesh& mesh,
146  const Vector<label>& meshD,
147  const vectorField& areas,
148  const scalarField& vols,
149  scalarField& openness,
150  scalarField& aratio
151  );
152 
153  //- Generate face concavity field. Returns per face the (sin of the)
154  // most concave angle between two consecutive edges
155  tmp<scalarField> faceConcavity
156  (
157  const scalar maxSin,
158  const primitiveMesh& mesh,
159  const pointField& p,
160  const vectorField& faceAreas
161  );
162 
163  //- Generate face flatness field. Compares the individual triangles'
164  // normals against the face average normal. Between 0 (fully warped)
165  // and 1 (fully flat)
166  tmp<scalarField> faceFlatness
167  (
168  const primitiveMesh& mesh,
169  const pointField& p,
170  const vectorField& fCtrs,
171  const vectorField& faceAreas
172  );
173 
174  //- Generate edge alignment field. Is per face the minimum aligned edge
175  // (does not use edge addressing)
177  (
178  const primitiveMesh& mesh,
179  const Vector<label>& directions,
180  const pointField& p
181  );
182 
183  //- Generate cell determinant field
185  (
186  const primitiveMesh& mesh,
187  const Vector<label>& directions,
188  const vectorField& faceAreas,
189  const PackedBoolList& internalOrCoupledFace
190  );
191 
192 
193  // Helpers: single face check
194 
195  //- Skewness of single face
196  scalar faceSkewness
197  (
198  const primitiveMesh& mesh,
199  const pointField& p,
200  const vectorField& fCtrs,
201  const vectorField& fAreas,
202 
203  const label facei,
204  const point& ownCc,
205  const point& neiCc
206  );
207 
208  //- Skewness of single boundary face
209  scalar boundaryFaceSkewness
210  (
211  const primitiveMesh& mesh,
212  const pointField& p,
213  const vectorField& fCtrs,
214  const vectorField& fAreas,
215 
216  const label facei,
217  const point& ownCc
218  );
219 
220  //- Orthogonality of single face
221  scalar faceOrthogonality
222  (
223  const point& ownCc,
224  const point& neiCc,
225  const vector& s
226  );
227 
228  //- Check boundary for closedness
230  (
231  const primitiveMesh& mesh,
232  const scalar closedThreshold,
233  const bool report = false
234  );
235 
236  //- Check cells for closedness
237  bool checkClosedCells
238  (
239  const primitiveMesh& mesh,
240  const scalar closedThreshold,
241  const scalar aspectThreshold,
242  const bool report = false,
243  labelHashSet* setPtr = nullptr,
244  labelHashSet* highAspectSetPtr = nullptr,
245  const Vector<label>& solutionD = Vector<label>::one
246  );
247 
248  //- Check for negative face areas
249  bool checkFaceAreas
250  (
251  const primitiveMesh& mesh,
252  const bool report = false,
253  labelHashSet* setPtr = nullptr
254  );
255 
256  //- Check for negative cell volumes
257  bool checkCellVolumes
258  (
259  const primitiveMesh& mesh,
260  const bool report = false,
261  labelHashSet* setPtr = nullptr
262  );
263 
264  //- Check face pyramid volume
265  bool checkFacePyramids
266  (
267  const primitiveMesh& mesh,
268  const bool report = false,
269  const scalar minPyrVol = -small,
270  labelHashSet* setPtr = nullptr
271  );
272 
273  //- Check face angles
274  bool checkFaceAngles
275  (
276  const primitiveMesh& mesh,
277  const bool report = false,
278  const scalar maxSin = 10, // In degrees
279  labelHashSet* setPtr = nullptr
280  );
281 
282  //- Check face warpage: decompose face and check ratio between
283  // magnitude of sum of triangle areas and sum of magnitude of
284  // triangle areas.
285  bool checkFaceFlatness
286  (
287  const primitiveMesh& mesh,
288  const bool report,
289  const scalar warnFlatness, // When to include in set.
290  labelHashSet* setPtr
291  );
292 
293  //- Check for point-point-nearness,
294  // e.g. colocated points which may be part of baffles.
295  bool checkPointNearness
296  (
297  const primitiveMesh& mesh,
298  const bool report,
299  const scalar reportDistSqr,
300  labelHashSet* setPtr = nullptr
301  );
302 
303  //- Check edge length
304  bool checkEdgeLength
305  (
306  const primitiveMesh& mesh,
307  const bool report,
308  const scalar minLenSqr,
309  labelHashSet* setPtr = nullptr
310  );
311 
312  //- Check for concave cells by the planes of faces
313  bool checkConcaveCells
314  (
315  const primitiveMesh& mesh,
316  const scalar planarCosAngle,
317  const bool report = false,
318  labelHashSet* setPtr = nullptr
319  );
320 }
321 
322 
323 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
324 
325 } // End namespace Foam
326 
327 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328 
329 #endif
330 
331 // ************************************************************************* //
A bit-packed bool list.
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
Definition: directions.H:67
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
A class for managing temporary objects.
Definition: tmp.H:55
const pointField & points
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
tmp< scalarField > faceConcavity(const scalar maxSin, const primitiveMesh &mesh, const pointField &p, const vectorField &faceAreas)
Generate face concavity field. Returns per face the (sin of the)
void cellClosedness(const primitiveMesh &mesh, const Vector< label > &meshD, const vectorField &areas, const scalarField &vols, scalarField &openness, scalarField &aratio)
Generate cell openness and cell aspect ratio field.
bool checkFacePyramids(const bool report, const scalar minPyrVol, const polyMesh &, const vectorField &cellCentres, const pointField &p, const labelList &checkFaces, const List< labelPair > &baffles, labelHashSet *)
Check face pyramid volumes.
tmp< scalarField > faceOrthogonality(const polyMesh &mesh, const vectorField &fAreas, const vectorField &cellCtrs)
Generate orthogonality field. (1 for fully orthogonal, < 1 for.
Definition: polyMeshCheck.C:34
tmp< scalarField > faceSkewness(const polyMesh &mesh, const pointField &points, const vectorField &fCtrs, const vectorField &fAreas, const vectorField &cellCtrs)
Generate skewness field.
Definition: polyMeshCheck.C:89
bool checkFaceFaces(const primitiveMesh &mesh, const bool report=false, labelHashSet *setPtr=nullptr)
Check face-face connectivity.
bool checkUpperTriangular(const primitiveMesh &mesh, const bool report=false, labelHashSet *setPtr=nullptr)
Check face ordering.
bool checkEdgeLength(const primitiveMesh &mesh, const bool report, const scalar minLenSqr, labelHashSet *setPtr=nullptr)
Check edge length.
bool checkConcaveCells(const primitiveMesh &mesh, const scalar planarCosAngle, const bool report=false, labelHashSet *setPtr=nullptr)
Check for concave cells by the planes of faces.
bool checkPointNearness(const primitiveMesh &mesh, const bool report, const scalar reportDistSqr, labelHashSet *setPtr=nullptr)
Check for point-point-nearness,.
bool checkFaceAngles(const bool report, const scalar maxConcave, const polyMesh &mesh, const vectorField &faceAreas, const pointField &p, const labelList &checkFaces, labelHashSet *setPtr)
Check convexity of angles in a face. See primitiveMesh for explanation.
bool checkDuplicateFaces(const primitiveMesh &mesh, const label, const Map< label > &, label &nBaffleFaces, labelHashSet *)
Check if all points on face are shared with another face.
bool checkFaceVertices(const primitiveMesh &mesh, const bool report=false, labelHashSet *setPtr=nullptr)
Check uniqueness of face vertices.
scalar boundaryFaceSkewness(const primitiveMesh &mesh, const pointField &p, const vectorField &fCtrs, const vectorField &fAreas, const label facei, const point &ownCc)
Skewness of single boundary face.
bool checkClosedCells(const primitiveMesh &mesh, const scalar closedThreshold, const scalar aspectThreshold, const bool report=false, labelHashSet *setPtr=nullptr, labelHashSet *highAspectSetPtr=nullptr, const Vector< label > &solutionD=Vector< label >::one)
Check cells for closedness.
bool checkCommonOrder(const primitiveMesh &mesh, const label, const Map< label > &, labelHashSet *)
Check that shared points are in consecutive order.
void facePyramidVolume(const primitiveMesh &mesh, const pointField &points, const vectorField &cellCtrs, scalarField &ownPyrVol, scalarField &neiPyrVol)
Generate face pyramid volume fields.
tmp< scalarField > cellDeterminant(const primitiveMesh &mesh, const Vector< label > &directions, const vectorField &faceAreas, const PackedBoolList &internalOrCoupledFace)
Generate cell determinant field.
tmp< scalarField > faceFlatness(const primitiveMesh &mesh, const pointField &p, const vectorField &fCtrs, const vectorField &faceAreas)
Generate face flatness field. Compares the individual triangles'.
bool checkClosedBoundary(const primitiveMesh &mesh, const scalar closedThreshold, const bool report=false)
Check boundary for closedness.
tmp< scalarField > edgeAlignment(const primitiveMesh &mesh, const Vector< label > &directions, const pointField &p)
Generate edge alignment field. Is per face the minimum aligned edge.
bool checkFaceFlatness(const bool report, const scalar minFlatness, const polyMesh &, const vectorField &faceAreas, const vectorField &faceCentres, const pointField &p, const labelList &checkFaces, labelHashSet *setPtr)
Check for face areas v.s. sum of face-triangle (from face-centre.
bool checkCellVolumes(const primitiveMesh &mesh, const bool report=false, labelHashSet *setPtr=nullptr)
Check for negative cell volumes.
bool checkFaceAreas(const primitiveMesh &mesh, const bool report=false, labelHashSet *setPtr=nullptr)
Check for negative face areas.
bool checkPoints(const primitiveMesh &mesh, const bool report=false, labelHashSet *setPtr=nullptr)
Check for unused points.
bool checkCellsZipUp(const primitiveMesh &mesh, const bool report=false, labelHashSet *setPtr=nullptr)
Check cell zip-up.
Namespace for OpenFOAM.
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
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< vector > vectorField
Specialisation of Field<T> for vector.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
Definition: HashSet.H:213
volScalarField & p