All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PatchToolsMatch.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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<class FaceList1, class PointField1, class FaceList2, class PointField2>
32 (
35 
36  labelList& p1PointLabels,
37  labelList& p2PointLabels
38 )
39 {
40  p1PointLabels.setSize(p1.nPoints());
41  p2PointLabels.setSize(p1.nPoints());
42 
43  label nMatches = 0;
44 
45  forAll(p1.meshPoints(), pointi)
46  {
47  label meshPointi = p1.meshPoints()[pointi];
48 
50  (
51  meshPointi
52  );
53 
54  if (iter != p2.meshPointMap().end())
55  {
56  p1PointLabels[nMatches] = pointi;
57  p2PointLabels[nMatches] = iter();
58  nMatches++;
59  }
60  }
61  p1PointLabels.setSize(nMatches);
62  p2PointLabels.setSize(nMatches);
63 }
64 
65 
66 template<class FaceList1, class PointField1, class FaceList2, class PointField2>
68 (
71 
72  labelList& p1EdgeLabels,
73  labelList& p2EdgeLabels,
74  PackedBoolList& sameOrientation
75 )
76 {
77  p1EdgeLabels.setSize(p1.nEdges());
78  p2EdgeLabels.setSize(p1.nEdges());
79  sameOrientation.setSize(p1.nEdges());
80  sameOrientation = 0;
81 
82  label nMatches = 0;
83 
84  EdgeMap<label> edgeToIndex(2*p1.nEdges());
85  forAll(p1.edges(), edgeI)
86  {
87  const edge& e = p1.edges()[edgeI];
88  const edge meshE
89  (
90  p1.meshPoints()[e[0]],
91  p1.meshPoints()[e[1]]
92  );
93  edgeToIndex.insert(meshE, edgeI);
94  }
95 
96  forAll(p2.edges(), edgeI)
97  {
98  const edge& e = p2.edges()[edgeI];
99  const edge meshE(p2.meshPoints()[e[0]], p2.meshPoints()[e[1]]);
100 
101  EdgeMap<label>::const_iterator iter = edgeToIndex.find(meshE);
102 
103  if (iter != edgeToIndex.end())
104  {
105  p1EdgeLabels[nMatches] = iter();
106  p2EdgeLabels[nMatches] = edgeI;
107  sameOrientation[nMatches] = (meshE[0] == iter.key()[0]);
108  nMatches++;
109  }
110  }
111  p1EdgeLabels.setSize(nMatches);
112  p2EdgeLabels.setSize(nMatches);
113  sameOrientation.setSize(nMatches);
114 }
115 
116 
117 // ************************************************************************* //
label nPoints() const
Return number of points supporting patch faces.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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:112
static void matchEdges(const PrimitivePatch< FaceList1, PointField1 > &p1, const PrimitivePatch< FaceList2, PointField2 > &p2, labelList &p1EdgeLabels, labelList &p2EdgeLabels, PackedBoolList &sameOrientation)
Find corresponding edges on patches sharing the same points.
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Definition: HashTable.C:142
A list of faces which address into the list of points.
const Map< label > & meshPointMap() const
Mesh point map. Given the global point index find its.
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:820
label nEdges() const
Return number of edges in patch.
void setSize(const label)
Reset size of List.
Definition: List.C:281
A bit-packed bool list.
static void matchPoints(const PrimitivePatch< FaceList1, PointField1 > &p1, const PrimitivePatch< FaceList2, PointField2 > &p2, labelList &p1PointLabels, labelList &p2PointLabels)
Find corresponding points on patches sharing the same points.
const dimensionedScalar e
Elementary charge.
Definition: doubleScalar.H:105
A HashTable to objects of type <T> with a label key.
Definition: Map.H:49