OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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