sammMesh.C
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 \*---------------------------------------------------------------------------*/
25 
26 #include "sammMesh.H"
27 #include "emptyPolyPatch.H"
28 #include "demandDrivenData.H"
29 #include "cellModeller.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 // Cell shape models
35  Foam::cellModeller::lookup("unknown");
47  Foam::cellModeller::lookup("tetWedge");
48 
50  Foam::cellModeller::lookup("sammTrim1");
52  Foam::cellModeller::lookup("sammTrim2");
54  Foam::cellModeller::lookup("sammTrim3");
56  Foam::cellModeller::lookup("sammTrim4");
58  Foam::cellModeller::lookup("sammTrim5");
60  Foam::cellModeller::lookup("hexagonalPrism");
61 
62 // lookup table giving OpenFOAM face number when looked up with shape index
63 // (first index) and STAR face number
64 // - first column is always -1
65 // - last column is -1 for all but hexagonal prism
66 // WARNING: Possible bug for sammTrim2
67 // There is a possibility that the lookup table for SAMM shapes is based on
68 // the rotation of the shape. This would imply that the table below would need
69 // to be split between the regular shapes (3-9), which are OK, and the SAMM
70 // shapes, for which the face lookup needs to be done based on the rotation.
71 // However, at the moment I haven't got enough info to complete the toble and
72 // there are no cases that break it. Please reconsider in the light of mode
73 // information.
75 {
76  {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 0 - empty+
77  {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 1 - empty+
78  {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 2 - empty+
79  {-1, 4, 5, 2, 3, 0, 1, -1, -1}, // shape 3 - hex+
80  {-1, 4, 5, 2, 3, 0, 1, -1, -1}, // shape 4 - wedge+
81  {-1, 0, 1, 4, -1, 2, 3, -1, -1}, // shape 5 - prism+
82  {-1, 0, -1, 4, 2, 1, 3, -1, -1}, // shape 6 - pyr+
83  {-1, 3, -1, 2, -1, 1, 0, -1, -1}, // shape 7 - tet+
84  {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 8 - splitHex (empty)
85  {-1, 0, -1, 1, -1, 2, 3, -1, -1}, // shape 9 - tetWedge+
86  {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 10 - empty+
87  {-1, 5, 4, 0, 1, 2, 3, 6, -1}, // shape 11 - sammTrim1+
88 // {-1, 1, 0, 2, 3, 4, 5, 6, -1}, // shape 12 - sammTrim2 ?
89  {-1, 1, 0, 2, 4, 3, 5, 6, -1}, // shape 12 - sammTrim2 f(4)=4
90  {-1, 5, 4, 0, 1, 2, 3, 6, -1}, // shape 13 - sammTrim3+
91  {-1, 5, 4, 1, 0, 3, 2, 6, -1}, // shape 14 - sammTrim4
92  {-1, 4, 3, 2, 5, 1, 0, -1, -1}, // shape 15 - sammTrim5
93  {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 16 - empty
94  {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 17 - empty
95  {-1, 0, 1, 2, 5, 3, 6, 4, 7} // shape 18 - sammTrim8
96 };
97 
98 // SAMM cell lookup data
99 
100 // List of pointers used instead of pointer list o avoid
101 // de-allocation problems
103 (
104  256,
105  reinterpret_cast<cellModel*>(0)
106 );
107 
109 (
110  256,
111  reinterpret_cast<label*>(0)
112 );
113 
114 
115 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
116 
118 {
119  Info<< "Creating a polyMesh" << endl;
120 
121  createPolyCells();
122 
123  Info<< "\nNumber of internal faces: "
124  << nInternalFaces_ << endl;
125 
127 
128  label nProblemCells = 0;
129 
130  // check that there is no zeros in the cellPolys_
131  forAll(cellPolys_, cellI)
132  {
133  const labelList& curFaceLabels = cellPolys_[cellI];
134 
135  forAll(curFaceLabels, faceI)
136  {
137  if (curFaceLabels[faceI] == -1)
138  {
139  Info<< "cell " << cellI
140  << " has got an unmatched face. "
141  << "Index: " << cellShapes_[cellI].model().index() << endl
142 // << "cell shape: " << cellShapes_[cellI] << endl
143 // << "shape faces: " << cellShapes_[cellI].faces() << endl
144  << "cellPolys: " << cellPolys_[cellI] << endl
145 // << "cell faces: " << cellFaces_[cellI]
146  << endl;
147 
148  nProblemCells++;
149 
150  break;
151  }
152  }
153  }
154 
155  if (nProblemCells > 0)
156  {
157  Info<< "Number of problem cells: " << nProblemCells << endl;
158  }
159 }
160 
161 
162 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
163 
165 (
166  const fileName& prefix,
167  const Time& rt,
168  const scalar scaleFactor
169 )
170 :
171  casePrefix_(prefix),
172  runTime_(rt),
173  points_(0),
174  cellShapes_(0),
175  boundary_(0),
176  patchTypes_(0),
177  defaultFacesName_("defaultFaces"),
178  defaultFacesType_(emptyPolyPatch::typeName),
179  patchNames_(0),
180  patchPhysicalTypes_(0),
181  starPointLabelLookup_(0),
182  starCellLabelLookup_(0),
183  cellFaces_(0),
184  meshFaces_(0),
185  cellPolys_(0),
186  nInternalFaces_(0),
187  polyBoundaryPatchStartIndices_(0),
188  pointCellsPtr_(NULL),
189  isShapeMesh_(true)
190 {
191  // Fill in the lookup tables
192  fillSammCellShapeTable();
193  fillSammAddressingTable();
194 
195  readPoints(scaleFactor);
196 
197  readCells();
198 
199  readBoundary();
200 
201  fixCollapsedEdges();
202 
203  readCouples();
204 
205  // create boundary faces
206  createBoundaryFaces();
207 
208  // after all this is done do couples
209 }
210 
211 
212 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
213 
215 {
217 }
218 
219 
220 // ************************************************************************* //
Foam::sammMesh::tetWedgePtr_
static const cellModel * tetWedgePtr_
Definition: sammMesh.H:125
Foam::sammMesh::nInternalFaces_
label nInternalFaces_
Number of internal faces for polyMesh.
Definition: sammMesh.H:103
Foam::sammMesh::createPolyMeshData
void createPolyMeshData()
Make polyhedral mesh data (packing)
Foam::labelList
List< label > labelList
A List of labels.
Definition: labelList.H:56
Foam::sammMesh::cellPolys_
cellList cellPolys_
Cells as polyhedra for polyMesh.
Definition: sammMesh.H:100
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::sammMesh::cellShapes_
cellShapeList cellShapes_
Cell shapes.
Definition: sammMesh.H:67
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::sammMesh::unknownPtr_
static const cellModel * unknownPtr_
Pointers to cell models.
Definition: sammMesh.H:119
Foam::sammMesh::sammTrim1Ptr_
static const cellModel * sammTrim1Ptr_
Definition: sammMesh.H:127
Foam::sammMesh::sammTrim2Ptr_
static const cellModel * sammTrim2Ptr_
Definition: sammMesh.H:128
Foam::sammMesh::sammTrim3Ptr_
static const cellModel * sammTrim3Ptr_
Definition: sammMesh.H:129
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::sammMesh::pyrPtr_
static const cellModel * pyrPtr_
Definition: sammMesh.H:123
Foam::sammMesh::wedgePtr_
static const cellModel * wedgePtr_
Definition: sammMesh.H:121
Foam::sammMesh::tetPtr_
static const cellModel * tetPtr_
Definition: sammMesh.H:124
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:40
Foam::sammMesh::pointCellsPtr_
labelListList * pointCellsPtr_
Point-cell addressing. Used for topological analysis.
Definition: sammMesh.H:111
cellModeller.H
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::sammMesh::createPolyCells
void createPolyCells()
Make polyhedral cells and global faces if the mesh is polyhedral.
Foam::Info
messageStream Info
Foam::cellModeller::lookup
static const cellModel * lookup(const word &)
Look up a model by name and return a pointer to the model or NULL.
Definition: cellModeller.C:91
Foam::sammMesh::sammTrim8Ptr_
static const cellModel * sammTrim8Ptr_
Definition: sammMesh.H:132
emptyPolyPatch.H
Foam::sammMesh::~sammMesh
~sammMesh()
Destructor.
Foam::sammMesh::prismPtr_
static const cellModel * prismPtr_
Definition: sammMesh.H:122
Foam::sammMesh::shapeFaceLookup
static const label shapeFaceLookup[19][9]
Definition: sammMesh.H:134
sammMesh.H
Foam::List< const Foam::cellModel * >
Foam::sammMesh::sammMesh
sammMesh(const sammMesh &)
Disallow default bitwise copy construct.
Foam::sammMesh::hexPtr_
static const cellModel * hexPtr_
Definition: sammMesh.H:120
Foam::sammMesh::sammShapeLookup
static List< const cellModel * > sammShapeLookup
SAMM addressing data.
Definition: sammMesh.H:138
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::sammMesh::createPolyBoundary
void createPolyBoundary()
Make polyhedral boundary from shape boundary.
Foam::sammMesh::sammAddressingTable
static List< const label * > sammAddressingTable
Definition: sammMesh.H:139
Foam::sammMesh::sammTrim5Ptr_
static const cellModel * sammTrim5Ptr_
Definition: sammMesh.H:131
Foam::sammMesh::sammTrim4Ptr_
static const cellModel * sammTrim4Ptr_
Definition: sammMesh.H:130