1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
28 A namespace for holding various types of mesh readers.
35 This class supports creating polyMeshes with baffles.
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).
42 The meshReader supports cellTable information (see new user's guide entry).
45 The boundary definitions are given as cell/face.
54 \*---------------------------------------------------------------------------*/
60 #include "HashTable.H"
63 #include "cellTable.H"
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 /*---------------------------------------------------------------------------*\
71 Class meshReader Declaration
72 \*---------------------------------------------------------------------------*/
78 //- Identify cell faces in terms of cell Id and face Id
79 class cellFaceIdentifier
94 cellFaceIdentifier() : cell(-1), face(-1) {}
96 //- Construct from cell/face components
97 cellFaceIdentifier(label c, label f) : cell(c), face(f) {}
102 //- Used if cell or face are non-negative
105 return (cell >= 0 && face >= 0);
108 //- Unused if cell or face are negative
111 return (cell < 0 || face < 0);
117 bool operator!=(const cellFaceIdentifier& cf) const
119 return (cell != cf.cell || face != cf.face);
122 bool operator==(const cellFaceIdentifier& cf) const
124 return (cell == cf.cell && face == cf.face);
127 // IOstream Operators
129 friend Ostream& operator<<
132 const cellFaceIdentifier& cf
135 os << "(" << cf.cell << "/" << cf.face << ")";
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_;
150 //- Number of internal faces for polyMesh
151 label nInternalFaces_;
153 //- Polyhedral mesh boundary patch start indices and dimensions
154 labelList patchStarts_;
155 labelList patchSizes_;
157 //- association between two faces
158 List<labelPair> interfaces_;
160 //- list of cells/faces id pairs for each baffle
161 List<List<cellFaceIdentifier> > baffleIds_;
163 //- Global face list for polyMesh
166 //- Cells as polyhedra for polyMesh
169 //- Face sets for monitoring
170 HashTable<List<label>, word, string::hash> monitoringSets_;
173 // Private Member Functions
175 //- Disallow default bitwise copy construct
176 meshReader(const meshReader&);
178 //- Disallow default bitwise assignment
179 void operator=(const meshReader&);
181 //- Calculate pointCells
182 void calcPointCells() const;
184 const labelListList& pointCells() const;
186 //- Make polyhedral cells and global faces if the mesh is polyhedral
187 void createPolyCells();
189 //- Add in boundary face
190 void addPolyBoundaryFace
193 const label cellFaceId,
194 const label nCreatedFaces
197 //- Add in boundary face
198 void addPolyBoundaryFace
200 const cellFaceIdentifier& identifier,
201 const label nCreatedFaces
204 //- Add cellZones based on cellTable Id
205 void addCellZones(polyMesh&) const;
207 //- Add faceZones based on monitoring boundary conditions
208 void addFaceZones(polyMesh&) const;
210 //- Make polyhedral boundary from shape boundary
211 // (adds more faces to the face list)
212 void createPolyBoundary();
214 //- Add polyhedral boundary
215 List<polyPatch*> polyBoundaryPatches(const polyMesh&);
217 //- Clear extra storage before creation of the mesh to remove
219 void clearExtraStorage();
221 void writeInterfaces(const objectRegistry&) const;
223 //- Write List<label> in constant/polyMesh
224 void writeMeshLabelList
226 const objectRegistry& registry,
227 const word& propertyName,
228 const labelList& list,
229 IOstream::streamFormat fmt = IOstream::ASCII
232 //- Return list of faces for every cell
233 faceListList& cellFaces() const
235 return const_cast<faceListList&>(cellFaces_);
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;
250 //- Referenced filename
251 fileName geometryFile_;
256 //- Points supporting the mesh
259 //- Lookup original Cell number for a given cell
260 labelList origCellId_;
262 //- Identify boundary faces by cells and their faces
264 List<List<cellFaceIdentifier> > boundaryIds_;
266 //- Boundary patch types
267 wordList patchTypes_;
269 //- Boundary patch names
270 wordList patchNames_;
272 //- Boundary patch physical types
273 wordList patchPhysicalTypes_;
275 //- List of faces for every cell
276 faceListList cellFaces_;
278 //- List of each baffle face
279 faceList baffleFaces_;
281 //- Cell table id for each cell
282 labelList cellTableId_;
284 //- Cell table persistent data saved as a dictionary
285 cellTable cellTable_;
290 //- Subclasses are required to supply this information
291 virtual bool readGeometry(const scalar scaleFactor = 1.0) = 0;
297 //- Warn about repeated names
298 static void warnDuplicates(const word& context, const wordList&);
303 //- Construct from fileName
304 meshReader(const fileName&, const scalar scaleFactor = 1.0);
308 virtual ~meshReader();
313 //- Create and return polyMesh
314 virtual autoPtr<polyMesh> mesh(const objectRegistry&);
316 //- Write auxiliary information
317 void writeAux(const objectRegistry&) const;
323 IOstream::streamFormat fmt = IOstream::BINARY
328 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 } // End namespace Foam
334 // ************************************************************************* //