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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2019-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "PatchTools.H"
30
31// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32
33template
34<
35 class FaceList1, class PointField1,
36 class FaceList2, class PointField2
37>
39(
42
43 labelList& p1PointLabels,
44 labelList& p2PointLabels
45)
46{
47 p1PointLabels.resize(p1.nPoints());
48 p2PointLabels.resize(p1.nPoints());
49
50 label nMatches = 0;
51
52 forAll(p1.meshPoints(), pointi)
53 {
54 const label meshPointi = p1.meshPoints()[pointi];
55
56 const auto iter = p2.meshPointMap().cfind(meshPointi);
57
58 if (iter.found())
59 {
60 p1PointLabels[nMatches] = pointi;
61 p2PointLabels[nMatches] = iter.val();
62 ++nMatches;
63 }
64 }
65
66 p1PointLabels.resize(nMatches);
67 p2PointLabels.resize(nMatches);
68}
69
70
71template
72<
73 class FaceList1, class PointField1,
74 class FaceList2, class PointField2
75>
77(
80
81 labelList& p1EdgeLabels,
82 labelList& p2EdgeLabels,
83 bitSet& sameOrientation
84)
85{
86 p1EdgeLabels.resize(p1.nEdges());
87 p2EdgeLabels.resize(p1.nEdges());
88 sameOrientation.resize(p1.nEdges());
89 sameOrientation = false;
90
91 label nMatches = 0;
92
93 EdgeMap<label> edgeToIndex(2*p1.nEdges());
94 forAll(p1.edges(), edgei)
95 {
96 // Map lookup with globalEdge
97 edgeToIndex.insert(p1.meshEdge(edgei), edgei);
98 }
99
100 forAll(p2.edges(), edgei)
101 {
102 const edge meshEdge2(p2.meshEdge(edgei));
103
104 const auto iter = edgeToIndex.cfind(meshEdge2);
105
106 if (iter.found())
107 {
108 p1EdgeLabels[nMatches] = iter.val();
109 p2EdgeLabels[nMatches] = edgei;
110 sameOrientation.set(nMatches, (meshEdge2[0] == iter.key()[0]));
111 ++nMatches;
112 }
113 }
114
115 p1EdgeLabels.resize(nMatches);
116 p2EdgeLabels.resize(nMatches);
117 sameOrientation.resize(nMatches);
118}
119
120
121// ************************************************************************* //
Map from edge (expressed as its endpoints) to value. For easier forward declaration it is currently i...
Definition: EdgeMap.H:54
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
Definition: HashTableI.H:141
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
Definition: HashTableI.H:180
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
Definition: PackedListI.H:409
static void matchEdges(const PrimitivePatch< FaceList1, PointField1 > &p1, const PrimitivePatch< FaceList2, PointField2 > &p2, labelList &p1EdgeLabels, labelList &p2EdgeLabels, bitSet &sameOrientation)
Find corresponding edges on patches sharing the same points.
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.
A list of faces which address into the list of points.
label nEdges() const
Number of edges in patch.
label nPoints() const
Number of points supporting patch faces.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const Map< label > & meshPointMap() const
Mesh point map.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
edge meshEdge(const label edgei) const
From patch edge to global edge using meshPoints.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition: bitSetI.H:590
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333