ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / OpenFOAM / meshes / primitiveMesh / PatchTools / PatchToolsMatch.C
blob1af68e8991236c2f9d88f50826243e7adbef6853
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 template
32     class Face1,
33     template<class> class FaceList1,
34     class PointField1,
35     class PointType1,
36     class Face2,
37     template<class> class FaceList2,
38     class PointField2,
39     class PointType2
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());
53     label nMatches = 0;
55     forAll(p1.meshPoints(), pointI)
56     {
57         label meshPointI = p1.meshPoints()[pointI];
59         Map<label>::const_iterator iter = p2.meshPointMap().find
60         (
61             meshPointI
62         );
64         if (iter != p2.meshPointMap().end())
65         {
66             p1PointLabels[nMatches] = pointI;
67             p2PointLabels[nMatches] = iter();
68             nMatches++;
69         }
70     }
71     p1PointLabels.setSize(nMatches);
72     p2PointLabels.setSize(nMatches);
76 template
78     class Face1,
79     template<class> class FaceList1,
80     class PointField1,
81     class PointType1,
82     class Face2,
83     template<class> class FaceList2,
84     class PointField2,
85     class PointType2
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());
100     sameOrientation = 0;
102     label nMatches = 0;
104     EdgeMap<label> edgeToIndex(2*p1.nEdges());
105     forAll(p1.edges(), edgeI)
106     {
107         const edge& e = p1.edges()[edgeI];
108         const edge meshE
109         (
110             p1.meshPoints()[e[0]],
111             p1.meshPoints()[e[1]]
112         );
113         edgeToIndex.insert(meshE, edgeI);
114     }
116     forAll(p2.edges(), edgeI)
117     {
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())
124         {
125             p1EdgeLabels[nMatches] = iter();
126             p2EdgeLabels[nMatches] = edgeI;
127             sameOrientation[nMatches] = (meshE[0] == iter.key()[0]);
128             nMatches++;
129         }
130     }
131     p1EdgeLabels.setSize(nMatches);
132     p2EdgeLabels.setSize(nMatches);
133     sameOrientation.setSize(nMatches);
137 // ************************************************************************* //