polyMeshGenChecks.H 8.71 KB
Newer Older
franjo's avatar
franjo committed
1
2
/*---------------------------------------------------------------------------*\
  =========                 |
Tomislav Lugaric's avatar
Tomislav Lugaric committed
3
  \\      /  F ield         | cfMesh: A library for mesh generation
franjo's avatar
franjo committed
4
   \\    /   O peration     |
Tomislav Lugaric's avatar
Tomislav Lugaric committed
5
6
    \\  /    A nd           | Author: Franjo Juretic (franjo.juretic@c-fields.com)
     \\/     M anipulation  | Copyright (C) Creative Fields, Ltd.
franjo's avatar
franjo committed
7
8
-------------------------------------------------------------------------------
License
Tomislav Lugaric's avatar
Tomislav Lugaric committed
9
    This file is part of cfMesh.
franjo's avatar
franjo committed
10

Tomislav Lugaric's avatar
Tomislav Lugaric committed
11
    cfMesh is free software; you can redistribute it and/or modify it
franjo's avatar
franjo committed
12
    under the terms of the GNU General Public License as published by the
Tomislav Lugaric's avatar
Tomislav Lugaric committed
13
    Free Software Foundation; either version 3 of the License, or (at your
franjo's avatar
franjo committed
14
15
    option) any later version.

Tomislav Lugaric's avatar
Tomislav Lugaric committed
16
    cfMesh is distributed in the hope that it will be useful, but WITHOUT
franjo's avatar
franjo committed
17
18
19
20
21
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
Tomislav Lugaric's avatar
Tomislav Lugaric committed
22
    along with cfMesh.  If not, see <http://www.gnu.org/licenses/>.
franjo's avatar
franjo committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

Class
    polyMeshGenChecks

Description
    A set of functions used for mesh checking mesh quality

SourceFiles
    polyMeshGenAddressingChecks.C

\*---------------------------------------------------------------------------*/

#ifndef polyMeshGenChecks_H
#define polyMeshGenChecks_H

#include "polyMeshGen.H"
#include "boolList.H"
#include "HashSet.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

/*---------------------------------------------------------------------------*\
            Namespace polyMeshGenChecks functions Declaration
\*---------------------------------------------------------------------------*/

namespace polyMeshGenChecks
{
53

franjo's avatar
franjo committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Check geometry
//- Check boundary closedness
bool checkClosedBoundary(const polyMeshGen&, const bool report = false);

//- Check cells for closedness
bool checkClosedCells
(
    const polyMeshGen&,
    const bool report = false,
    const scalar aspectWarn = 1000,
    labelHashSet* setPtr = NULL
);

//- Check for negative cell volumes
bool checkCellVolumes
(
    const polyMeshGen&,
    const bool report = false,
    labelHashSet* setPtr = NULL
);

//- Check for negative face areas
bool checkFaceAreas
(
    const polyMeshGen&,
    const bool report = false,
    const scalar minFaceArea = VSMALL,
    labelHashSet* setPtr = NULL,
    const boolList* changedFacePtr = NULL
);

85
86
87
88
89
90
91
92
93
94
95
96

//- Check quality of tetrahedra
bool checkTetQuality
(
    const polyMeshGen&,
    const bool report = false,
    const scalar minTetQuality = VSMALL,
    labelHashSet* setPtr = NULL,
    const boolList* changedFacePtr = NULL
);


Alen Cukrov's avatar
Alen Cukrov committed
97
98
99
100
101
102
103
104
105
106
//- Check minimum face twist
bool checkMinTwist
(
    const polyMeshGen&,
    const bool report = false,
    const scalar minTwist = VSMALL,
    labelHashSet* setPtr = NULL,
    const boolList* changedFacePtr = NULL
);

107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

//- Check the area of internal faces versus boundary faces
bool checkCellDeterminant
(
    const polyMeshGen&,
    const bool report = false,
    const scalar warnDet = 1e-3,
    labelHashSet* setPtr = NULL,
    const boolList* changedFacePtr = NULL
);

//- Check volume ratio
void checkMinVolRatio
(
    const polyMeshGen&,
    scalarField&,
    const boolList* changedFacePtr = NULL
);

bool checkMinVolRatio
(
    const polyMeshGen&,
    const bool report = false,
    const scalar warnVolRatio = 0.01,
    labelHashSet* setPtr = NULL,
    const boolList* changedFacePtr = NULL
);

//- Check face triangle twist
bool checkTriangleTwist
(
    const polyMeshGen&,
    const bool report = false,
    const scalar minTwist = VSMALL,
    labelHashSet* setPtr = NULL,
    const boolList* changedFacePtr = NULL
);

franjo's avatar
franjo committed
145
146
147
148
149
150
151
152
153
154
155
156
157
//- Check for negative part tetrahedra
//- Cells are decomposed into tetrahedra formed by
//- the cell centre, face centre and the edge vertices
bool checkCellPartTetrahedra
(
    const polyMeshGen&,
    const bool report = false,
    const scalar minPartTet = VSMALL,
    labelHashSet* setPtr = NULL,
    const boolList* changedFacePtr = NULL
);

//- Check for non-orthogonality
158
159
160
161
162
163
164
void checkFaceDotProduct
(
    const polyMeshGen&,
    scalarField&,
    const boolList* changedFacePtr = NULL
);

franjo's avatar
franjo committed
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
bool checkFaceDotProduct
(
    const polyMeshGen&,
    const bool report = false,
    const scalar nonOrthWarn = 70.0,
    labelHashSet* setPtr = NULL,
    const boolList* changedFacePtr = NULL
);

//- Check face pyramid volume
bool checkFacePyramids
(
    const polyMeshGen&,
    const bool report = false,
    const scalar minPyrVol = -SMALL,
    labelHashSet* setPtr = NULL,
    const boolList* changedFacePtr = NULL
);

//- Check face skewness
185
186
187
188
189
190
191
void checkFaceSkewness
(
    const polyMeshGen&,
    scalarField&,
    const boolList* changedFacePtr = NULL
);

franjo's avatar
franjo committed
192
193
194
195
196
197
198
199
200
201
bool checkFaceSkewness
(
    const polyMeshGen&,
    const bool report = false,
    const scalar warnSkew = 4.0,
    labelHashSet* setPtr = NULL,
    const boolList* changedFacePtr = NULL
);

//- Check face uniformity
202
203
204
205
206
207
208
void checkFaceUniformity
(
    const polyMeshGen&,
    scalarField&,
    const boolList* changedFacePtr = NULL
);

franjo's avatar
franjo committed
209
210
211
212
213
214
215
216
217
bool checkFaceUniformity
(
    const polyMeshGen&,
    const bool report = false,
    const scalar warnUniform = 0.1,
    labelHashSet* setPtr = NULL,
    const boolList* changedFacePtr = NULL
);

218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
//- check volume difference of neighbouring cells
void checkVolumeUniformity
(
    const polyMeshGen&,
    scalarField&,
    const boolList* changedFacePtr = NULL
);

bool checkVolumeUniformity
(
    const polyMeshGen&,
    const bool report = false,
    const scalar warnUniform = 0.1,
    labelHashSet* setPtr = NULL,
    const boolList* changedFacePtr = NULL
);

franjo's avatar
franjo committed
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
//- Check face angles
bool checkFaceAngles
(
    const polyMeshGen&,
    const bool report = false,
    const scalar maxDeg = 10,    // In degrees
    labelHashSet* setPtr = NULL,
    const boolList* changedFacePtr = NULL
);

//- Check face warpage: decompose face and check ratio between
//  magnitude of sum of triangle areas and sum of magnitude of
//  triangle areas.
bool checkFaceFlatness
(
    const polyMeshGen&,
    const bool report,
    const scalar warnFlatness,  // When to include in set.
253
    labelHashSet* setPtr = NULL,
franjo's avatar
franjo committed
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
    const boolList* changedFacePtr = NULL
);

// Checks using topology only

//- Check for unused points
bool checkPoints
(
    const polyMeshGen&,
    const bool report = false,
    labelHashSet* setPtr = NULL
);

//- Check face ordering
bool checkUpperTriangular
(
    const polyMeshGen&,
    const bool report = false,
    labelHashSet* setPtr = NULL
);

//- Check cell zip-up
bool checkCellsZipUp
(
    const polyMeshGen&,
    const bool report = false,
    labelHashSet* setPtr = NULL
);

//- Check uniqueness of face vertices
bool checkFaceVertices
(
    const polyMeshGen&,
    const bool report = false,
    labelHashSet* setPtr = NULL
);

//- Check mesh topology for correctness. Returns false for no error.
bool checkTopology(const polyMeshGen&, const bool report = false);

294
//- Check mesh geometry (& implicitly topology) for correctness.
franjo's avatar
franjo committed
295
296
297
298
299
//  Returns false for no error.
bool checkGeometry(const polyMeshGen&, const bool report = false);

//- Check mesh for correctness. Returns false for no error.
bool checkMesh(const polyMeshGen&, const bool report = false);
300

301
302
303
304
305
306
307
308
309
//- Read the user defined mesh quality settings
label findBadFacesAdditionalChecks
(
    const polyMeshGen& mesh,
    const bool report,
    labelHashSet& badFaces,
    const boolList* activeFacePtr = NULL
);

Franjo's avatar
Franjo committed
310
311
312
313
314
315
316
317
318
319
320
321
322
//- checks for bad faces making the mesh unusable
//- checks for negative pyramids and zero area faces
label findBadFacesRelaxed
(
    const polyMeshGen&,
    labelHashSet& badFaces,
    const bool report = false,
    const boolList* activeFacePtr = NULL
);

//- check mesh for bad faces which make the mesh invalid
//- checks for negative pyramids, face flatness,
//- zero area faces and negative tetrahedra
323
324
325
326
327
328
329
330
label findBadFaces
(
    const polyMeshGen&,
    labelHashSet& badFaces,
    const bool report = false,
    const boolList* activeFacePtr = NULL
);

Franjo's avatar
Franjo committed
331
332
//- check mesh for faces that may cause problems to the solver
//- checks for non-orthogonality and skewness
333
334
335
336
337
338
339
340
label findLowQualityFaces
(
    const polyMeshGen& mesh,
    labelHashSet& badFaces,
    const bool report = false,
    const boolList* activeFacePtr = NULL
);

341
342
343
344
345
346
347
348
349
350
//- checks the mesh and selects the faces with worst quality
label findWorstQualityFaces
(
    const polyMeshGen& mesh,
    labelHashSet& badFaces,
    const bool report = false,
    const boolList* activeFacePtr = NULL,
    const scalar relativeThreshold = 0.1
);

franjo's avatar
franjo committed
351
352
353
354
355
356
357
358
359
360
361
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //