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

starMesh.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 Class
00025     Foam::starMesh
00026 
00027 Description
00028     A messy mesh class which supports the possibility of creating a shapeMesh
00029     for regular Star meshes (no arbitrary interfaces or collapsed SAMM cells).
00030     If any of these special feateres exist, the mesh is created as polyMesh
00031 
00032 SourceFiles
00033     calcPointCells.C
00034     createBoundaryFaces.C
00035     createCoupleMatches.C
00036     createPolyBoundary.C
00037     createPolyCells.C
00038     fixCollapsedEdges.C
00039     mergeCoupleFacePoints.C
00040     readBoundary.C
00041     readCells.C
00042     readCouples.C
00043     readPoints.C
00044     starMesh.C
00045     writeMesh.C
00046 
00047 \*---------------------------------------------------------------------------*/
00048 
00049 #ifndef starMesh_H
00050 #define starMesh_H
00051 
00052 #include <OpenFOAM/polyMesh.H>
00053 #include <OpenFOAM/cellShape.H>
00054 #include <OpenFOAM/cellList.H>
00055 #include <OpenFOAM/polyPatchList.H>
00056 #include "coupledFacePair.H"
00057 #include <OpenFOAM/IFstream.H>
00058 
00059 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00060 
00061 #ifndef namespaceFoam
00062 #define namespaceFoam
00063     using namespace Foam;
00064 #endif
00065 
00066 
00067 /*---------------------------------------------------------------------------*\
00068                            Class starMesh Declaration
00069 \*---------------------------------------------------------------------------*/
00070 
00071 class starMesh
00072 {
00073     // Private data
00074 
00075         //- Name of the case
00076         fileName casePrefix_;
00077 
00078         //- Database
00079         const Time& runTime_;
00080 
00081         //- Points supporting the mesh
00082         pointField points_;
00083 
00084         //- Cell shapes
00085         cellShapeList cellShapes_;
00086 
00087         //- Boundary faces
00088         faceListList boundary_;
00089 
00090         //- Boundary patch types
00091         wordList patchTypes_;
00092 
00093         //- Default boundary patch name
00094         word defaultFacesName_;
00095 
00096         //- Default boundary patch types
00097         word defaultFacesType_;
00098 
00099         //- Boundary patch names
00100         wordList patchNames_;
00101 
00102         //- Boundary patch physical types
00103         wordList patchPhysicalTypes_;
00104 
00105         //- Point labels (STAR point numbering is not necessarily contiguous)
00106         labelList starPointLabelLookup_;
00107 
00108         //- STAR point number for a given vertex
00109         labelList starPointID_;
00110 
00111         //- STAR Cell number for a given cell
00112         labelList starCellID_;
00113 
00114         //- Cell labels (STAR cell numbering is not necessarily contiguous)
00115         labelList starCellLabelLookup_;
00116 
00117         //- STAR Cell permutation label
00118         labelList starCellPermutation_;
00119 
00120         //- List of faces for every cell
00121         faceListList cellFaces_;
00122 
00123         //- Cell ID for every boundary face. Used in two-tier boundary
00124         //  reconstruction
00125         labelListList boundaryCellIDs_;
00126 
00127         //- Cell face ID for every boundary face. Used in two-tier boundary
00128         //  reconstruction
00129         labelListList boundaryCellFaceIDs_;
00130 
00131         //- Global face list for polyMesh
00132         faceList meshFaces_;
00133 
00134         //- Cells as polyhedra for polyMesh
00135         cellList cellPolys_;
00136 
00137         //- Number of internal faces for polyMesh
00138         label nInternalFaces_;
00139 
00140         //- Polyhedral mesh boundary patch start indices
00141         labelList polyBoundaryPatchStartIndices_;
00142 
00143         //- Point-cell addressing. Used for topological analysis
00144         // Warning. This point cell addressing list potentially contains
00145         // duplicate cell entries. Use additional checking
00146         mutable labelListList* pointCellsPtr_;
00147 
00148         //- List of face couples
00149         PtrList<coupledFacePair> couples_;
00150 
00151         //- Can the mesh be treated as a shapeMesh?
00152         bool isShapeMesh_;
00153 
00154     // Private static data members
00155 
00156         //- Error on unity small tolerance
00157         static const scalar smallMergeTol_;
00158 
00159         //- Couple match relative point merge tolerance
00160         static const scalar cpMergePointTol_;
00161 
00162         //- Pointers to cell models
00163         static const cellModel* unknownPtr_;
00164         static const cellModel* tetPtr_;
00165         static const cellModel* pyrPtr_;
00166         static const cellModel* tetWedgePtr_;
00167         static const cellModel* prismPtr_;
00168         static const cellModel* wedgePtr_;
00169         static const cellModel* hexPtr_;
00170 
00171         static const cellModel* sammTrim1Ptr_;
00172         static const cellModel* sammTrim2Ptr_;
00173         static const cellModel* sammTrim3Ptr_;
00174         static const cellModel* sammTrim4Ptr_;
00175         static const cellModel* sammTrim5Ptr_;
00176         static const cellModel* sammTrim8Ptr_;
00177 
00178         //- Regular addressing data
00179         static const label regularAddressingTable[6][8];
00180 
00181         //- SAMM addressing data
00182         static const label sammAddressingTable[9][12];
00183 
00184         static const label sammFacePermutationTable[24][8];
00185 
00186         static const label shapeFaceLookup[19][9];
00187 
00188 
00189     // Private Member Functions
00190 
00191         //- Disallow default bitwise copy construct
00192         starMesh(const starMesh&);
00193 
00194         //- Disallow default bitwise assignment
00195         void operator=(const starMesh&);
00196 
00197 
00198         //- read fixed format vertex label
00199         static label readVtxLabel(IFstream&);
00200 
00201         //- read fixed format vertex coordinate component
00202         static scalar readVtxCmpt(IFstream&);
00203 
00204         //- Read to nl
00205         static void readToNl(IFstream&);
00206 
00207         //- Read the points file
00208         void readPoints(const scalar scaleFactor);
00209 
00210         //- Read the cells file
00211         void readCells();
00212 
00213         void addRegularCell
00214         (
00215             const labelList& labels,
00216             const label nCreatedCells
00217         );
00218 
00219         void addSAMMcell
00220         (
00221             const labelList& labels,
00222             const label nCreatedCells
00223         );
00224 
00225         //- Read the boundary file
00226         void readBoundary();
00227 
00228         //- Check and correct collapsed edges on faces
00229         // Note. If a collapsed edge is found, the mesh is no longer shapeMesh
00230         void fixCollapsedEdges();
00231 
00232         //- Read couples
00233         void readCouples();
00234 
00235         //- Create couple matches
00236         void createCoupleMatches();
00237 
00238         //- Calculate pointCells
00239         void calcPointCells() const;
00240 
00241         const labelListList& pointCells() const;
00242 
00243         //- Mark boundary faces from the quads
00244         void markBoundaryFaces();
00245 
00246         //- Collect boundary faces from the quads
00247         void collectBoundaryFaces();
00248 
00249         //- Specialist version of face comparison to deal with
00250         // PROSTAR boundary format idiosyncracies
00251         bool starEqualFace
00252         (
00253             const face& boundaryFace,
00254             const face& cellFace
00255         ) const;
00256 
00257         //- Merge couple face points
00258         void mergeCoupleFacePoints();
00259 
00260         //- Point indexing structure used by sort to keep track of
00261         //  the point labels
00262         struct pointIndex
00263         {
00264             label label_;
00265             double index_;
00266         };
00267 
00268         //- Purge cell shapes
00269         void purgeCellShapes();
00270 
00271         //- Make polyhedral cells and global faces if the mesh is polyhedral
00272         void createPolyCells();
00273 
00274         //- Make polyhedral boundary from shape boundary
00275         // (adds more faces to the face list)
00276         void createPolyBoundary();
00277 
00278         //- Make polyhedral mesh data (packing)
00279         void createPolyMeshData();
00280 
00281         //- Add polyhedral boundary
00282         List<polyPatch*> polyBoundaryPatches(const polyMesh&);
00283 
00284         //- Clear extra storage before creation of the mesh to remove
00285         //  a memory peak
00286         void clearExtraStorage();
00287 
00288 
00289 public:
00290 
00291     // Constructors
00292 
00293         //- Construct from case name
00294         starMesh
00295         (
00296             const fileName& prefix,
00297             const Time& rt,
00298             const scalar scaleFactor
00299         );
00300 
00301 
00302     // Destructor
00303 
00304         ~starMesh();
00305 
00306 
00307     // Member Functions
00308 
00309         //- Write mesh
00310         void writeMesh();
00311 };
00312 
00313 
00314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00315 
00316 #endif
00317 
00318 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines