-
Notifications
You must be signed in to change notification settings - Fork 123
/
PatchToolsMatch.C
137 lines (115 loc) · 3.83 KB
/
PatchToolsMatch.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "PatchTools.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template
<
class Face1,
template<class> class FaceList1,
class PointField1,
class PointType1,
class Face2,
template<class> class FaceList2,
class PointField2,
class PointType2
>
void Foam::PatchTools::matchPoints
(
const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
labelList& p1PointLabels,
labelList& p2PointLabels
)
{
p1PointLabels.setSize(p1.nPoints());
p2PointLabels.setSize(p1.nPoints());
label nMatches = 0;
forAll(p1.meshPoints(), pointi)
{
label meshPointi = p1.meshPoints()[pointi];
Map<label>::const_iterator iter = p2.meshPointMap().find
(
meshPointi
);
if (iter != p2.meshPointMap().end())
{
p1PointLabels[nMatches] = pointi;
p2PointLabels[nMatches] = iter();
nMatches++;
}
}
p1PointLabels.setSize(nMatches);
p2PointLabels.setSize(nMatches);
}
template
<
class Face1,
template<class> class FaceList1,
class PointField1,
class PointType1,
class Face2,
template<class> class FaceList2,
class PointField2,
class PointType2
>
void Foam::PatchTools::matchEdges
(
const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
labelList& p1EdgeLabels,
labelList& p2EdgeLabels,
PackedBoolList& sameOrientation
)
{
p1EdgeLabels.setSize(p1.nEdges());
p2EdgeLabels.setSize(p1.nEdges());
sameOrientation.setSize(p1.nEdges());
sameOrientation = 0;
label nMatches = 0;
EdgeMap<label> edgeToIndex(2*p1.nEdges());
forAll(p1.edges(), edgeI)
{
const edge& e = p1.edges()[edgeI];
const edge meshE
(
p1.meshPoints()[e[0]],
p1.meshPoints()[e[1]]
);
edgeToIndex.insert(meshE, edgeI);
}
forAll(p2.edges(), edgeI)
{
const edge& e = p2.edges()[edgeI];
const edge meshE(p2.meshPoints()[e[0]], p2.meshPoints()[e[1]]);
EdgeMap<label>::const_iterator iter = edgeToIndex.find(meshE);
if (iter != edgeToIndex.end())
{
p1EdgeLabels[nMatches] = iter();
p2EdgeLabels[nMatches] = edgeI;
sameOrientation[nMatches] = (meshE[0] == iter.key()[0]);
nMatches++;
}
}
p1EdgeLabels.setSize(nMatches);
p2EdgeLabels.setSize(nMatches);
sameOrientation.setSize(nMatches);
}
// ************************************************************************* //