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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::meshReader
29
30Description
31 This class supports creating polyMeshes with baffles.
32
33 The derived classes are responsible for providing the protected data.
34 This implementation is somewhat messy, but could/should be restructured
35 to provide a more generalized reader (at the moment it has been written
36 for converting PROSTAR data).
37
38 The meshReader supports cellTable information (see new user's guide entry).
39
40Note
41 The boundary definitions are given as cell/face.
42
43SourceFiles
44 calcPointCells.C
45 createPolyBoundary.C
46 createPolyCells.C
47 meshReader.C
48 meshReaderAux.C
49
50\*---------------------------------------------------------------------------*/
51
52#ifndef meshReader_H
53#define meshReader_H
54
55#include "polyMesh.H"
56#include "HashTable.H"
57#include "IOstream.H"
58#include "cellTable.H"
59
60// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61
62namespace Foam
63{
64
65/*---------------------------------------------------------------------------*\
66 Class meshReader Declaration
67\*---------------------------------------------------------------------------*/
69class meshReader
70{
71protected:
72
73 //- Identify cell faces in terms of cell Id and face Id
74 class cellFaceIdentifier : public labelPair
75 {
76 public:
77
78 // Constructors
79
80 //- Construct null, as invalid pair
81 cellFaceIdentifier() : labelPair(-1, -1) {}
82
83 //- Construct from cell/face components
84 cellFaceIdentifier(label c, label f) : labelPair(c, f) {}
85
86
87 // Access
88
89 //- The cell id (readonly)
90 const label& cellId() const
91 {
92 return first();
93 }
94
95 //- The face id (readonly)
96 const label& faceId() const
97 {
98 return second();
99 }
100
101
102 // Check
103
104 //- Used if both cell or face are non-negative
105 bool used() const
106 {
107 return (first() >= 0 && second() >= 0);
108 }
109
110 //- Unused if either cell or face are negative
111 bool notUsed() const
112 {
113 return (first() < 0 || second() < 0);
114 }
115 };
116
117
118private:
119
120 // Private Data
121
122 //- Point-cell addressing. Used for topological analysis
123 // Warning. This point cell addressing list potentially contains
124 // duplicate cell entries. Use additional checking
125 mutable unique_ptr<labelListList> pointCellsPtr_;
126
127 //- Association between two faces
128 List<labelPair> interfaces_;
129
130 //- List of cells/faces id pairs for each baffle
132
133 //- Cells as polyhedra for polyMesh
134 cellList cellPolys_;
135
136 //- Face sets for monitoring
137 HashTable<labelList> monitoringSets_;
138
139
140 // Private Member Functions
141
142 //- No copy construct
143 meshReader(const meshReader&) = delete;
144
145 //- No copy assignment
146 void operator=(const meshReader&) = delete;
147
148 //- Calculate pointCells
149 void calcPointCells() const;
150
151 const labelListList& pointCells() const;
152
153 //- Make polyhedral cells and global faces if the mesh is polyhedral
154 void createPolyCells();
155
156 //- Add in boundary face
157 void addPolyBoundaryFace
158 (
159 const label cellId,
160 const label cellFaceId,
161 const label nCreatedFaces
162 );
163
164 //- Add in boundary face
165 void addPolyBoundaryFace
166 (
167 const cellFaceIdentifier& identifier,
168 const label nCreatedFaces
169 );
170
171 //- Add cellZones based on cellTable Id
172 void addCellZones(polyMesh&) const;
173
174 //- Add faceZones based on monitoring boundary conditions
175 void addFaceZones(polyMesh&) const;
176
177 //- Make polyhedral boundary from shape boundary
178 // (adds more faces to the face list)
179 void createPolyBoundary();
180
181 //- Add polyhedral boundary
182 List<polyPatch*> polyBoundaryPatches(const polyMesh&);
183
184 //- Clear extra storage before creation of the mesh to remove
185 // a memory peak
186 void clearExtraStorage();
187
188 void writeInterfaces(const objectRegistry&) const;
189
190 //- Write labelList in constant/polyMesh
191 void writeMeshLabelList
192 (
193 const objectRegistry& registry,
194 const word& propertyName,
195 const labelList& list,
196 IOstreamOption streamOpt
197 ) const;
198
199 //- Return list of faces for every cell
200 faceListList& cellFaces() const
201 {
202 return const_cast<faceListList&>(cellFaces_);
203 }
204
205
206protected:
207
208 // Protected Data
209
210 //- Referenced filename
212
213 //- Geometry scaling
214 scalar scaleFactor_;
215
216 //- Points supporting the mesh
218
219 //- Lookup original Cell number for a given cell
221
222 //- Identify boundary faces by cells and their faces
223 // for each patch
225
226 //- Boundary patch types
228
229 //- Boundary patch names
231
232 //- Boundary patch physical types
234
235 //- Polyhedral mesh boundary patch start indices and dimensions
238
239 //- Number of internal faces for polyMesh
240 label nInternalFaces_;
241
242 //- Global face list for polyMesh
244
245 //- List of faces for every cell
247
248 //- List of each baffle face
250
251 //- Cell table id for each cell
253
254 //- Cell table persistent data saved as a dictionary
256
257
258 // Protected Member Functions
259
260 //- Subclasses are required to supply this information
261 virtual bool readGeometry(const scalar scaleFactor = 1.0) = 0;
262
263
264public:
265
266 // Static Members
267
268 //- Warn about repeated names
269 static void warnDuplicates(const word& context, const wordList&);
270
271
272 // Constructors
273
274 //- Construct from fileName
275 meshReader(const fileName&, const scalar scaling = 1.0);
276
277
278 //- Destructor
279 virtual ~meshReader() = default;
280
281
282 // Member Functions
283
284 //- Create and return polyMesh
285 virtual autoPtr<polyMesh> mesh(const objectRegistry&);
286
287 //- Write auxiliary information
288 void writeAux(const objectRegistry&) const;
289
290 //- Write mesh
291 void writeMesh
292 (
293 const polyMesh&,
295 ) const;
296};
297
298
299// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300
301} // End namespace Foam
302
303#endif
304
305// ************************************************************************* //
T & first() noexcept
The first element of the list, position [0].
Definition: FixedListI.H:207
A HashTable similar to std::unordered_map.
Definition: HashTable.H:123
The IOstreamOption is a simple container for options an IOstream can normally have.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
const label & second() const noexcept
Return second element, which is also the last element.
Definition: PairI.H:120
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
The cellTable persistent data saved as a Map<dictionary>.
Definition: cellTable.H:83
A class for handling file names.
Definition: fileName.H:76
Identify cell faces in terms of cell Id and face Id.
Definition: meshReader.H:74
cellFaceIdentifier(label c, label f)
Construct from cell/face components.
Definition: meshReader.H:83
bool notUsed() const
Unused if either cell or face are negative.
Definition: meshReader.H:110
const label & cellId() const
The cell id (readonly)
Definition: meshReader.H:89
cellFaceIdentifier()
Construct null, as invalid pair.
Definition: meshReader.H:80
bool used() const
Used if both cell or face are non-negative.
Definition: meshReader.H:104
const label & faceId() const
The face id (readonly)
Definition: meshReader.H:95
This class supports creating polyMeshes with baffles.
Definition: meshReader.H:69
scalar scaleFactor_
Geometry scaling.
Definition: meshReader.H:213
static void warnDuplicates(const word &context, const wordList &)
Warn about repeated names.
Definition: meshReaderAux.C:37
List< List< cellFaceIdentifier > > boundaryIds_
Identify boundary faces by cells and their faces.
Definition: meshReader.H:223
wordList patchPhysicalTypes_
Boundary patch physical types.
Definition: meshReader.H:232
faceList meshFaces_
Global face list for polyMesh.
Definition: meshReader.H:242
wordList patchNames_
Boundary patch names.
Definition: meshReader.H:229
void writeAux(const objectRegistry &) const
Write auxiliary information.
label nInternalFaces_
Number of internal faces for polyMesh.
Definition: meshReader.H:239
cellTable cellTable_
Cell table persistent data saved as a dictionary.
Definition: meshReader.H:254
virtual bool readGeometry(const scalar scaleFactor=1.0)=0
Subclasses are required to supply this information.
labelList cellTableId_
Cell table id for each cell.
Definition: meshReader.H:251
labelList origCellId_
Lookup original Cell number for a given cell.
Definition: meshReader.H:219
pointField points_
Points supporting the mesh.
Definition: meshReader.H:216
labelList patchSizes_
Definition: meshReader.H:236
void writeMesh(const polyMesh &, IOstreamOption streamOpt=IOstreamOption(IOstreamOption::BINARY)) const
Write mesh.
Definition: meshReader.C:125
faceList baffleFaces_
List of each baffle face.
Definition: meshReader.H:248
virtual ~meshReader()=default
Destructor.
faceListList cellFaces_
List of faces for every cell.
Definition: meshReader.H:245
labelList patchStarts_
Polyhedral mesh boundary patch start indices and dimensions.
Definition: meshReader.H:235
fileName geometryFile_
Referenced filename.
Definition: meshReader.H:210
wordList patchTypes_
Boundary patch types.
Definition: meshReader.H:226
Registry of regIOobjects.
Smooth ATC in cells having a point to a set of patches supplied by type.
Definition: pointCells.H:59
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
label cellId
Namespace for OpenFOAM.
labelList f(nPoints)