FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

meshReader.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Namespace
00025     Foam::meshReaders
00026 
00027 Description
00028     A namespace for holding various types of mesh readers.
00029 
00030 
00031 Class
00032     Foam::meshReader
00033 
00034 Description
00035     This class supports creating polyMeshes with baffles.
00036 
00037     The derived classes are responsible for providing the protected data.
00038     This implementation is somewhat messy, but could/should be restructured
00039     to provide a more generalized reader (at the moment it has been written
00040     for converting pro-STAR data).
00041 
00042     The meshReader supports cellTable information (see new user's guide entry).
00043 
00044 Note
00045     The boundary definitions are given as cell/face.
00046 
00047 SourceFiles
00048     calcPointCells.C
00049     createPolyBoundary.C
00050     createPolyCells.C
00051     meshReader.C
00052     meshReaderAux.C
00053 
00054 \*---------------------------------------------------------------------------*/
00055 
00056 #ifndef meshReader_H
00057 #define meshReader_H
00058 
00059 #include <OpenFOAM/polyMesh.H>
00060 #include <OpenFOAM/HashTable.H>
00061 #include <OpenFOAM/IOstream.H>
00062 
00063 #include <conversion/cellTable.H>
00064 
00065 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00066 
00067 namespace Foam
00068 {
00069 
00070 /*---------------------------------------------------------------------------*\
00071                         Class meshReader Declaration
00072 \*---------------------------------------------------------------------------*/
00073 
00074 class meshReader
00075 {
00076 protected:
00077 
00078     //- Identify cell faces in terms of cell Id and face Id
00079     class cellFaceIdentifier
00080     {
00081     public:
00082         // Public data
00083 
00084             //- Cell Id
00085             label cell;
00086 
00087             //- Face Id
00088             label face;
00089 
00090 
00091         // Constructors
00092 
00093             //- Construct null
00094             cellFaceIdentifier() : cell(-1), face(-1) {}
00095 
00096             //- Construct from cell/face components
00097             cellFaceIdentifier(label c, label f) : cell(c), face(f) {}
00098 
00099 
00100         // Check
00101 
00102             //- Used if cell or face are non-negative
00103             bool used() const
00104             {
00105                 return (cell >= 0 && face >= 0);
00106             }
00107 
00108             //- Unused if cell or face are negative
00109             bool unused() const
00110             {
00111                 return (cell < 0 || face < 0);
00112             }
00113 
00114 
00115         // Member Operators
00116 
00117             bool operator!=(const cellFaceIdentifier& cf) const
00118             {
00119                 return (cell != cf.cell || face != cf.face);
00120             }
00121 
00122             bool operator==(const cellFaceIdentifier& cf) const
00123             {
00124                 return (cell == cf.cell && face == cf.face);
00125             }
00126 
00127         // IOstream Operators
00128 
00129             friend Ostream& operator<<
00130             (
00131                 Ostream& os,
00132                 const cellFaceIdentifier& cf
00133             )
00134             {
00135                 os << "(" << cf.cell << "/" << cf.face << ")";
00136                 return os;
00137             }
00138         };
00139 
00140 
00141 private:
00142 
00143     // Private data
00144 
00145         //- Point-cell addressing. Used for topological analysis
00146         // Warning. This point cell addressing list potentially contains
00147         // duplicate cell entries. Use additional checking
00148         mutable labelListList* pointCellsPtr_;
00149 
00150         //- Number of internal faces for polyMesh
00151         label nInternalFaces_;
00152 
00153         //- Polyhedral mesh boundary patch start indices and dimensions
00154         labelList patchStarts_;
00155         labelList patchSizes_;
00156 
00157         //- association between two faces
00158         List<labelPair> interfaces_;
00159 
00160         //- list of cells/faces id pairs for each baffle
00161         List<List<cellFaceIdentifier> > baffleIds_;
00162 
00163         //- Global face list for polyMesh
00164         faceList meshFaces_;
00165 
00166         //- Cells as polyhedra for polyMesh
00167         cellList cellPolys_;
00168 
00169         //- Face sets for monitoring
00170         HashTable<List<label>, word, string::hash> monitoringSets_;
00171 
00172 
00173     // Private Member Functions
00174 
00175         //- Disallow default bitwise copy construct
00176         meshReader(const meshReader&);
00177 
00178         //- Disallow default bitwise assignment
00179         void operator=(const meshReader&);
00180 
00181         //- Calculate pointCells
00182         void calcPointCells() const;
00183 
00184         const labelListList& pointCells() const;
00185 
00186         //- Make polyhedral cells and global faces if the mesh is polyhedral
00187         void createPolyCells();
00188 
00189         //- Add in boundary face
00190         void addPolyBoundaryFace
00191         (
00192             const label cellId,
00193             const label cellFaceId,
00194             const label nCreatedFaces
00195         );
00196 
00197         //- Add in boundary face
00198         void addPolyBoundaryFace
00199         (
00200             const cellFaceIdentifier& identifier,
00201             const label nCreatedFaces
00202         );
00203 
00204         //- Add cellZones based on cellTable Id
00205         void addCellZones(polyMesh&) const;
00206 
00207         //- Add faceZones based on monitoring boundary conditions
00208         void addFaceZones(polyMesh&) const;
00209 
00210         //- Make polyhedral boundary from shape boundary
00211         // (adds more faces to the face list)
00212         void createPolyBoundary();
00213 
00214         //- Add polyhedral boundary
00215         List<polyPatch*> polyBoundaryPatches(const polyMesh&);
00216 
00217         //- Clear extra storage before creation of the mesh to remove
00218         //  a memory peak
00219         void clearExtraStorage();
00220 
00221         void writeInterfaces(const objectRegistry&) const;
00222 
00223         //- Write List<label> in constant/polyMesh
00224         void writeMeshLabelList
00225         (
00226             const objectRegistry& registry,
00227             const word& propertyName,
00228             const labelList& list,
00229             IOstream::streamFormat fmt = IOstream::ASCII
00230         ) const;
00231 
00232         //- Return list of faces for every cell
00233         faceListList& cellFaces() const
00234         {
00235             return const_cast<faceListList&>(cellFaces_);
00236         }
00237 
00238 
00239 protected:
00240 
00241     // Protected data
00242 
00243         //- Pointers to cell shape models
00244         static const cellModel* unknownModel;
00245         static const cellModel* tetModel;
00246         static const cellModel* pyrModel;
00247         static const cellModel* prismModel;
00248         static const cellModel* hexModel;
00249 
00250         //- Referenced filename
00251         fileName geometryFile_;
00252 
00253         //- Geometry scaling
00254         scalar scaleFactor_;
00255 
00256         //- Points supporting the mesh
00257         pointField points_;
00258 
00259         //- Lookup original Cell number for a given cell
00260         labelList origCellId_;
00261 
00262         //- Identify boundary faces by cells and their faces
00263         //  for each patch
00264         List<List<cellFaceIdentifier> > boundaryIds_;
00265 
00266         //- Boundary patch types
00267         wordList patchTypes_;
00268 
00269         //- Boundary patch names
00270         wordList patchNames_;
00271 
00272         //- Boundary patch physical types
00273         wordList patchPhysicalTypes_;
00274 
00275         //- List of faces for every cell
00276         faceListList cellFaces_;
00277 
00278         //- List of each baffle face
00279         faceList baffleFaces_;
00280 
00281         //- Cell table id for each cell
00282         labelList cellTableId_;
00283 
00284         //- Cell table persistent data saved as a dictionary
00285         cellTable cellTable_;
00286 
00287 
00288     // Member Functions
00289 
00290         //- Subclasses are required to supply this information
00291         virtual bool readGeometry(const scalar scaleFactor = 1.0) = 0;
00292 
00293 public:
00294 
00295     // Static Members
00296 
00297         //- Warn about repeated names
00298         static void warnDuplicates(const word& context, const wordList&);
00299 
00300 
00301     // Constructors
00302 
00303         //- Construct from fileName
00304         meshReader(const fileName&, const scalar scaleFactor = 1.0);
00305 
00306 
00307     //- Destructor
00308     virtual ~meshReader();
00309 
00310 
00311     // Member Functions
00312 
00313         //- Create and return polyMesh
00314         virtual autoPtr<polyMesh> mesh(const objectRegistry&);
00315 
00316         //- Write auxiliary information
00317         void writeAux(const objectRegistry&) const;
00318 
00319         //- Write mesh
00320         void writeMesh
00321         (
00322             const polyMesh&,
00323             IOstream::streamFormat fmt = IOstream::BINARY
00324         ) const;
00325 };
00326 
00327 
00328 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00329 
00330 } // End namespace Foam
00331 
00332 #endif
00333 
00334 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines