Loading...
Searching...
No Matches
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 Foam_meshReader_H
53#define Foam_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{
65/*---------------------------------------------------------------------------*\
66 Class meshReader Declaration
67\*---------------------------------------------------------------------------*/
68
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) {}
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
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
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 std::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 polyPatchList 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 labelUList& 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
272 // Constructors
273
274 //- Construct from fileName
275 meshReader(const fileName&, const scalar scaling = 1.0);
277
278 //- Destructor
279 virtual ~meshReader() = default;
280
281
282 // Member Functions
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
299// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300
301} // End namespace Foam
302
303#endif
305// ************************************************************************* //
A HashTable similar to std::unordered_map.
Definition HashTable.H:124
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:72
const label & first() const noexcept
Definition Pair.H:137
const label & second() const noexcept
Definition Pair.H:147
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
The cellTable persistent data saved as a Map<dictionary>.
Definition cellTable.H:80
A class for handling file names.
Definition fileName.H:75
cellFaceIdentifier(label c, label f)
Construct from cell/face components.
Definition meshReader.H:85
bool notUsed() const
Unused if either cell or face are negative.
Definition meshReader.H:120
const label & cellId() const
The cell id (readonly).
Definition meshReader.H:93
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:112
const label & faceId() const
The face id (readonly).
Definition meshReader.H:101
This class supports creating polyMeshes with baffles.
Definition meshReader.H:65
scalar scaleFactor_
Geometry scaling.
Definition meshReader.H:266
static void warnDuplicates(const word &context, const wordList &)
Warn about repeated names.
List< List< cellFaceIdentifier > > boundaryIds_
Identify boundary faces by cells and their faces.
Definition meshReader.H:283
wordList patchPhysicalTypes_
Boundary patch physical types.
Definition meshReader.H:298
faceList meshFaces_
Global face list for polyMesh.
Definition meshReader.H:314
wordList patchNames_
Boundary patch names.
Definition meshReader.H:293
void writeAux(const objectRegistry &) const
Write auxiliary information.
label nInternalFaces_
Number of internal faces for polyMesh.
Definition meshReader.H:309
cellTable cellTable_
Cell table persistent data saved as a dictionary.
Definition meshReader.H:334
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:329
labelList origCellId_
Lookup original Cell number for a given cell.
Definition meshReader.H:276
pointField points_
Points supporting the mesh.
Definition meshReader.H:271
labelList patchSizes_
Definition meshReader.H:304
void writeMesh(const polyMesh &, IOstreamOption streamOpt=IOstreamOption(IOstreamOption::BINARY)) const
Write mesh.
Definition meshReader.C:120
faceList baffleFaces_
List of each baffle face.
Definition meshReader.H:324
virtual ~meshReader()=default
Destructor.
faceListList cellFaces_
List of faces for every cell.
Definition meshReader.H:319
labelList patchStarts_
Polyhedral mesh boundary patch start indices and dimensions.
Definition meshReader.H:303
fileName geometryFile_
Referenced filename.
Definition meshReader.H:261
wordList patchTypes_
Boundary patch types.
Definition meshReader.H:288
Registry of regIOobjects.
Smooth ATC in cells having a point to a set of patches supplied by type.
Definition pointCells.H:55
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
label cellId
Namespace for OpenFOAM.
Pair< label > labelPair
A pair of labels.
Definition Pair.H:54
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
Definition polyPatch.H:61
List< word > wordList
List of word.
Definition fileName.H:60
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
List< face > faceList
List of faces.
Definition faceListFwd.H:41
List< cell > cellList
List of cell.
Definition cellListFwd.H:41
List< faceList > faceListList
List of faceList.
Definition faceListFwd.H:44
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Definition UList.H:75
labelList f(nPoints)