FreeFOAM The Cross-Platform CFD Toolkit
sammMesh.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::sammMesh
26 
27 Description
28  A messy mesh class which supports the possibility of creating a shapeMesh
29  for regular Samm 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  sammMesh.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef sammMesh_H
38 #define sammMesh_H
39 
40 #include <OpenFOAM/polyMesh.H>
41 #include <OpenFOAM/cellShape.H>
42 #include <OpenFOAM/cellList.H>
43 #include <OpenFOAM/polyPatchList.H>
44 
45 #ifndef namespaceFoam
46 #define namespaceFoam
47  using namespace Foam;
48 #endif
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 // Forward declaration of classes
53 
54 /*---------------------------------------------------------------------------*\
55  Class sammMesh Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class sammMesh
59 {
60  // Private data
61 
62  //- Name of the case
63  fileName casePrefix_;
64 
65  //- Database
66  const Time& runTime_;
67 
68  //- Points supporting the mesh
69  pointField points_;
70 
71  //- Cell shapes
72  cellShapeList cellShapes_;
73 
74  //- Boundary faces
75  faceListList boundary_;
76 
77  //- Boundary patch types
78  wordList patchTypes_;
79 
80  //- Default boundary patch name
81  word defaultFacesName_;
82 
83  //- Default boundary patch types
84  word defaultFacesType_;
85 
86  //- Boundary patch names
87  wordList patchNames_;
88 
89  //- Boundary patch physical types
90  wordList patchPhysicalTypes_;
91 
92  //- Point labels (SAMM point numbering is not necessarily contiguous)
93  labelList starPointLabelLookup_;
94 
95  //- Point labels (SAMM point numbering is not necessarily contiguous)
96  labelList starCellLabelLookup_;
97 
98  //- List of faces for every cell
99  faceListList cellFaces_;
100 
101  //- Global face list for polyMesh
102  faceList meshFaces_;
103 
104  //- Cells as polyhedra for polyMesh
105  cellList cellPolys_;
106 
107  //- Number of internal faces for polyMesh
108  label nInternalFaces_;
109 
110  //- Polyhedral mesh boundary patch start indices
111  labelList polyBoundaryPatchStartIndices_;
112 
113  //- Point-cell addressing. Used for topological analysis
114  // Warning. This point cell addressing list potentially contains
115  // duplicate cell entries. Use additional checking
116  mutable labelListList* pointCellsPtr_;
117 
118  //- Can the mesh be treated as a shapeMesh?
119  bool isShapeMesh_;
120 
121  // Private static data members
122 
123  //- Pointers to cell models
124  static const cellModel* unknownPtr_;
125  static const cellModel* hexPtr_;
126  static const cellModel* wedgePtr_;
127  static const cellModel* prismPtr_;
128  static const cellModel* pyrPtr_;
129  static const cellModel* tetPtr_;
130  static const cellModel* tetWedgePtr_;
131 
132  static const cellModel* sammTrim1Ptr_;
133  static const cellModel* sammTrim2Ptr_;
134  static const cellModel* sammTrim3Ptr_;
135  static const cellModel* sammTrim4Ptr_;
136  static const cellModel* sammTrim5Ptr_;
137  static const cellModel* sammTrim8Ptr_;
138 
139  static const label shapeFaceLookup[19][9];
140 
141 
142  //- SAMM addressing data
143  static List<const cellModel*> sammShapeLookup;
144  static List<const label*> sammAddressingTable;
145 
146  // Private Member Functions
147 
148  //- Disallow default bitwise copy construct
149  sammMesh(const sammMesh&);
150 
151  //- Disallow default bitwise assignment
152  void operator=(const sammMesh&);
153 
154 
155  //- Fill SAMM lookup tables
156  void fillSammCellShapeTable();
157  void fillSammAddressingTable();
158 
159 
160  //- Read the points file
161  void readPoints(const scalar scaleFactor);
162 
163 
164  //- Read the cells file
165  void readCells();
166 
167  void addRegularCell
168  (
169  const labelList& labels,
170  const label nCreatedCells
171  );
172 
173  void addSAMMcell
174  (
175  const label typeFlag,
176  const labelList& globalLabels,
177  const label nCreatedCells
178  );
179 
180 
181  //- Read the boundary file
182  void readBoundary();
183 
184 
185  //- Check and correct collapsed edges on faces
186  // Note. If a collapsed edge is found, the mesh is no longer shapeMesh
187  void fixCollapsedEdges();
188 
189  //- Read couples
190  void readCouples();
191 
192  //- Calculate pointCells
193  void calcPointCells() const;
194 
195  const labelListList& pointCells() const;
196 
197  //- Create boundary faces from the quads
198  void createBoundaryFaces();
199 
200  //- Specialist version of face comparison to deal with
201  // PROSTAR boundary format idiosyncracies
202  bool sammEqualFace
203  (
204  const face& boundaryFace,
205  const face& cellFace
206  ) const;
207 
208  //- Purge cell shapes
209  void purgeCellShapes();
210 
211  //- Make polyhedral cells and global faces if the mesh is polyhedral
212  void createPolyCells();
213 
214  //- Make polyhedral boundary from shape boundary
215  // (adds more faces to the face list)
216  void createPolyBoundary();
217 
218  //- Make polyhedral mesh data (packing)
219  void createPolyMeshData();
220 
221  //- Add polyhedral boundary
222  List<polyPatch* > polyBoundaryPatches(const polyMesh&);
223 
224 
225 public:
226 
227  // Static data members
228 
229 
230  // Constructors
231 
232  //- Construct from case name
233  sammMesh
234  (
235  const fileName& prefix,
236  const Time& rt,
237  const scalar scaleFactor
238  );
239 
240 
241  // Destructor
242 
243  ~sammMesh();
244 
245 
246  // Member Functions
247 
248  //- Write mesh
249  void writeMesh();
250 
251  // Member Operators
252 
253  // Friend Functions
254 
255  // Friend Operators
256 
257  // IOstream Operators
258  // Ostream Operator
259 };
260 
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 #endif
265 
266 // ************************ vim: set sw=4 sts=4 et: ************************ //