Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / applications / utilities / mesh / conversion / star3ToFoam / starMesh.H
blob85417116b8256c3d3e124e825c87260053ac5b61
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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/>.
24 Class
25     Foam::starMesh
27 Description
28     A messy mesh class which supports the possibility of creating a shapeMesh
29     for regular Star meshes (no arbitrary interfaces or collapsed SAMM cells).
30     If any of these special feateres exist, the mesh is created as polyMesh
32 SourceFiles
33     calcPointCells.C
34     createBoundaryFaces.C
35     createCoupleMatches.C
36     createPolyBoundary.C
37     createPolyCells.C
38     fixCollapsedEdges.C
39     mergeCoupleFacePoints.C
40     readBoundary.C
41     readCells.C
42     readCouples.C
43     readPoints.C
44     starMesh.C
45     writeMesh.C
47 \*---------------------------------------------------------------------------*/
49 #ifndef starMesh_H
50 #define starMesh_H
52 #include "polyMesh.H"
53 #include "cellShape.H"
54 #include "cellList.H"
55 #include "polyPatchList.H"
56 #include "coupledFacePair.H"
57 #include "IFstream.H"
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 #ifndef namespaceFoam
62 #define namespaceFoam
63     using namespace Foam;
64 #endif
67 /*---------------------------------------------------------------------------*\
68                            Class starMesh Declaration
69 \*---------------------------------------------------------------------------*/
71 class starMesh
73     // Private data
75         //- Name of the case
76         fileName casePrefix_;
78         //- Database
79         const Time& runTime_;
81         //- Points supporting the mesh
82         pointField points_;
84         //- Cell shapes
85         cellShapeList cellShapes_;
87         //- Boundary faces
88         faceListList boundary_;
90         //- Boundary patch types
91         wordList patchTypes_;
93         //- Default boundary patch name
94         word defaultFacesName_;
96         //- Default boundary patch types
97         word defaultFacesType_;
99         //- Boundary patch names
100         wordList patchNames_;
102         //- Boundary patch physical types
103         wordList patchPhysicalTypes_;
105         //- Point labels (STAR point numbering is not necessarily contiguous)
106         labelList starPointLabelLookup_;
108         //- STAR point number for a given vertex
109         labelList starPointID_;
111         //- STAR Cell number for a given cell
112         labelList starCellID_;
114         //- Cell labels (STAR cell numbering is not necessarily contiguous)
115         labelList starCellLabelLookup_;
117         //- STAR Cell permutation label
118         labelList starCellPermutation_;
120         //- List of faces for every cell
121         faceListList cellFaces_;
123         //- Cell ID for every boundary face. Used in two-tier boundary
124         //  reconstruction
125         labelListList boundaryCellIDs_;
127         //- Cell face ID for every boundary face. Used in two-tier boundary
128         //  reconstruction
129         labelListList boundaryCellFaceIDs_;
131         //- Global face list for polyMesh
132         faceList meshFaces_;
134         //- Cells as polyhedra for polyMesh
135         cellList cellPolys_;
137         //- Number of internal faces for polyMesh
138         label nInternalFaces_;
140         //- Polyhedral mesh boundary patch start indices
141         labelList polyBoundaryPatchStartIndices_;
143         //- Point-cell addressing. Used for topological analysis
144         // Warning. This point cell addressing list potentially contains
145         // duplicate cell entries. Use additional checking
146         mutable labelListList* pointCellsPtr_;
148         //- List of face couples
149         PtrList<coupledFacePair> couples_;
151         //- Can the mesh be treated as a shapeMesh?
152         bool isShapeMesh_;
154     // Private static data members
156         //- Error on unity small tolerance
157         static const scalar smallMergeTol_;
159         //- Couple match relative point merge tolerance
160         static const scalar cpMergePointTol_;
162         //- Pointers to cell models
163         static const cellModel* unknownPtr_;
164         static const cellModel* tetPtr_;
165         static const cellModel* pyrPtr_;
166         static const cellModel* tetWedgePtr_;
167         static const cellModel* prismPtr_;
168         static const cellModel* wedgePtr_;
169         static const cellModel* hexPtr_;
171         static const cellModel* sammTrim1Ptr_;
172         static const cellModel* sammTrim2Ptr_;
173         static const cellModel* sammTrim3Ptr_;
174         static const cellModel* sammTrim4Ptr_;
175         static const cellModel* sammTrim5Ptr_;
176         static const cellModel* sammTrim8Ptr_;
178         //- Regular addressing data
179         static const label regularAddressingTable[6][8];
181         //- SAMM addressing data
182         static const label sammAddressingTable[9][12];
184         static const label sammFacePermutationTable[24][8];
186         static const label shapeFaceLookup[19][9];
189     // Private Member Functions
191         //- Disallow default bitwise copy construct
192         starMesh(const starMesh&);
194         //- Disallow default bitwise assignment
195         void operator=(const starMesh&);
198         //- read fixed format vertex label
199         static label readVtxLabel(IFstream&);
201         //- read fixed format vertex coordinate component
202         static scalar readVtxCmpt(IFstream&);
204         //- Read to nl
205         static void readToNl(IFstream&);
207         //- Read the points file
208         void readPoints(const scalar scaleFactor);
210         //- Read the cells file
211         void readCells();
213         void addRegularCell
214         (
215             const labelList& labels,
216             const label nCreatedCells
217         );
219         void addSAMMcell
220         (
221             const labelList& labels,
222             const label nCreatedCells
223         );
225         //- Read the boundary file
226         void readBoundary();
228         //- Check and correct collapsed edges on faces
229         // Note. If a collapsed edge is found, the mesh is no longer shapeMesh
230         void fixCollapsedEdges();
232         //- Read couples
233         void readCouples();
235         //- Create couple matches
236         void createCoupleMatches();
238         //- Calculate pointCells
239         void calcPointCells() const;
241         const labelListList& pointCells() const;
243         //- Mark boundary faces from the quads
244         void markBoundaryFaces();
246         //- Collect boundary faces from the quads
247         void collectBoundaryFaces();
249         //- Specialist version of face comparison to deal with
250         // PROSTAR boundary format idiosyncracies
251         bool starEqualFace
252         (
253             const face& boundaryFace,
254             const face& cellFace
255         ) const;
257         //- Merge couple face points
258         void mergeCoupleFacePoints();
260         //- Point indexing structure used by sort to keep track of
261         //  the point labels
262         struct pointIndex
263         {
264             label label_;
265             double index_;
266         };
268         //- Purge cell shapes
269         void purgeCellShapes();
271         //- Make polyhedral cells and global faces if the mesh is polyhedral
272         void createPolyCells();
274         //- Make polyhedral boundary from shape boundary
275         // (adds more faces to the face list)
276         void createPolyBoundary();
278         //- Make polyhedral mesh data (packing)
279         void createPolyMeshData();
281         //- Add polyhedral boundary
282         List<polyPatch*> polyBoundaryPatches(const polyMesh&);
284         //- Clear extra storage before creation of the mesh to remove
285         //  a memory peak
286         void clearExtraStorage();
289 public:
291     // Constructors
293         //- Construct from case name
294         starMesh
295         (
296             const fileName& prefix,
297             const Time& rt,
298             const scalar scaleFactor
299         );
302     //- Destructor
303     ~starMesh();
306     // Member Functions
308         //- Write mesh
309         void writeMesh();
313 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
315 #endif
317 // ************************************************************************* //