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
surfMesh
MeshedSurface
MeshedSurface.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
Class
25
Foam::MeshedSurface
26
27
Description
28
A surface geometry mesh with zone information, not to be confused with
29
the similarly named surfaceMesh, which actually refers to the cell faces
30
of a volume mesh.
31
32
A MeshedSurface can have zero or more surface zones (roughly equivalent
33
to faceZones for a polyMesh). If surface zones are defined, they must
34
be contiguous and cover all of the faces.
35
36
The MeshedSurface is intended for surfaces from a variety of sources.
37
- A set of points and faces without any surface zone information.
38
- A set of points and faces with randomly ordered zone information.
39
This could arise, for example, from reading external file formats
40
such as STL, etc.
41
42
SourceFiles
43
MeshedSurface.C
44
45
\*---------------------------------------------------------------------------*/
46
47
#ifndef MeshedSurface_H
48
#define MeshedSurface_H
49
50
#include <
OpenFOAM/PrimitivePatch_.H
>
51
#include <
OpenFOAM/PatchTools.H
>
52
#include <
OpenFOAM/pointField.H
>
53
#include <
OpenFOAM/face.H
>
54
#include <
OpenFOAM/triFace.H
>
55
56
#include <
surfMesh/surfZoneList.H
>
57
#include <
surfMesh/surfaceFormatsCore.H
>
58
#include <
OpenFOAM/runTimeSelectionTables.H
>
59
#include <
OpenFOAM/memberFunctionSelectionTables.H
>
60
#include <
OpenFOAM/HashSet.H
>
61
62
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63
64
namespace
Foam
65
{
66
67
// Forward declaration of friend functions and operators
68
69
class
Time;
70
class
surfMesh;
71
class
polyBoundaryMesh;
72
73
template
<
class
Face>
class
MeshedSurface;
74
template
<
class
Face>
class
MeshedSurfaceProxy;
75
template
<
class
Face>
class
UnsortedMeshedSurface;
76
77
/*---------------------------------------------------------------------------*\
78
Class MeshedSurface Declaration
79
\*---------------------------------------------------------------------------*/
80
81
template
<
class
Face>
82
class
MeshedSurface
83
:
84
public
PrimitivePatch
<Face, ::Foam::List, pointField, point>,
85
public
fileFormats::surfaceFormatsCore
86
{
87
// friends - despite different face representationsx
88
template
<
class
Face2>
friend
class
MeshedSurface
;
89
template
<
class
Face2>
friend
class
UnsortedMeshedSurface
;
90
friend
class
surfMesh
;
91
92
private
:
93
94
//- Private typedefs for convenience
95
96
typedef
PrimitivePatch
97
<
98
Face,
99
::Foam::List
,
100
pointField
,
101
point
102
>
103
ParentType
;
104
105
typedef
UnsortedMeshedSurface<Face>
FriendType
;
106
typedef
MeshedSurfaceProxy<Face>
ProxyType
;
107
108
// Private Member Data
109
110
//- Zone information
111
// (face ordering nFaces/startFace only used during reading/writing)
112
List<surfZone>
zones_;
113
114
115
// Private member functions
116
117
protected
:
118
119
// Protected Member functions
120
121
//- Transfer points/zones and transcribe face -> triFace
122
void
transcribe
(
MeshedSurface<face>
&);
123
124
//- basic sanity check on zones
125
void
checkZones
();
126
127
//- Non-const access to global points
128
pointField
&
storedPoints
()
129
{
130
return
const_cast<
pointField
&
>
(
ParentType::points
());
131
}
132
133
//- Non-const access to the faces
134
List<Face>
&
storedFaces
()
135
{
136
return
static_cast<
List<Face>
&
>
(*this);
137
}
138
139
//- Non-const access to the zones
140
surfZoneList
&
storedZones
()
141
{
142
return
zones_;
143
}
144
145
//- sort faces by zones and store sorted faces
146
void
sortFacesAndStore
147
(
148
const
Xfer
<
List<Face>
>& unsortedFaces,
149
const
Xfer
<
List<label>
>& zoneIds,
150
const
bool
sorted
151
);
152
153
//- Set new zones from faceMap
154
virtual
void
remapFaces
(
const
UList<label>
& faceMap);
155
156
public
:
157
158
//- Runtime type information
159
ClassName
(
"MeshedSurface"
);
160
161
// Static
162
163
//- Face storage only handles triangulated faces
164
inline
static
bool
isTri
();
165
166
//- Can we read this file format?
167
static
bool
canRead
(
const
fileName
&,
const
bool
verbose=
false
);
168
169
//- Can we read this file format?
170
static
bool
canReadType
(
const
word
& ext,
const
bool
verbose=
false
);
171
172
//- Can we write this file format?
173
static
bool
canWriteType
(
const
word
& ext,
const
bool
verbose=
false
);
174
175
static
wordHashSet
readTypes
();
176
static
wordHashSet
writeTypes
();
177
178
// Constructors
179
180
//- Construct null
181
MeshedSurface
();
182
183
//- Construct by transferring components (points, faces, zones).
184
MeshedSurface
185
(
186
const
Xfer< pointField >
&,
187
const
Xfer
<
List<Face>
>&,
188
const
Xfer< surfZoneList >
&
189
);
190
191
//- Construct by transferring components (points, faces).
192
// Use zone information if available
193
MeshedSurface
194
(
195
const
Xfer< pointField >
&,
196
const
Xfer
<
List<Face>
>&,
197
const
UList<label>
& zoneSizes =
UList<label>
(),
198
const
UList<word>
& zoneNames =
UList<word>
()
199
);
200
201
//- Construct as copy
202
MeshedSurface
(
const
MeshedSurface
&);
203
204
//- Construct from a UnsortedMeshedSurface
205
MeshedSurface
(
const
UnsortedMeshedSurface<Face>
&);
206
207
//- Construct from a boundary mesh with local points/faces
208
MeshedSurface
209
(
210
const
polyBoundaryMesh
&,
211
const
bool
globalPoints
=
false
212
);
213
214
//- Construct from a surfMesh
215
MeshedSurface
(
const
surfMesh
&);
216
217
//- Construct by transferring the contents from a UnsortedMeshedSurface
218
MeshedSurface
(
const
Xfer
<
UnsortedMeshedSurface<Face>
>&);
219
220
//- Construct by transferring the contents from a MeshedSurface
221
MeshedSurface
(
const
Xfer
<
MeshedSurface<Face>
>&);
222
223
//- Construct from file name (uses extension to determine type)
224
MeshedSurface
(
const
fileName
&);
225
226
//- Construct from file name (uses extension to determine type)
227
MeshedSurface
(
const
fileName
&,
const
word
& ext);
228
229
//- Construct from database
230
MeshedSurface
(
const
Time
&,
const
word
& surfName=
""
);
231
232
// Declare run-time constructor selection table
233
234
declareRunTimeSelectionTable
235
(
236
autoPtr
,
237
MeshedSurface
,
238
fileExtension,
239
(
240
const
fileName
&
name
241
),
242
(name)
243
);
244
245
// Selectors
246
247
//- Select constructed from filename (explicit extension)
248
static
autoPtr<MeshedSurface>
New
249
(
250
const
fileName
&,
251
const
word
& ext
252
);
253
254
//- Select constructed from filename (implicit extension)
255
static
autoPtr<MeshedSurface>
New
(
const
fileName
&);
256
257
// Destructor
258
259
virtual
~MeshedSurface
();
260
261
262
// Member Function Selectors
263
264
declareMemberFunctionSelectionTable
265
(
266
void
,
267
UnsortedMeshedSurface
,
268
write
,
269
fileExtension,
270
(
271
const
fileName
& name,
272
const
MeshedSurface<Face>
& surf
273
),
274
(name, surf)
275
);
276
277
//- Write to file
278
static
void
write
(
const
fileName
&,
const
MeshedSurface<Face>
&);
279
280
281
// Member Functions
282
283
// Access
284
285
//- The surface size is the number of faces
286
label
size
()
const
287
{
288
return
ParentType::size
();
289
}
290
291
//- Return const access to the faces
292
inline
const
List<Face>
&
faces
()
const
293
{
294
return
static_cast<
const
List<Face>
&
>
(*this);
295
}
296
297
//- Const access to the surface zones.
298
// If zones are defined, they must be contiguous and cover the entire
299
// surface.
300
const
List<surfZone>
&
surfZones
()
const
301
{
302
return
zones_;
303
}
304
305
//- Add surface zones
306
virtual
void
addZones
307
(
308
const
UList<surfZone>
&,
309
const
bool
cullEmpty=
false
310
);
311
312
//- Add surface zones
313
virtual
void
addZones
314
(
315
const
UList<label>
& sizes,
316
const
UList<word>
& names,
317
const
bool
cullEmpty=
false
318
);
319
320
//- Add surface zones
321
virtual
void
addZones
322
(
323
const
UList<label>
& sizes,
324
const
bool
cullEmpty=
false
325
);
326
327
//- Remove surface zones
328
virtual
void
removeZones
();
329
330
331
// Edit
332
333
//- Clear all storage
334
virtual
void
clear
();
335
336
//- Move points
337
virtual
void
movePoints
(
const
pointField
&);
338
339
//- Scale points. A non-positive factor is ignored
340
virtual
void
scalePoints
(
const
scalar&);
341
342
//- Reset primitive data (points, faces and zones)
343
// Note, optimized to avoid overwriting data (with Xfer::null)
344
virtual
void
reset
345
(
346
const
Xfer< pointField >
&
points
,
347
const
Xfer
<
List<Face>
>&
faces
,
348
const
Xfer< surfZoneList >
& zones
349
);
350
351
//- Reset primitive data (points, faces and zones)
352
// Note, optimized to avoid overwriting data (with Xfer::null)
353
virtual
void
reset
354
(
355
const
Xfer
<
List<point>
>&
points
,
356
const
Xfer
<
List<Face>
>&
faces
,
357
const
Xfer< surfZoneList >
& zones
358
);
359
360
//- Remove invalid faces
361
virtual
void
cleanup
(
const
bool
verbose);
362
363
virtual
bool
stitchFaces
364
(
365
const
scalar tol=SMALL,
366
const
bool
verbose=
false
367
);
368
369
virtual
bool
checkFaces
370
(
371
const
bool
verbose=
false
372
);
373
374
//- Triangulate in-place, returning the number of triangles added
375
virtual
label
triangulate
();
376
377
//- Triangulate in-place, returning the number of triangles added
378
// and setting a map of original face Ids.
379
// The faceMap is zero-sized when no triangulation was done.
380
virtual
label
triangulate
(
List<label>
& faceMap);
381
382
383
//- Return new surface.
384
// Returns return pointMap, faceMap from subsetMeshMap
385
MeshedSurface
subsetMesh
386
(
387
const
labelHashSet
& include,
388
labelList
& pointMap,
389
labelList
& faceMap
390
)
const
;
391
392
//- Return new surface.
393
MeshedSurface
subsetMesh
394
(
395
const
labelHashSet
& include
396
)
const
;
397
398
//- Transfer the contents of the argument and annull the argument
399
void
transfer
(
MeshedSurface<Face>
&);
400
401
//- Transfer the contents of the argument and annull the argument
402
void
transfer
(
UnsortedMeshedSurface<Face>
&);
403
404
//- Transfer contents to the Xfer container
405
Xfer< MeshedSurface<Face>
>
xfer
();
406
407
// Read
408
409
//- Read from file. Chooses reader based on explicit extension
410
bool
read
(
const
fileName
&,
const
word
& ext);
411
412
//- Read from file. Chooses reader based on detected extension
413
virtual
bool
read
(
const
fileName
&);
414
415
416
// Write
417
418
void
writeStats
(
Ostream
& os)
const
;
419
420
//- Generic write routine. Chooses writer based on extension.
421
virtual
void
write
(
const
fileName
& name)
const
422
{
423
write
(name, *
this
);
424
}
425
426
//- Write to database
427
void
write
(
const
Time
&,
const
word
& surfName=
""
)
const
;
428
429
430
// Member operators
431
432
void
operator=
(
const
MeshedSurface<Face>
&);
433
434
//- Conversion operator to MeshedSurfaceProxy
435
operator
MeshedSurfaceProxy<Face>
()
const
;
436
437
};
438
439
440
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
441
442
//- Specialization for holding triangulated information
443
template
<>
444
inline
bool
MeshedSurface<triFace>::isTri
()
445
{
446
return
true
;
447
}
448
449
//- Specialization for holding triangulated information
450
template
<>
451
inline
label
MeshedSurface<triFace>::triangulate
()
452
{
453
return
0;
454
}
455
456
//- Specialization for holding triangulated information
457
template
<>
458
inline
label
MeshedSurface<triFace>::triangulate
(
List<label>
& faceMap)
459
{
460
if
(&faceMap)
461
{
462
faceMap.
clear
();
463
}
464
465
return
0;
466
}
467
468
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
469
470
}
// End namespace Foam
471
472
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
473
474
#ifdef NoRepository
475
# include "
MeshedSurface.C
"
476
#endif
477
478
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
479
480
#endif
481
482
// ************************ vim: set sw=4 sts=4 et: ************************ //