1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 A namespace for holding various types of mesh readers.
36 This class supports creating polyMeshes with baffles.
38 The derived classes are responsible for providing the protected data.
39 This implementation is somewhat messy, but could/should be restructured
40 to provide a more generalized reader (at the moment it has been written
41 for converting pro-STAR data).
43 The meshReader supports cellTable information (see new user's guide entry).
46 The boundary definitions are given as cell/face.
55 \*---------------------------------------------------------------------------*/
61 #include "HashTable.H"
64 #include "cellTable.H"
66 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 /*---------------------------------------------------------------------------*\
72 Class meshReader Declaration
73 \*---------------------------------------------------------------------------*/
79 //- Identify cell faces in terms of cell Id and face Id
80 class cellFaceIdentifier
95 cellFaceIdentifier() : cell(-1), face(-1) {}
97 //- Construct from cell/face components
98 cellFaceIdentifier(label c, label f) : cell(c), face(f) {}
103 //- Used if cell or face are non-negative
106 return (cell >= 0 && face >= 0);
109 //- Unused if cell or face are negative
112 return (cell < 0 || face < 0);
118 bool operator!=(const cellFaceIdentifier& cf) const
120 return (cell != cf.cell || face != cf.face);
123 bool operator==(const cellFaceIdentifier& cf) const
125 return (cell == cf.cell && face == cf.face);
128 // IOstream Operators
130 friend Ostream& operator<<
133 const cellFaceIdentifier& cf
136 os << "(" << cf.cell << "/" << cf.face << ")";
146 //- Point-cell addressing. Used for topological analysis
147 // Warning. This point cell addressing list potentially contains
148 // duplicate cell entries. Use additional checking
149 mutable labelListList* pointCellsPtr_;
151 //- Number of internal faces for polyMesh
152 label nInternalFaces_;
154 //- Polyhedral mesh boundary patch start indices and dimensions
155 labelList patchStarts_;
156 labelList patchSizes_;
158 //- association between two faces
159 List<labelPair> interfaces_;
161 //- list of cells/faces id pairs for each baffle
162 List<List<cellFaceIdentifier> > baffleIds_;
164 //- Global face list for polyMesh
167 //- Cells as polyhedra for polyMesh
170 //- Face sets for monitoring
171 HashTable<List<label>, word, string::hash> monitoringSets_;
174 // Private Member Functions
176 //- Disallow default bitwise copy construct
177 meshReader(const meshReader&);
179 //- Disallow default bitwise assignment
180 void operator=(const meshReader&);
182 //- Calculate pointCells
183 void calcPointCells() const;
185 const labelListList& pointCells() const;
187 //- Make polyhedral cells and global faces if the mesh is polyhedral
188 void createPolyCells();
190 //- Add in boundary face
191 void addPolyBoundaryFace
194 const label cellFaceId,
195 const label nCreatedFaces
198 //- Add in boundary face
199 void addPolyBoundaryFace
201 const cellFaceIdentifier& identifier,
202 const label nCreatedFaces
205 //- Add cellZones based on cellTable Id
206 void addCellZones(polyMesh&) const;
208 //- Add faceZones based on monitoring boundary conditions
209 void addFaceZones(polyMesh&) const;
211 //- Make polyhedral boundary from shape boundary
212 // (adds more faces to the face list)
213 void createPolyBoundary();
215 //- Add polyhedral boundary
216 List<polyPatch*> polyBoundaryPatches(const polyMesh&);
218 //- Clear extra storage before creation of the mesh to remove
220 void clearExtraStorage();
222 void writeInterfaces(const objectRegistry&) const;
224 //- Write List<label> in constant/polyMesh
225 void writeMeshLabelList
227 const objectRegistry& registry,
228 const word& propertyName,
229 const labelList& list,
230 IOstream::streamFormat fmt = IOstream::ASCII
233 //- Return list of faces for every cell
234 faceListList& cellFaces() const
236 return const_cast<faceListList&>(cellFaces_);
244 //- Pointers to cell shape models
245 static const cellModel* unknownModel;
246 static const cellModel* tetModel;
247 static const cellModel* pyrModel;
248 static const cellModel* prismModel;
249 static const cellModel* hexModel;
251 //- Referenced filename
252 fileName geometryFile_;
257 //- Points supporting the mesh
260 //- Lookup original Cell number for a given cell
261 labelList origCellId_;
263 //- Identify boundary faces by cells and their faces
265 List<List<cellFaceIdentifier> > boundaryIds_;
267 //- Boundary patch types
268 wordList patchTypes_;
270 //- Boundary patch names
271 wordList patchNames_;
273 //- Boundary patch physical types
274 wordList patchPhysicalTypes_;
276 //- List of faces for every cell
277 faceListList cellFaces_;
279 //- List of each baffle face
280 faceList baffleFaces_;
282 //- Cell table id for each cell
283 labelList cellTableId_;
285 //- Cell table persistent data saved as a dictionary
286 cellTable cellTable_;
291 //- Subclasses are required to supply this information
292 virtual bool readGeometry(const scalar scaleFactor = 1.0) = 0;
298 //- Warn about repeated names
299 static void warnDuplicates(const word& context, const wordList&);
304 //- Construct from fileName
305 meshReader(const fileName&, const scalar scaleFactor = 1.0);
309 virtual ~meshReader();
314 //- Create and return polyMesh
315 virtual autoPtr<polyMesh> mesh(const objectRegistry&);
317 //- Write auxiliary information
318 void writeAux(const objectRegistry&) const;
324 IOstream::streamFormat fmt = IOstream::BINARY
329 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
331 } // End namespace Foam
335 // ************************************************************************* //