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 "tetMatcher.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::tetMatcher::vertPerCell = 4;
36 const Foam::label Foam::tetMatcher::facePerCell = 4;
37 const Foam::label Foam::tetMatcher::maxVertPerFace = 3;
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 Foam::tetMatcher::tetMatcher()
54 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
56 Foam::tetMatcher::~tetMatcher()
60 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
63 bool Foam::tetMatcher::matchShape
66 const faceList& faces,
67 const labelList& owner,
69 const labelList& myFaces
72 if (!faceSizeMatch(faces, myFaces))
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 bottom face (face 3)
106 const face& face3 = localFaces_[face3I];
107 label face3vert0 = 0;
110 // Try to follow prespecified path on faces of cell,
111 // starting at face3vert0
114 vertLabels_[0] = pointMap_[face3[face3vert0]];
115 faceLabels_[3] = faceMap_[face3I];
117 // Walk face 3 from vertex 0 to 1
123 !(owner[faceMap_[face3I]] == cellI)
125 vertLabels_[1] = pointMap_[face3[face3vert1]];
127 // Walk face 3 from vertex 1 to 2
133 !(owner[faceMap_[face3I]] == cellI)
135 vertLabels_[2] = pointMap_[face3[face3vert2]];
137 // Jump edge from face3 to face2
146 faceLabels_[2] = faceMap_[face2I];
148 // Jump edge from face3 to face0
157 faceLabels_[0] = faceMap_[face0I];
159 // Jump edge from face3 to face1
168 faceLabels_[1] = faceMap_[face1I];
169 const face& face1 = localFaces_[face1I];
171 // Get index of vert0 in face 1
172 label face1vert0 = pointFaceIndex_[face3[face3vert0]][face1I];
174 // Walk face 1 from vertex 0 to 3
180 (owner[faceMap_[face1I]] == cellI)
182 vertLabels_[3] = pointMap_[face1[face1vert3]];
188 Foam::label Foam::tetMatcher::faceHashValue() const
194 bool Foam::tetMatcher::faceSizeMatch
196 const faceList& faces,
197 const labelList& myFaces
200 if (myFaces.size() != 4)
205 forAll(myFaces, myFaceI)
207 label size = faces[myFaces[myFaceI]].size();
218 bool Foam::tetMatcher::isA(const primitiveMesh& mesh, const label cellI)
231 bool Foam::tetMatcher::isA(const faceList& faces)
233 // Do as if mesh with one cell only
237 faces, // all faces in mesh
238 labelList(faces.size(), 0), // cell 0 is owner of all faces
240 identity(faces.size()) // faces of cell 0
245 bool Foam::tetMatcher::matches
247 const primitiveMesh& mesh,
264 shape = cellShape(model(), vertLabels());
275 // ************************************************************************* //