1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
24 \*---------------------------------------------------------------------------*/
27 #include "emptyPolyPatch.H"
28 #include "demandDrivenData.H"
29 #include "cellModeller.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 const cellModel* sammMesh::unknownPtr_ = cellModeller::lookup("unknown");
35 const cellModel* sammMesh::hexPtr_ = cellModeller::lookup("hex");
36 const cellModel* sammMesh::wedgePtr_ = cellModeller::lookup("wedge");
37 const cellModel* sammMesh::prismPtr_ = cellModeller::lookup("prism");
38 const cellModel* sammMesh::pyrPtr_ = cellModeller::lookup("pyr");
39 const cellModel* sammMesh::tetPtr_ = cellModeller::lookup("tet");
40 const cellModel* sammMesh::tetWedgePtr_ = cellModeller::lookup("tetWedge");
42 const cellModel* sammMesh::sammTrim1Ptr_ = cellModeller::lookup("sammTrim1");
43 const cellModel* sammMesh::sammTrim2Ptr_ = cellModeller::lookup("sammTrim2");
44 const cellModel* sammMesh::sammTrim3Ptr_ = cellModeller::lookup("sammTrim3");
45 const cellModel* sammMesh::sammTrim4Ptr_ = cellModeller::lookup("sammTrim4");
46 const cellModel* sammMesh::sammTrim5Ptr_ = cellModeller::lookup("sammTrim5");
47 const cellModel* sammMesh::sammTrim8Ptr_ =
48 cellModeller::lookup("hexagonalPrism");
50 // lookup table giving OpenFOAM face number when looked up with shape index
51 // (first index) and STAR face number
52 // - first column is always -1
53 // - last column is -1 for all but hexagonal prism
54 // WARNING: Possible bug for sammTrim2
55 // There is a possibility that the lookup table for SAMM shapes is based on
56 // the rotation of the shape. This would imply that the table below would need
57 // to be split between the regular shapes (3-9), which are OK, and the SAMM
58 // shapes, for which the face lookup needs to be done based on the rotation.
59 // However, at the moment I haven't got enough info to complete the toble and
60 // there are no cases that break it. Please reconsider in the light of mode
62 const label sammMesh::shapeFaceLookup[19][9] =
64 {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 0 - empty+
65 {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 1 - empty+
66 {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 2 - empty+
67 {-1, 4, 5, 2, 3, 0, 1, -1, -1}, // shape 3 - hex+
68 {-1, 4, 5, 2, 3, 0, 1, -1, -1}, // shape 4 - wedge+
69 {-1, 0, 1, 4, -1, 2, 3, -1, -1}, // shape 5 - prism+
70 {-1, 0, -1, 4, 2, 1, 3, -1, -1}, // shape 6 - pyr+
71 {-1, 3, -1, 2, -1, 1, 0, -1, -1}, // shape 7 - tet+
72 {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 8 - splitHex (empty)
73 {-1, 0, -1, 1, -1, 2, 3, -1, -1}, // shape 9 - tetWedge+
74 {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 10 - empty+
75 {-1, 5, 4, 0, 1, 2, 3, 6, -1}, // shape 11 - sammTrim1+
76 // {-1, 1, 0, 2, 3, 4, 5, 6, -1}, // shape 12 - sammTrim2 ?
77 {-1, 1, 0, 2, 4, 3, 5, 6, -1}, // shape 12 - sammTrim2 f(4)=4
78 {-1, 5, 4, 0, 1, 2, 3, 6, -1}, // shape 13 - sammTrim3+
79 {-1, 5, 4, 1, 0, 3, 2, 6, -1}, // shape 14 - sammTrim4
80 {-1, 4, 3, 2, 5, 1, 0, -1, -1}, // shape 15 - sammTrim5
81 {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 16 - empty
82 {-1, -1, -1, -1, -1, -1, -1, -1, -1}, // shape 17 - empty
83 {-1, 0, 1, 2, 5, 3, 6, 4, 7} // shape 18 - sammTrim8
86 // SAMM cell lookup data
88 // List of pointers used instead of pointer list o avoid
89 // de-allocation problems
90 List<const cellModel*> sammMesh::sammShapeLookup
93 reinterpret_cast<cellModel*>(0)
96 List<const label*> sammMesh::sammAddressingTable
99 reinterpret_cast<label*>(0)
102 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
104 // Make polyhedral mesh data (packing)
105 void sammMesh::createPolyMeshData()
107 Info<< "Creating a polyMesh" << endl;
111 Info<< "\nNumber of internal faces: "
112 << nInternalFaces_ << endl;
114 createPolyBoundary();
116 label nProblemCells = 0;
118 // check that there is no zeros in the cellPolys_
119 forAll(cellPolys_, cellI)
121 const labelList& curFaceLabels = cellPolys_[cellI];
123 forAll(curFaceLabels, faceI)
125 if (curFaceLabels[faceI] == -1)
127 Info<< "cell " << cellI
128 << " has got an unmatched face. "
129 << "Index: " << cellShapes_[cellI].model().index() << endl
130 // << "cell shape: " << cellShapes_[cellI] << endl
131 // << "shape faces: " << cellShapes_[cellI].faces() << endl
132 << "cellPolys: " << cellPolys_[cellI] << endl
133 // << "cell faces: " << cellFaces_[cellI]
143 if (nProblemCells > 0)
145 Info<< "Number of problem cells: " << nProblemCells << endl;
149 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
151 // Construct from components
154 const fileName& prefix,
156 const scalar scaleFactor
165 defaultFacesName_("defaultFaces"),
166 defaultFacesType_(emptyPolyPatch::typeName),
168 patchPhysicalTypes_(0),
169 starPointLabelLookup_(0),
170 starCellLabelLookup_(0),
175 polyBoundaryPatchStartIndices_(0),
176 pointCellsPtr_(NULL),
179 // Fill in the lookup tables
180 fillSammCellShapeTable();
181 fillSammAddressingTable();
183 readPoints(scaleFactor);
193 // create boundary faces
194 createBoundaryFaces();
196 // after all this is done do couples
200 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
202 sammMesh::~sammMesh()
204 deleteDemandDrivenData(pointCellsPtr_);
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 // ************************************************************************* //