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 \*---------------------------------------------------------------------------*/
26 #include "PatchTools.H"
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 template<class> class FaceList1,
37 template<class> class FaceList2,
41 void Foam::PatchTools::matchPoints
43 const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
44 const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
46 labelList& p1PointLabels,
47 labelList& p2PointLabels
50 p1PointLabels.setSize(p1.nPoints());
51 p2PointLabels.setSize(p1.nPoints());
55 forAll(p1.meshPoints(), pointI)
57 label meshPointI = p1.meshPoints()[pointI];
59 Map<label>::const_iterator iter = p2.meshPointMap().find
64 if (iter != p2.meshPointMap().end())
66 p1PointLabels[nMatches] = pointI;
67 p2PointLabels[nMatches] = iter();
71 p1PointLabels.setSize(nMatches);
72 p2PointLabels.setSize(nMatches);
79 template<class> class FaceList1,
83 template<class> class FaceList2,
87 void Foam::PatchTools::matchEdges
89 const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
90 const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
92 labelList& p1EdgeLabels,
93 labelList& p2EdgeLabels,
94 PackedBoolList& sameOrientation
97 p1EdgeLabels.setSize(p1.nEdges());
98 p2EdgeLabels.setSize(p1.nEdges());
99 sameOrientation.setSize(p1.nEdges());
104 EdgeMap<label> edgeToIndex(2*p1.nEdges());
105 forAll(p1.edges(), edgeI)
107 const edge& e = p1.edges()[edgeI];
110 p1.meshPoints()[e[0]],
111 p1.meshPoints()[e[1]]
113 edgeToIndex.insert(meshE, edgeI);
116 forAll(p2.edges(), edgeI)
118 const edge& e = p2.edges()[edgeI];
119 const edge meshE(p2.meshPoints()[e[0]], p2.meshPoints()[e[1]]);
121 EdgeMap<label>::const_iterator iter = edgeToIndex.find(meshE);
123 if (iter != edgeToIndex.end())
125 p1EdgeLabels[nMatches] = iter();
126 p2EdgeLabels[nMatches] = edgeI;
127 sameOrientation[nMatches] = (meshE[0] == iter.key()[0]);
131 p1EdgeLabels.setSize(nMatches);
132 p2EdgeLabels.setSize(nMatches);
133 sameOrientation.setSize(nMatches);
137 // ************************************************************************* //