PatchToolsMatch.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "PatchTools.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 template
31 <
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
40 >
42 (
45 
46  labelList& p1PointLabels,
47  labelList& p2PointLabels
48 )
49 {
50  p1PointLabels.setSize(p1.nPoints());
51  p2PointLabels.setSize(p1.nPoints());
52 
53  label nMatches = 0;
54 
55  forAll(p1.meshPoints(), pointi)
56  {
57  label meshPointi = p1.meshPoints()[pointi];
58 
60  (
61  meshPointi
62  );
63 
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);
73 }
74 
75 
76 template
77 <
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
86 >
88 (
91 
92  labelList& p1EdgeLabels,
93  labelList& p2EdgeLabels,
94  PackedBoolList& sameOrientation
95 )
96 {
97  p1EdgeLabels.setSize(p1.nEdges());
98  p2EdgeLabels.setSize(p1.nEdges());
99  sameOrientation.setSize(p1.nEdges());
100  sameOrientation = 0;
101 
102  label nMatches = 0;
103 
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  }
115 
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]]);
120 
121  EdgeMap<label>::const_iterator iter = edgeToIndex.find(meshE);
122 
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);
134 }
135 
136 
137 // ************************************************************************* //
label nPoints() const
Return number of points supporting patch faces.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
Definition: HashTable.H:106
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
static void matchEdges(const PrimitivePatch< Face1, FaceList1, PointField1, PointType1 > &p1, const PrimitivePatch< Face2, FaceList2, PointField2, PointType2 > &p2, labelList &p1EdgeLabels, labelList &p2EdgeLabels, PackedBoolList &sameOrientation)
Find corresponding edges on patches sharing the same points.
const Map< label > & meshPointMap() const
Mesh point map. Given the global point index find its.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Definition: HashTable.C:138
A list of faces which address into the list of points.
const dimensionedScalar e
Elementary charge.
Definition: doubleFloat.H:78
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
void setSize(const label, const unsigned int &val=0u)
Alias for resize()
Definition: PackedListI.H:822
label nEdges() const
Return number of edges in patch.
void setSize(const label)
Reset size of List.
Definition: List.C:295
A bit-packed bool list.
static void matchPoints(const PrimitivePatch< Face1, FaceList1, PointField1, PointType1 > &p1, const PrimitivePatch< Face2, FaceList2, PointField2, PointType2 > &p2, labelList &p1PointLabels, labelList &p2PointLabels)
Find corresponding points on patches sharing the same points.
A HashTable to objects of type <T> with a label key.
Definition: Map.H:49