1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 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 "tetWedgeMatcher.H"
28 #include "cellMatcher.H"
29 #include "primitiveMesh.H"
30 #include "primitiveMesh.H"
31 #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 * * * * * * * * * * * * * * //
43 Foam::tetWedgeMatcher::tetWedgeMatcher()
55 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
57 Foam::tetWedgeMatcher::~tetWedgeMatcher()
61 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63 bool Foam::tetWedgeMatcher::matchShape
66 const faceList& faces,
67 const labelList& owner,
69 const labelList& myFaces
72 if (!faceSizeMatch(faces, myFaces))
77 // Is tetWedge for sure now. No other shape has two tri, two quad
83 // Calculate localFaces_ and mapping pointMap_, faceMap_
84 label numVert = calcLocalFaces(faces, myFaces);
86 if (numVert != vertPerCell)
91 // Set up 'edge' to face mapping.
92 calcEdgeAddressing(numVert);
94 // Set up point on face to index-in-face mapping
97 // Storage for maps -vertex to mesh and -face to mesh
98 vertLabels_.setSize(vertPerCell);
99 faceLabels_.setSize(facePerCell);
102 // Try first triangular face. Rotate in all directions.
103 // Walk path to other triangular face.
107 forAll(faceSize_, faceI)
109 if (faceSize_[faceI] == 3)
116 const face& face0 = localFaces_[face0I];
118 // Try all rotations of this face
119 for(label face0vert0 = 0; face0vert0 < faceSize_[face0I]; face0vert0++)
122 // Try to follow prespecified path on faces of cell,
123 // starting at face0vert0
126 vertLabels_[0] = pointMap_[face0[face0vert0]];
127 faceLabels_[0] = faceMap_[face0I];
129 // Walk face 0 from vertex 0 to 1
135 !(owner[faceMap_[face0I]] == cellI)
137 vertLabels_[1] = pointMap_[face0[face0vert1]];
139 // Jump edge from face0 to face1 (the other triangular face)
149 if (faceSize_[face1I] != 3)
153 faceLabels_[1] = faceMap_[face1I];
156 // Now correctly oriented tet-wedge for sure.
158 // Walk face 0 from vertex 1 to 2
164 !(owner[faceMap_[face0I]] == cellI)
166 vertLabels_[2] = pointMap_[face0[face0vert2]];
168 // Jump edge from face0 to face3
177 faceLabels_[3] = faceMap_[face3I];
179 // Jump edge from face0 to face2
188 faceLabels_[2] = faceMap_[face2I];
190 // Get index of vertex 2 in face3
191 label face3vert2 = pointFaceIndex_[face0[face0vert2]][face3I];
193 // Walk face 3 from vertex 2 to 4
199 (owner[faceMap_[face3I]] == cellI)
202 const face& face3 = localFaces_[face3I];
204 vertLabels_[4] = pointMap_[face3[face3vert4]];
206 // Walk face 3 from vertex 4 to 3
212 (owner[faceMap_[face3I]] == cellI)
214 vertLabels_[3] = pointMap_[face3[face3vert3]];
219 // Tried all triangular faces, in all rotations but no match found
224 Foam::label Foam::tetWedgeMatcher::faceHashValue() const
230 bool Foam::tetWedgeMatcher::faceSizeMatch
232 const faceList& faces,
233 const labelList& myFaces
236 if (myFaces.size() != 4)
244 forAll(myFaces, myFaceI)
246 label size = faces[myFaces[myFaceI]].size();
261 if ((nTris == 2) && (nQuads == 2))
272 bool Foam::tetWedgeMatcher::isA(const primitiveMesh& mesh, const label cellI)
285 bool Foam::tetWedgeMatcher::isA(const faceList& faces)
287 // Do as if mesh with one cell only
291 faces, // all faces in mesh
292 labelList(faces.size(), 0), // cell 0 is owner of all faces
294 makeIdentity(faces.size()) // faces of cell 0
299 bool Foam::tetWedgeMatcher::matches
301 const primitiveMesh& mesh,
318 shape = cellShape(model(), vertLabels());
329 // ************************************************************************* //