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) 2011-2015 OpenFOAM Foundation
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 "polyMesh.H"
53 #include "cellShape.H"
54 #include "cellList.H"
55 #include "polyPatchList.H"
56 #include "coupledFacePair.H"
57 #include "IFstream.H"
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 namespace Foam
62 {
63 
64 /*---------------------------------------------------------------------------*\
65  Class starMesh Declaration
66 \*---------------------------------------------------------------------------*/
67 
68 class starMesh
69 {
70  // Private data
71 
72  //- Name of the case
73  fileName casePrefix_;
74 
75  //- Database
76  const Time& runTime_;
77 
78  //- Points supporting the mesh
79  pointField points_;
80 
81  //- Cell shapes
82  cellShapeList cellShapes_;
83 
84  //- Boundary faces
85  faceListList boundary_;
86 
87  //- Boundary patch types
88  wordList patchTypes_;
89 
90  //- Default boundary patch name
91  word defaultFacesName_;
92 
93  //- Default boundary patch types
94  word defaultFacesType_;
95 
96  //- Boundary patch names
97  wordList patchNames_;
98 
99  //- Boundary patch physical types
100  wordList patchPhysicalTypes_;
101 
102  //- Point labels (STAR point numbering is not necessarily contiguous)
103  labelList starPointLabelLookup_;
104 
105  //- STAR point number for a given vertex
106  labelList starPointID_;
107 
108  //- STAR Cell number for a given cell
109  labelList starCellID_;
110 
111  //- Cell labels (STAR cell numbering is not necessarily contiguous)
112  labelList starCellLabelLookup_;
113 
114  //- STAR Cell permutation label
115  labelList starCellPermutation_;
116 
117  //- List of faces for every cell
118  faceListList cellFaces_;
119 
120  //- Cell ID for every boundary face. Used in two-tier boundary
121  // reconstruction
122  labelListList boundaryCellIDs_;
123 
124  //- Cell face ID for every boundary face. Used in two-tier boundary
125  // reconstruction
126  labelListList boundaryCellFaceIDs_;
127 
128  //- Global face list for polyMesh
129  faceList meshFaces_;
130 
131  //- Cells as polyhedra for polyMesh
132  cellList cellPolys_;
133 
134  //- Number of internal faces for polyMesh
135  label nInternalFaces_;
136 
137  //- Polyhedral mesh boundary patch start indices
138  labelList polyBoundaryPatchStartIndices_;
139 
140  //- Point-cell addressing. Used for topological analysis
141  // Warning. This point cell addressing list potentially contains
142  // duplicate cell entries. Use additional checking
143  mutable labelListList* pointCellsPtr_;
144 
145  //- List of face couples
146  PtrList<coupledFacePair> couples_;
147 
148  //- Can the mesh be treated as a shapeMesh?
149  bool isShapeMesh_;
150 
151  // Private static data members
152 
153  //- Error on unity small tolerance
154  static const scalar smallMergeTol_;
155 
156  //- Couple match relative point merge tolerance
157  static const scalar cpMergePointTol_;
158 
159  //- Pointers to cell models
160  static const cellModel* unknownPtr_;
161  static const cellModel* tetPtr_;
162  static const cellModel* pyrPtr_;
163  static const cellModel* tetWedgePtr_;
164  static const cellModel* prismPtr_;
165  static const cellModel* wedgePtr_;
166  static const cellModel* hexPtr_;
167 
168  static const cellModel* sammTrim1Ptr_;
169  static const cellModel* sammTrim2Ptr_;
170  static const cellModel* sammTrim3Ptr_;
171  static const cellModel* sammTrim4Ptr_;
172  static const cellModel* sammTrim5Ptr_;
173  static const cellModel* sammTrim8Ptr_;
174 
175  //- Regular addressing data
176  static const label regularAddressingTable[6][8];
177 
178  //- SAMM addressing data
179  static const label sammAddressingTable[9][12];
180 
181  static const label sammFacePermutationTable[24][8];
182 
183  static const label shapeFaceLookup[19][9];
184 
185 
186  // Private Member Functions
187 
188  //- Disallow default bitwise copy construct
189  starMesh(const starMesh&);
190 
191  //- Disallow default bitwise assignment
192  void operator=(const starMesh&);
193 
194 
195  //- Read fixed format vertex label
196  static label readVtxLabel(IFstream&);
197 
198  //- Read fixed format vertex coordinate component
199  static scalar readVtxCmpt(IFstream&);
200 
201  //- Read to nl
202  static void readToNl(IFstream&);
203 
204  //- Read the points file
205  void readPoints(const scalar scaleFactor);
206 
207  //- Read the cells file
208  void readCells();
209 
210  void addRegularCell
211  (
212  const labelList& labels,
213  const label nCreatedCells
214  );
215 
216  void addSAMMcell
217  (
218  const labelList& labels,
219  const label nCreatedCells
220  );
221 
222  //- Read the boundary file
223  void readBoundary();
224 
225  //- Check and correct collapsed edges on faces
226  // Note. If a collapsed edge is found, the mesh is no longer shapeMesh
227  void fixCollapsedEdges();
228 
229  //- Read couples
230  void readCouples();
231 
232  //- Create couple matches
233  void createCoupleMatches();
234 
235  //- Calculate pointCells
236  void calcPointCells() const;
237 
238  const labelListList& pointCells() const;
239 
240  //- Mark boundary faces from the quads
241  void markBoundaryFaces();
242 
243  //- Collect boundary faces from the quads
244  void collectBoundaryFaces();
245 
246  //- Specialist version of face comparison to deal with
247  // PROSTAR boundary format idiosyncracies
248  bool starEqualFace
249  (
250  const face& boundaryFace,
251  const face& cellFace
252  ) const;
253 
254  //- Merge couple face points
255  void mergeCoupleFacePoints();
256 
257  //- Point indexing structure used by sort to keep track of
258  // the point labels
259  struct pointIndex
260  {
261  label label_;
262  double index_;
263  };
264 
265  //- Purge cell shapes
266  void purgeCellShapes();
267 
268  //- Make polyhedral cells and global faces if the mesh is polyhedral
269  void createPolyCells();
270 
271  //- Make polyhedral boundary from shape boundary
272  // (adds more faces to the face list)
273  void createPolyBoundary();
274 
275  //- Make polyhedral mesh data (packing)
276  void createPolyMeshData();
277 
278  //- Add polyhedral boundary
279  List<polyPatch*> polyBoundaryPatches(const polyMesh&);
280 
281  //- Clear extra storage before creation of the mesh to remove
282  // a memory peak
283  void clearExtraStorage();
284 
285 
286 public:
287 
288  // Constructors
289 
290  //- Construct from case name
291  starMesh
292  (
293  const fileName& prefix,
294  const Time& rt,
295  const scalar scaleFactor
296  );
297 
298 
299  //- Destructor
300  ~starMesh();
301 
302 
303  // Member Functions
304 
305  //- Write mesh
306  void writeMesh();
307 };
308 
309 
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 
312 } // End namespace Foam
313 
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
315 
316 #endif
317 
318 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A class for handling file names.
Definition: fileName.H:69
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
void writeMesh()
Write mesh.
A class for handling words, derived from string.
Definition: word.H:59
~starMesh()
Destructor.
Input from file stream.
Definition: IFstream.H:81
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:62
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
Definition: cellModel.H:64
A messy mesh class which supports the possibility of creating a shapeMesh for regular Star meshes (no...
Definition: starMesh.H:67
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.