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
conversion
meshReader
meshReader.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::meshReaders
26
27
Description
28
A namespace for holding various types of mesh readers.
29
30
31
Class
32
Foam::meshReader
33
34
Description
35
This class supports creating polyMeshes with baffles.
36
37
The derived classes are responsible for providing the protected data.
38
This implementation is somewhat messy, but could/should be restructured
39
to provide a more generalized reader (at the moment it has been written
40
for converting pro-STAR data).
41
42
The meshReader supports cellTable information (see new user's guide entry).
43
44
Note
45
The boundary definitions are given as cell/face.
46
47
SourceFiles
48
calcPointCells.C
49
createPolyBoundary.C
50
createPolyCells.C
51
meshReader.C
52
meshReaderAux.C
53
54
\*---------------------------------------------------------------------------*/
55
56
#ifndef meshReader_H
57
#define meshReader_H
58
59
#include <
OpenFOAM/polyMesh.H
>
60
#include <
OpenFOAM/HashTable.H
>
61
#include <
OpenFOAM/IOstream.H
>
62
63
#include <
conversion/cellTable.H
>
64
65
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66
67
namespace
Foam
68
{
69
70
/*---------------------------------------------------------------------------*\
71
Class meshReader Declaration
72
\*---------------------------------------------------------------------------*/
73
74
class
meshReader
75
{
76
protected
:
77
78
//- Identify cell faces in terms of cell Id and face Id
79
class
cellFaceIdentifier
80
{
81
public
:
82
// Public data
83
84
//- Cell Id
85
label
cell
;
86
87
//- Face Id
88
label
face
;
89
90
91
// Constructors
92
93
//- Construct null
94
cellFaceIdentifier
() :
cell
(-1),
face
(-1) {}
95
96
//- Construct from cell/face components
97
cellFaceIdentifier
(label c, label
f
) :
cell
(c),
face
(f) {}
98
99
100
// Check
101
102
//- Used if cell or face are non-negative
103
bool
used
()
const
104
{
105
return
(
cell
>= 0 &&
face
>= 0);
106
}
107
108
//- Unused if cell or face are negative
109
bool
unused
()
const
110
{
111
return
(
cell
< 0 ||
face
< 0);
112
}
113
114
115
// Member Operators
116
117
bool
operator!=
(
const
cellFaceIdentifier
& cf)
const
118
{
119
return
(
cell
!= cf.
cell
||
face
!= cf.
face
);
120
}
121
122
bool
operator==
(
const
cellFaceIdentifier
& cf)
const
123
{
124
return
(
cell
== cf.
cell
&&
face
== cf.
face
);
125
}
126
127
// IOstream Operators
128
129
friend
Ostream
&
operator
<<
130
(
131
Ostream
& os,
132
const
cellFaceIdentifier
& cf
133
)
134
{
135
os <<
"("
<< cf.cell <<
"/"
<< cf.face <<
")"
;
136
return
os;
137
}
138
};
139
140
141
private
:
142
143
// Private data
144
145
//- Point-cell addressing. Used for topological analysis
146
// Warning. This point cell addressing list potentially contains
147
// duplicate cell entries. Use additional checking
148
mutable
labelListList
* pointCellsPtr_;
149
150
//- Number of internal faces for polyMesh
151
label nInternalFaces_;
152
153
//- Polyhedral mesh boundary patch start indices and dimensions
154
labelList
patchStarts_;
155
labelList
patchSizes_;
156
157
//- association between two faces
158
List<labelPair>
interfaces_;
159
160
//- list of cells/faces id pairs for each baffle
161
List<List<cellFaceIdentifier>
> baffleIds_;
162
163
//- Global face list for polyMesh
164
faceList
meshFaces_;
165
166
//- Cells as polyhedra for polyMesh
167
cellList
cellPolys_;
168
169
//- Face sets for monitoring
170
HashTable<List<label>
,
word
,
string::hash
> monitoringSets_;
171
172
173
// Private Member Functions
174
175
//- Disallow default bitwise copy construct
176
meshReader
(
const
meshReader
&);
177
178
//- Disallow default bitwise assignment
179
void
operator=(
const
meshReader
&);
180
181
//- Calculate pointCells
182
void
calcPointCells()
const
;
183
184
const
labelListList
& pointCells()
const
;
185
186
//- Make polyhedral cells and global faces if the mesh is polyhedral
187
void
createPolyCells();
188
189
//- Add in boundary face
190
void
addPolyBoundaryFace
191
(
192
const
label cellId,
193
const
label cellFaceId,
194
const
label nCreatedFaces
195
);
196
197
//- Add in boundary face
198
void
addPolyBoundaryFace
199
(
200
const
cellFaceIdentifier& identifier,
201
const
label nCreatedFaces
202
);
203
204
//- Add cellZones based on cellTable Id
205
void
addCellZones(
polyMesh
&)
const
;
206
207
//- Add faceZones based on monitoring boundary conditions
208
void
addFaceZones(
polyMesh
&)
const
;
209
210
//- Make polyhedral boundary from shape boundary
211
// (adds more faces to the face list)
212
void
createPolyBoundary();
213
214
//- Add polyhedral boundary
215
List<polyPatch*>
polyBoundaryPatches(
const
polyMesh
&);
216
217
//- Clear extra storage before creation of the mesh to remove
218
// a memory peak
219
void
clearExtraStorage();
220
221
void
writeInterfaces(
const
objectRegistry
&)
const
;
222
223
//- Write List<label> in constant/polyMesh
224
void
writeMeshLabelList
225
(
226
const
objectRegistry
& registry,
227
const
word
& propertyName,
228
const
labelList
& list,
229
IOstream::streamFormat
fmt =
IOstream::ASCII
230
)
const
;
231
232
//- Return list of faces for every cell
233
faceListList
& cellFaces()
const
234
{
235
return
const_cast<
faceListList
&
>
(
cellFaces_
);
236
}
237
238
239
protected
:
240
241
// Protected data
242
243
//- Pointers to cell shape models
244
static
const
cellModel
*
unknownModel
;
245
static
const
cellModel
*
tetModel
;
246
static
const
cellModel
*
pyrModel
;
247
static
const
cellModel
*
prismModel
;
248
static
const
cellModel
*
hexModel
;
249
250
//- Referenced filename
251
fileName
geometryFile_
;
252
253
//- Geometry scaling
254
scalar
scaleFactor_
;
255
256
//- Points supporting the mesh
257
pointField
points_
;
258
259
//- Lookup original Cell number for a given cell
260
labelList
origCellId_
;
261
262
//- Identify boundary faces by cells and their faces
263
// for each patch
264
List<List<cellFaceIdentifier>
>
boundaryIds_
;
265
266
//- Boundary patch types
267
wordList
patchTypes_
;
268
269
//- Boundary patch names
270
wordList
patchNames_
;
271
272
//- Boundary patch physical types
273
wordList
patchPhysicalTypes_
;
274
275
//- List of faces for every cell
276
faceListList
cellFaces_
;
277
278
//- List of each baffle face
279
faceList
baffleFaces_
;
280
281
//- Cell table id for each cell
282
labelList
cellTableId_
;
283
284
//- Cell table persistent data saved as a dictionary
285
cellTable
cellTable_
;
286
287
288
// Member Functions
289
290
//- Subclasses are required to supply this information
291
virtual
bool
readGeometry
(
const
scalar scaleFactor = 1.0) = 0;
292
293
public
:
294
295
// Static Members
296
297
//- Warn about repeated names
298
static
void
warnDuplicates
(
const
word
& context,
const
wordList
&);
299
300
301
// Constructors
302
303
//- Construct from fileName
304
meshReader
(
const
fileName
&,
const
scalar scaleFactor = 1.0);
305
306
307
//- Destructor
308
virtual
~meshReader
();
309
310
311
// Member Functions
312
313
//- Create and return polyMesh
314
virtual
autoPtr<polyMesh>
mesh
(
const
objectRegistry
&);
315
316
//- Write auxiliary information
317
void
writeAux
(
const
objectRegistry
&)
const
;
318
319
//- Write mesh
320
void
writeMesh
321
(
322
const
polyMesh
&,
323
IOstream::streamFormat
fmt =
IOstream::BINARY
324
)
const
;
325
};
326
327
328
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
329
330
}
// End namespace Foam
331
332
#endif
333
334
// ************************ vim: set sw=4 sts=4 et: ************************ //