1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
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 \*---------------------------------------------------------------------------*/
26 #include "tetWedgeMatcher.H"
27 #include "cellMatcher.H"
28 #include "primitiveMesh.H"
29 #include "primitiveMesh.H"
30 #include "cellModeller.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 const Foam::label Foam::tetWedgeMatcher::vertPerCell = 5;
36 const Foam::label Foam::tetWedgeMatcher::facePerCell = 4;
37 const Foam::label Foam::tetWedgeMatcher::maxVertPerFace = 4;
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 Foam::tetWedgeMatcher::tetWedgeMatcher()
54 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
56 Foam::tetWedgeMatcher::~tetWedgeMatcher()
60 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62 bool Foam::tetWedgeMatcher::matchShape
65 const faceList& faces,
66 const labelList& owner,
68 const labelList& myFaces
71 if (!faceSizeMatch(faces, myFaces))
76 // Is tetWedge for sure now. No other shape has two tri, two quad
82 // Calculate localFaces_ and mapping pointMap_, faceMap_
83 label numVert = calcLocalFaces(faces, myFaces);
85 if (numVert != vertPerCell)
90 // Set up 'edge' to face mapping.
91 calcEdgeAddressing(numVert);
93 // Set up point on face to index-in-face mapping
96 // Storage for maps -vertex to mesh and -face to mesh
97 vertLabels_.setSize(vertPerCell);
98 faceLabels_.setSize(facePerCell);
101 // Try first triangular face. Rotate in all directions.
102 // Walk path to other triangular face.
106 forAll(faceSize_, faceI)
108 if (faceSize_[faceI] == 3)
115 const face& face0 = localFaces_[face0I];
117 // Try all rotations of this face
118 for (label face0vert0 = 0; face0vert0 < faceSize_[face0I]; face0vert0++)
121 // Try to follow prespecified path on faces of cell,
122 // starting at face0vert0
125 vertLabels_[0] = pointMap_[face0[face0vert0]];
126 faceLabels_[0] = faceMap_[face0I];
128 // Walk face 0 from vertex 0 to 1
134 !(owner[faceMap_[face0I]] == cellI)
136 vertLabels_[1] = pointMap_[face0[face0vert1]];
138 // Jump edge from face0 to face1 (the other triangular face)
148 if (faceSize_[face1I] != 3)
152 faceLabels_[1] = faceMap_[face1I];
155 // Now correctly oriented tet-wedge for sure.
157 // Walk face 0 from vertex 1 to 2
163 !(owner[faceMap_[face0I]] == cellI)
165 vertLabels_[2] = pointMap_[face0[face0vert2]];
167 // Jump edge from face0 to face3
176 faceLabels_[3] = faceMap_[face3I];
178 // Jump edge from face0 to face2
187 faceLabels_[2] = faceMap_[face2I];
189 // Get index of vertex 2 in face3
190 label face3vert2 = pointFaceIndex_[face0[face0vert2]][face3I];
192 // Walk face 3 from vertex 2 to 4
198 (owner[faceMap_[face3I]] == cellI)
201 const face& face3 = localFaces_[face3I];
203 vertLabels_[4] = pointMap_[face3[face3vert4]];
205 // Walk face 3 from vertex 4 to 3
211 (owner[faceMap_[face3I]] == cellI)
213 vertLabels_[3] = pointMap_[face3[face3vert3]];
218 // Tried all triangular faces, in all rotations but no match found
223 Foam::label Foam::tetWedgeMatcher::faceHashValue() const
229 bool Foam::tetWedgeMatcher::faceSizeMatch
231 const faceList& faces,
232 const labelList& myFaces
235 if (myFaces.size() != 4)
243 forAll(myFaces, myFaceI)
245 label size = faces[myFaces[myFaceI]].size();
260 if ((nTris == 2) && (nQuads == 2))
271 bool Foam::tetWedgeMatcher::isA(const primitiveMesh& mesh, const label cellI)
284 bool Foam::tetWedgeMatcher::isA(const faceList& faces)
286 // Do as if mesh with one cell only
290 faces, // all faces in mesh
291 labelList(faces.size(), 0), // cell 0 is owner of all faces
293 identity(faces.size()) // faces of cell 0
298 bool Foam::tetWedgeMatcher::matches
300 const primitiveMesh& mesh,
317 shape = cellShape(model(), vertLabels());
328 // ************************************************************************* //