starMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 features 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  //- Read fixed format vertex label
189  static label readVtxLabel(IFstream&);
190 
191  //- Read fixed format vertex coordinate component
192  static scalar readVtxCmpt(IFstream&);
193 
194  //- Read to nl
195  static void readToNl(IFstream&);
196 
197  //- Read the points file
198  void readPoints(const scalar scaleFactor);
199 
200  //- Read the cells file
201  void readCells();
202 
203  void addRegularCell
204  (
205  const labelList& labels,
206  const label nCreatedCells
207  );
208 
209  void addSAMMcell
210  (
211  const labelList& labels,
212  const label nCreatedCells
213  );
214 
215  //- Read the boundary file
216  void readBoundary();
217 
218  //- Check and correct collapsed edges on faces
219  // Note. If a collapsed edge is found, the mesh is no longer shapeMesh
220  void fixCollapsedEdges();
221 
222  //- Read couples
223  void readCouples();
224 
225  //- Create couple matches
226  void createCoupleMatches();
227 
228  //- Calculate pointCells
229  void calcPointCells() const;
230 
231  const labelListList& pointCells() const;
232 
233  //- Mark boundary faces from the quads
234  void markBoundaryFaces();
235 
236  //- Collect boundary faces from the quads
237  void collectBoundaryFaces();
238 
239  //- Specialist version of face comparison to deal with
240  // PROSTAR boundary format idiosyncracies
241  bool starEqualFace
242  (
243  const face& boundaryFace,
244  const face& cellFace
245  ) const;
246 
247  //- Merge couple face points
248  void mergeCoupleFacePoints();
249 
250  //- Point indexing structure used by sort to keep track of
251  // the point labels
252  struct pointIndex
253  {
254  label label_;
255  double index_;
256  };
257 
258  //- Purge cell shapes
259  void purgeCellShapes();
260 
261  //- Make polyhedral cells and global faces if the mesh is polyhedral
262  void createPolyCells();
263 
264  //- Make polyhedral boundary from shape boundary
265  // (adds more faces to the face list)
266  void createPolyBoundary();
267 
268  //- Make polyhedral mesh data (packing)
269  void createPolyMeshData();
270 
271  //- Add polyhedral boundary
272  List<polyPatch*> polyBoundaryPatches(const polyMesh&);
273 
274  //- Clear extra storage before creation of the mesh to remove
275  // a memory peak
276  void clearExtraStorage();
277 
278 
279 public:
280 
281  // Constructors
282 
283  //- Construct from case name
284  starMesh
285  (
286  const fileName& prefix,
287  const Time& rt,
288  const scalar scaleFactor
289  );
290 
291  //- Disallow default bitwise copy construction
292  starMesh(const starMesh&) = delete;
293 
294 
295  //- Destructor
296  ~starMesh();
297 
298 
299  // Member Functions
300 
301  //- Write mesh
302  void writeMesh();
303 
304 
305  // Member Operators
306 
307  //- Disallow default bitwise assignment
308  void operator=(const starMesh&) = delete;
309 };
310 
311 
312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 
314 } // End namespace Foam
315 
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317 
318 #endif
319 
320 // ************************************************************************* //
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:79
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
starMesh(const fileName &prefix, const Time &rt, const scalar scaleFactor)
Construct from case name.
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:70
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
void operator=(const starMesh &)=delete
Disallow default bitwise assignment.
Namespace for OpenFOAM.