1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "hexMatcher.H"
28 #include "primitiveMesh.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 const Foam::label Foam::hexMatcher::vertPerCell = 8;
33 const Foam::label Foam::hexMatcher::facePerCell = 6;
34 const Foam::label Foam::hexMatcher::maxVertPerFace = 4;
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 Foam::hexMatcher::hexMatcher()
52 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
54 Foam::hexMatcher::~hexMatcher()
58 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
60 bool Foam::hexMatcher::matchShape
63 const faceList& faces,
64 const labelList& owner,
66 const labelList& myFaces
69 if (!faceSizeMatch(faces, myFaces))
74 // Is hex for sure since all faces are quads
81 // Calculate localFaces_ and mapping pointMap_, faceMap_
82 label numVert = calcLocalFaces(faces, myFaces);
84 if (numVert != vertPerCell)
89 // Set up 'edge' to face mapping.
90 calcEdgeAddressing(numVert);
92 // Set up point on face to index-in-face mapping
95 // Storage for maps -vertex to mesh and -face to mesh
96 vertLabels_.setSize(vertPerCell);
97 faceLabels_.setSize(facePerCell);
100 // Try bottom face (face 4).
101 // Only need to try one orientation of this face since hex is
102 // rotation symmetric
107 const face& face4 = localFaces_[face4I];
108 label face4vert0 = 0;
110 vertLabels_[0] = pointMap_[face4[face4vert0]];
111 faceLabels_[4] = faceMap_[face4I];
113 // Walk face 4 from vertex 0 to 1
119 !(owner[faceMap_[face4I]] == cellI)
121 vertLabels_[1] = pointMap_[face4[face4vert1]];
123 // Walk face 4 from vertex 1 to 2
129 !(owner[faceMap_[face4I]] == cellI)
131 vertLabels_[2] = pointMap_[face4[face4vert2]];
133 // Walk face 4 from vertex 2 to 3
139 !(owner[faceMap_[face4I]] == cellI)
141 vertLabels_[3] = pointMap_[face4[face4vert3]];
143 // Jump edge from face4 to face0
152 faceLabels_[0] = faceMap_[face0I];
153 const face& face0 = localFaces_[face0I];
155 label face0vert0 = pointFaceIndex_[face4[face4vert0]][face0I];
157 // Walk face 0 from vertex 0 to 4
163 (owner[faceMap_[face0I]] == cellI)
165 vertLabels_[4] = pointMap_[face0[face0vert4]];
167 // Walk face 0 from vertex 4 to 7
173 (owner[faceMap_[face0I]] == cellI)
175 vertLabels_[7] = pointMap_[face0[face0vert7]];
177 // Jump edge from face0 to face5
186 const face& face5 = localFaces_[face5I];
187 faceLabels_[5] = faceMap_[face5I];
189 label face5vert4 = pointFaceIndex_[face0[face0vert4]][face5I];
191 // Walk face 5 from vertex 4 to 5
197 (owner[faceMap_[face5I]] == cellI)
199 vertLabels_[5] = pointMap_[face5[face5vert5]];
201 // Walk face 5 from vertex 5 to 6
207 (owner[faceMap_[face5I]] == cellI)
209 vertLabels_[6] = pointMap_[face5[face5vert6]];
211 // Jump edge from face4 to face2
220 faceLabels_[2] = faceMap_[face2I];
222 // Jump edge from face4 to face1
231 faceLabels_[1] = faceMap_[face1I];
233 // Jump edge from face4 to face3
242 faceLabels_[3] = faceMap_[face3I];
248 Foam::label Foam::hexMatcher::faceHashValue() const
250 return facePerCell*vertPerCell;
254 bool Foam::hexMatcher::faceSizeMatch
256 const faceList& faces,
257 const labelList& myFaces
260 if (myFaces.size() != facePerCell)
265 forAll(myFaces, myFaceI)
267 label size = faces[myFaces[myFaceI]].size();
279 bool Foam::hexMatcher::isA(const primitiveMesh& mesh, const label cellI)
292 bool Foam::hexMatcher::isA(const faceList& faces)
294 // Do as if mesh with one cell only
298 faces, // all faces in mesh
299 labelList(faces.size(), 0), // cell 0 is owner of all faces
301 makeIdentity(faces.size()) // faces of cell 0
306 bool Foam::hexMatcher::matches
308 const primitiveMesh& mesh,
325 shape = cellShape(model(), vertLabels());
336 // ************************************************************************* //