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
74 
75  //- Database
76  const Time& runTime_;
77 
78  //- Points supporting the mesh
80 
81  //- Cell shapes
83 
84  //- Boundary faces
86 
87  //- Boundary patch types
89 
90  //- Default boundary patch name
92 
93  //- Default boundary patch types
95 
96  //- Boundary patch names
98 
99  //- Boundary patch physical types
101 
102  //- Point labels (STAR point numbering is not necessarily contiguous)
104 
105  //- STAR point number for a given vertex
107 
108  //- STAR Cell number for a given cell
110 
111  //- Cell labels (STAR cell numbering is not necessarily contiguous)
113 
114  //- STAR Cell permutation label
116 
117  //- List of faces for every cell
119 
120  //- Cell ID for every boundary face. Used in two-tier boundary
121  // reconstruction
123 
124  //- Cell face ID for every boundary face. Used in two-tier boundary
125  // reconstruction
127 
128  //- Global face list for polyMesh
130 
131  //- Cells as polyhedra for polyMesh
133 
134  //- Number of internal faces for polyMesh
136 
137  //- Polyhedral mesh boundary patch start indices
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
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  {
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
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 // ************************************************************************* //
Foam::starMesh::boundaryCellFaceIDs_
labelListList boundaryCellFaceIDs_
Cell face ID for every boundary face. Used in two-tier boundary.
Definition: starMesh.H:125
Foam::starMesh::readVtxLabel
static label readVtxLabel(IFstream &)
Read fixed format vertex label.
Foam::starMesh::prismPtr_
static const cellModel * prismPtr_
Definition: starMesh.H:163
Foam::starMesh::pyrPtr_
static const cellModel * pyrPtr_
Definition: starMesh.H:161
Foam::starMesh::nInternalFaces_
label nInternalFaces_
Number of internal faces for polyMesh.
Definition: starMesh.H:134
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::starMesh::tetPtr_
static const cellModel * tetPtr_
Definition: starMesh.H:160
Foam::starMesh::sammTrim3Ptr_
static const cellModel * sammTrim3Ptr_
Definition: starMesh.H:169
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::starMesh::pointIndex::label_
label label_
Definition: starMesh.H:260
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::starMesh::mergeCoupleFacePoints
void mergeCoupleFacePoints()
Merge couple face points.
Foam::starMesh::points_
pointField points_
Points supporting the mesh.
Definition: starMesh.H:78
Foam::IFstream
Input from file stream.
Definition: IFstream.H:81
Foam::starMesh::couples_
PtrList< coupledFacePair > couples_
List of face couples.
Definition: starMesh.H:145
Foam::starMesh::patchPhysicalTypes_
wordList patchPhysicalTypes_
Boundary patch physical types.
Definition: starMesh.H:99
Foam::starMesh::sammTrim4Ptr_
static const cellModel * sammTrim4Ptr_
Definition: starMesh.H:170
Foam::starMesh::sammFacePermutationTable
static const label sammFacePermutationTable[24][8]
Definition: starMesh.H:180
Foam::starMesh::starEqualFace
bool starEqualFace(const face &boundaryFace, const face &cellFace) const
Specialist version of face comparison to deal with.
Foam::starMesh::regularAddressingTable
static const label regularAddressingTable[6][8]
Regular addressing data.
Definition: starMesh.H:175
Foam::starMesh::readVtxCmpt
static scalar readVtxCmpt(IFstream &)
Read fixed format vertex coordinate component.
Foam::starMesh::smallMergeTol_
static const scalar smallMergeTol_
Error on unity small tolerance.
Definition: starMesh.H:153
polyPatchList.H
Foam::starMesh::readCells
void readCells()
Read the cells file.
Foam::starMesh::polyBoundaryPatches
List< polyPatch * > polyBoundaryPatches(const polyMesh &)
Add polyhedral boundary.
Foam::starMesh::meshFaces_
faceList meshFaces_
Global face list for polyMesh.
Definition: starMesh.H:128
Foam::starMesh::addRegularCell
void addRegularCell(const labelList &labels, const label nCreatedCells)
Foam::starMesh::cellShapes_
cellShapeList cellShapes_
Cell shapes.
Definition: starMesh.H:81
Foam::starMesh::sammAddressingTable
static const label sammAddressingTable[9][12]
SAMM addressing data.
Definition: starMesh.H:178
Foam::starMesh::writeMesh
void writeMesh()
Write mesh.
coupledFacePair.H
Foam::starMesh::markBoundaryFaces
void markBoundaryFaces()
Mark boundary faces from the quads.
polyMesh.H
Foam::starMesh::pointCellsPtr_
labelListList * pointCellsPtr_
Point-cell addressing. Used for topological analysis.
Definition: starMesh.H:142
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::starMesh::cellPolys_
cellList cellPolys_
Cells as polyhedra for polyMesh.
Definition: starMesh.H:131
Foam::starMesh::patchNames_
wordList patchNames_
Boundary patch names.
Definition: starMesh.H:96
Foam::starMesh::casePrefix_
fileName casePrefix_
Name of the case.
Definition: starMesh.H:72
Foam::label
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
Foam::starMesh::runTime_
const Time & runTime_
Database.
Definition: starMesh.H:75
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::starMesh::~starMesh
~starMesh()
Destructor.
Foam::starMesh::polyBoundaryPatchStartIndices_
labelList polyBoundaryPatchStartIndices_
Polyhedral mesh boundary patch start indices.
Definition: starMesh.H:137
Foam::starMesh::addSAMMcell
void addSAMMcell(const labelList &labels, const label nCreatedCells)
Foam::starMesh::pointIndex
Point indexing structure used by sort to keep track of.
Definition: starMesh.H:258
Foam::starMesh::calcPointCells
void calcPointCells() const
Calculate pointCells.
Foam::starMesh::pointIndex::index_
double index_
Definition: starMesh.H:261
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
Foam::starMesh::starCellID_
labelList starCellID_
STAR Cell number for a given cell.
Definition: starMesh.H:108
cellList.H
IFstream.H
Foam::starMesh::readCouples
void readCouples()
Read couples.
Foam::starMesh::tetWedgePtr_
static const cellModel * tetWedgePtr_
Definition: starMesh.H:162
Foam::starMesh::sammTrim2Ptr_
static const cellModel * sammTrim2Ptr_
Definition: starMesh.H:168
Foam::starMesh::sammTrim8Ptr_
static const cellModel * sammTrim8Ptr_
Definition: starMesh.H:172
Foam::starMesh::operator=
void operator=(const starMesh &)
Disallow default bitwise assignment.
Foam::starMesh::readPoints
void readPoints(const scalar scaleFactor)
Read the points file.
Foam::starMesh::starCellLabelLookup_
labelList starCellLabelLookup_
Cell labels (STAR cell numbering is not necessarily contiguous)
Definition: starMesh.H:111
Foam::starMesh::isShapeMesh_
bool isShapeMesh_
Can the mesh be treated as a shapeMesh?
Definition: starMesh.H:148
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::starMesh::defaultFacesType_
word defaultFacesType_
Default boundary patch types.
Definition: starMesh.H:93
Foam::starMesh::starMesh
starMesh(const starMesh &)
Disallow default bitwise copy construct.
Foam::starMesh::createPolyBoundary
void createPolyBoundary()
Make polyhedral boundary from shape boundary.
Foam::starMesh::cellFaces_
faceListList cellFaces_
List of faces for every cell.
Definition: starMesh.H:117
Foam::starMesh::clearExtraStorage
void clearExtraStorage()
Clear extra storage before creation of the mesh to remove.
Foam::starMesh::readBoundary
void readBoundary()
Read the boundary file.
Foam::starMesh::hexPtr_
static const cellModel * hexPtr_
Definition: starMesh.H:165
Foam::starMesh::purgeCellShapes
void purgeCellShapes()
Purge cell shapes.
Foam::starMesh::defaultFacesName_
word defaultFacesName_
Default boundary patch name.
Definition: starMesh.H:90
Foam::starMesh::starCellPermutation_
labelList starCellPermutation_
STAR Cell permutation label.
Definition: starMesh.H:114
Foam::starMesh::boundary_
faceListList boundary_
Boundary faces.
Definition: starMesh.H:84
Foam::starMesh::cpMergePointTol_
static const scalar cpMergePointTol_
Couple match relative point merge tolerance.
Definition: starMesh.H:156
Foam::List< cellShape >
Foam::starMesh::sammTrim5Ptr_
static const cellModel * sammTrim5Ptr_
Definition: starMesh.H:171
Foam::starMesh::unknownPtr_
static const cellModel * unknownPtr_
Pointers to cell models.
Definition: starMesh.H:159
Foam::starMesh::collectBoundaryFaces
void collectBoundaryFaces()
Collect boundary faces from the quads.
Foam::starMesh::pointCells
const labelListList & pointCells() const
Foam::starMesh::createPolyCells
void createPolyCells()
Make polyhedral cells and global faces if the mesh is polyhedral.
Foam::starMesh::boundaryCellIDs_
labelListList boundaryCellIDs_
Cell ID for every boundary face. Used in two-tier boundary.
Definition: starMesh.H:121
Foam::starMesh::starPointID_
labelList starPointID_
STAR point number for a given vertex.
Definition: starMesh.H:105
Foam::starMesh::sammTrim1Ptr_
static const cellModel * sammTrim1Ptr_
Definition: starMesh.H:167
cellShape.H
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Foam::cellModel
Maps a geometry to a set of cell primitives, which enables geometric cell data to be calculated witho...
Definition: cellModel.H:64
Foam::starMesh::createCoupleMatches
void createCoupleMatches()
Create couple matches.
Foam::starMesh
A messy mesh class which supports the possibility of creating a shapeMesh for regular Star meshes (no...
Definition: starMesh.H:67
Foam::starMesh::fixCollapsedEdges
void fixCollapsedEdges()
Check and correct collapsed edges on faces.
Foam::starMesh::starPointLabelLookup_
labelList starPointLabelLookup_
Point labels (STAR point numbering is not necessarily contiguous)
Definition: starMesh.H:102
Foam::starMesh::patchTypes_
wordList patchTypes_
Boundary patch types.
Definition: starMesh.H:87
Foam::starMesh::createPolyMeshData
void createPolyMeshData()
Make polyhedral mesh data (packing)
Foam::starMesh::readToNl
static void readToNl(IFstream &)
Read to nl.
Foam::starMesh::shapeFaceLookup
static const label shapeFaceLookup[19][9]
Definition: starMesh.H:182
Foam::starMesh::wedgePtr_
static const cellModel * wedgePtr_
Definition: starMesh.H:164