Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
meshTools
meshTools
meshTools.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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::meshTools
26
27
Description
28
Collection of static functions to do various simple mesh related things.
29
30
SourceFiles
31
meshTools.C
32
33
\*---------------------------------------------------------------------------*/
34
35
#ifndef meshTools_H
36
#define meshTools_H
37
38
#include <
OpenFOAM/label.H
>
39
#include <
OpenFOAM/vector.H
>
40
#include <
OpenFOAM/labelList.H
>
41
#include <
OpenFOAM/pointField.H
>
42
#include <
OpenFOAM/faceList.H
>
43
#include <
OpenFOAM/cellList.H
>
44
#include <
OpenFOAM/primitivePatch.H
>
45
46
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48
namespace
Foam
49
{
50
51
class
primitiveMesh;
52
class
polyMesh;
53
54
/*---------------------------------------------------------------------------*\
55
Namespace meshTools Declaration
56
\*---------------------------------------------------------------------------*/
57
58
namespace
meshTools
59
{
60
// Bit identifiers for octants (p=plus, m=min e.g. plusXminYminZ)
61
62
static
const
label
mXmYmZ
= 0;
63
static
const
label
pXmYmZ
= 1;
64
static
const
label
mXpYmZ
= 2;
65
static
const
label
pXpYmZ
= 3;
66
67
static
const
label
mXmYpZ
= 4;
68
static
const
label
pXmYpZ
= 5;
69
static
const
label
mXpYpZ
= 6;
70
static
const
label
pXpYpZ
= 7;
71
72
static
const
label
mXmYmZMask
= 1 <<
mXmYmZ
;
73
static
const
label
pXmYmZMask
= 1 <<
pXmYmZ
;
74
static
const
label
mXpYmZMask
= 1 <<
mXpYmZ
;
75
static
const
label
pXpYmZMask
= 1 <<
pXpYmZ
;
76
77
static
const
label
mXmYpZMask
= 1 <<
mXmYpZ
;
78
static
const
label
pXmYpZMask
= 1 <<
pXmYpZ
;
79
static
const
label
mXpYpZMask
= 1 <<
mXpYpZ
;
80
static
const
label
pXpYpZMask
= 1 <<
pXpYpZ
;
81
82
83
// Normal handling
84
85
//- Check if n is in same direction as normals of all faceLabels
86
bool
visNormal
87
(
88
const
vector
& n,
89
const
vectorField
& faceNormals,
90
const
labelList
& faceLabels
91
);
92
93
//- Calculate point normals on a 'box' mesh (all edges aligned with
94
// coordinate axes)
95
vectorField
calcBoxPointNormals
(
const
primitivePatch
& pp);
96
97
//- Normalized edge vector
98
vector
normEdgeVec
(
const
primitiveMesh
&,
const
label edgeI);
99
100
101
// OBJ writing
102
103
//- Write obj representation of point
104
void
writeOBJ
105
(
106
Ostream
& os,
107
const
point
& pt
108
);
109
110
//- Write obj representation of faces subset
111
void
writeOBJ
112
(
113
Ostream
& os,
114
const
faceList
&,
115
const
pointField
&,
116
const
labelList
& faceLabels
117
);
118
119
//- Write obj representation of faces
120
void
writeOBJ
121
(
122
Ostream
& os,
123
const
faceList
&,
124
const
pointField
&
125
);
126
127
//- Write obj representation of cell subset
128
void
writeOBJ
129
(
130
Ostream
& os,
131
const
cellList
&,
132
const
faceList
&,
133
const
pointField
&,
134
const
labelList
& cellLabels
135
);
136
137
138
// Cell/face/edge walking
139
140
//- Is edge used by cell
141
bool
edgeOnCell
142
(
143
const
primitiveMesh
&,
144
const
label cellI,
145
const
label edgeI
146
);
147
148
//- Is edge used by face
149
bool
edgeOnFace
150
(
151
const
primitiveMesh
&,
152
const
label faceI,
153
const
label edgeI
154
);
155
156
//- Is face used by cell
157
bool
faceOnCell
158
(
159
const
primitiveMesh
&,
160
const
label cellI,
161
const
label faceI
162
);
163
164
//- Return edge among candidates that uses the two vertices.
165
label
findEdge
166
(
167
const
edgeList
& edges,
168
const
labelList
& candidates,
169
const
label v0,
170
const
label
v1
171
);
172
173
//- Return edge between two vertices. Returns -1 if no edge.
174
label
findEdge
175
(
176
const
primitiveMesh
&,
177
const
label v0,
178
const
label
v1
179
);
180
181
//- Return edge shared by two faces. Throws error if no edge found.
182
label
getSharedEdge
183
(
184
const
primitiveMesh
&,
185
const
label f0,
186
const
label f1
187
);
188
189
//- Return face shared by two cells. Throws error if none found.
190
label
getSharedFace
191
(
192
const
primitiveMesh
&,
193
const
label cell0,
194
const
label cell1
195
);
196
197
//- Get faces on cell using edgeI. Throws error if no two found.
198
void
getEdgeFaces
199
(
200
const
primitiveMesh
&,
201
const
label cellI,
202
const
label edgeI,
203
label& face0,
204
label& face1
205
);
206
207
//- Return label of other edge (out of candidates edgeLabels)
208
// connected to vertex but not edgeI. Throws error if none found.
209
label
otherEdge
210
(
211
const
primitiveMesh
&,
212
const
labelList
& edgeLabels,
213
const
label edgeI,
214
const
label vertI
215
);
216
217
//- Return face on cell using edgeI but not faceI. Throws error
218
// if none found.
219
label
otherFace
220
(
221
const
primitiveMesh
&,
222
const
label cellI,
223
const
label faceI,
224
const
label edgeI
225
);
226
227
//- Return cell on other side of face. Throws error
228
// if face not internal.
229
label
otherCell
230
(
231
const
primitiveMesh
&,
232
const
label cellI,
233
const
label faceI
234
);
235
236
//- Returns label of edge nEdges away from startEdge (in the direction
237
// of startVertI)
238
label
walkFace
239
(
240
const
primitiveMesh
&,
241
const
label faceI,
242
const
label startEdgeI,
243
const
label startVertI,
244
const
label nEdges
245
);
246
247
248
// Constraints on position
249
250
//- Set the constrained components of position to mesh centre
251
void
constrainToMeshCentre
252
(
253
const
polyMesh
&
mesh
,
254
point
& pt
255
);
256
void
constrainToMeshCentre
257
(
258
const
polyMesh
&
mesh
,
259
pointField
& pt
260
);
261
262
//- Set the constrained components of directions/velocity to zero
263
void
constrainDirection
264
(
265
const
polyMesh
&
mesh
,
266
const
Vector<label>
& dirs,
267
vector
&
d
268
);
269
void
constrainDirection
270
(
271
const
polyMesh
&
mesh
,
272
const
Vector<label>
& dirs,
273
vectorField
&
d
274
);
275
276
277
// Hex only functionality.
278
279
//- Given edge on hex find other 'parallel', non-connected edges.
280
void
getParallelEdges
281
(
282
const
primitiveMesh
&,
283
const
label cellI,
284
const
label e0,
285
label&,
286
label&,
287
label&
288
);
289
290
//- Given edge on hex find all 'parallel' (i.e. non-connected)
291
// edges and average direction of them
292
vector
edgeToCutDir
293
(
294
const
primitiveMesh
&,
295
const
label cellI,
296
const
label edgeI
297
);
298
299
//- Reverse of edgeToCutDir: given direction find edge bundle and
300
// return one of them.
301
label
cutDirToEdge
302
(
303
const
primitiveMesh
&,
304
const
label cellI,
305
const
vector
& cutDir
306
);
307
308
}
// End namespace meshTools
309
310
311
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312
313
}
// End namespace Foam
314
315
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316
317
#endif
318
319
// ************************ vim: set sw=4 sts=4 et: ************************ //