FreeFOAM The Cross-Platform CFD Toolkit
starMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::starMesh
26 
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
31 
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
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef starMesh_H
50 #define starMesh_H
51 
52 #include <OpenFOAM/polyMesh.H>
53 #include <OpenFOAM/cellShape.H>
54 #include <OpenFOAM/cellList.H>
55 #include <OpenFOAM/polyPatchList.H>
56 #include "coupledFacePair.H"
57 #include <OpenFOAM/IFstream.H>
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 #ifndef namespaceFoam
62 #define namespaceFoam
63  using namespace Foam;
64 #endif
65 
66 
67 /*---------------------------------------------------------------------------*\
68  Class starMesh Declaration
69 \*---------------------------------------------------------------------------*/
70 
71 class starMesh
72 {
73  // Private data
74 
75  //- Name of the case
76  fileName casePrefix_;
77 
78  //- Database
79  const Time& runTime_;
80 
81  //- Points supporting the mesh
82  pointField points_;
83 
84  //- Cell shapes
85  cellShapeList cellShapes_;
86 
87  //- Boundary faces
88  faceListList boundary_;
89 
90  //- Boundary patch types
91  wordList patchTypes_;
92 
93  //- Default boundary patch name
94  word defaultFacesName_;
95 
96  //- Default boundary patch types
97  word defaultFacesType_;
98 
99  //- Boundary patch names
100  wordList patchNames_;
101 
102  //- Boundary patch physical types
103  wordList patchPhysicalTypes_;
104 
105  //- Point labels (STAR point numbering is not necessarily contiguous)
106  labelList starPointLabelLookup_;
107 
108  //- STAR point number for a given vertex
109  labelList starPointID_;
110 
111  //- STAR Cell number for a given cell
112  labelList starCellID_;
113 
114  //- Cell labels (STAR cell numbering is not necessarily contiguous)
115  labelList starCellLabelLookup_;
116 
117  //- STAR Cell permutation label
118  labelList starCellPermutation_;
119 
120  //- List of faces for every cell
121  faceListList cellFaces_;
122 
123  //- Cell ID for every boundary face. Used in two-tier boundary
124  // reconstruction
125  labelListList boundaryCellIDs_;
126 
127  //- Cell face ID for every boundary face. Used in two-tier boundary
128  // reconstruction
129  labelListList boundaryCellFaceIDs_;
130 
131  //- Global face list for polyMesh
132  faceList meshFaces_;
133 
134  //- Cells as polyhedra for polyMesh
135  cellList cellPolys_;
136 
137  //- Number of internal faces for polyMesh
138  label nInternalFaces_;
139 
140  //- Polyhedral mesh boundary patch start indices
141  labelList polyBoundaryPatchStartIndices_;
142 
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_;
147 
148  //- List of face couples
149  PtrList<coupledFacePair> couples_;
150 
151  //- Can the mesh be treated as a shapeMesh?
152  bool isShapeMesh_;
153 
154  // Private static data members
155 
156  //- Error on unity small tolerance
157  static const scalar smallMergeTol_;
158 
159  //- Couple match relative point merge tolerance
160  static const scalar cpMergePointTol_;
161 
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_;
170 
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_;
177 
178  //- Regular addressing data
179  static const label regularAddressingTable[6][8];
180 
181  //- SAMM addressing data
182  static const label sammAddressingTable[9][12];
183 
184  static const label sammFacePermutationTable[24][8];
185 
186  static const label shapeFaceLookup[19][9];
187 
188 
189  // Private Member Functions
190 
191  //- Disallow default bitwise copy construct
192  starMesh(const starMesh&);
193 
194  //- Disallow default bitwise assignment
195  void operator=(const starMesh&);
196 
197 
198  //- read fixed format vertex label
199  static label readVtxLabel(IFstream&);
200 
201  //- read fixed format vertex coordinate component
202  static scalar readVtxCmpt(IFstream&);
203 
204  //- Read to nl
205  static void readToNl(IFstream&);
206 
207  //- Read the points file
208  void readPoints(const scalar scaleFactor);
209 
210  //- Read the cells file
211  void readCells();
212 
213  void addRegularCell
214  (
215  const labelList& labels,
216  const label nCreatedCells
217  );
218 
219  void addSAMMcell
220  (
221  const labelList& labels,
222  const label nCreatedCells
223  );
224 
225  //- Read the boundary file
226  void readBoundary();
227 
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();
231 
232  //- Read couples
233  void readCouples();
234 
235  //- Create couple matches
236  void createCoupleMatches();
237 
238  //- Calculate pointCells
239  void calcPointCells() const;
240 
241  const labelListList& pointCells() const;
242 
243  //- Mark boundary faces from the quads
244  void markBoundaryFaces();
245 
246  //- Collect boundary faces from the quads
247  void collectBoundaryFaces();
248 
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;
256 
257  //- Merge couple face points
258  void mergeCoupleFacePoints();
259 
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  };
267 
268  //- Purge cell shapes
269  void purgeCellShapes();
270 
271  //- Make polyhedral cells and global faces if the mesh is polyhedral
272  void createPolyCells();
273 
274  //- Make polyhedral boundary from shape boundary
275  // (adds more faces to the face list)
276  void createPolyBoundary();
277 
278  //- Make polyhedral mesh data (packing)
279  void createPolyMeshData();
280 
281  //- Add polyhedral boundary
282  List<polyPatch*> polyBoundaryPatches(const polyMesh&);
283 
284  //- Clear extra storage before creation of the mesh to remove
285  // a memory peak
286  void clearExtraStorage();
287 
288 
289 public:
290 
291  // Constructors
292 
293  //- Construct from case name
294  starMesh
295  (
296  const fileName& prefix,
297  const Time& rt,
298  const scalar scaleFactor
299  );
300 
301 
302  // Destructor
303 
304  ~starMesh();
305 
306 
307  // Member Functions
308 
309  //- Write mesh
310  void writeMesh();
311 };
312 
313 
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
315 
316 #endif
317 
318 // ************************ vim: set sw=4 sts=4 et: ************************ //