PrimitivePatchMeshEdges.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) 2020-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 "PrimitivePatch.H"
30
31// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32
33template<class FaceList, class PointField>
36{
37 return Foam::edge(this->meshPoints(), this->edges()[edgei]);
38}
39
40
41template<class FaceList, class PointField>
44{
45 return Foam::edge(this->meshPoints(), e);
46}
47
48
49template<class FaceList, class PointField>
53(
54 const edgeList& allEdges,
55 const labelListList& cellEdges,
56 const labelList& faceCells
57) const
58{
60 << "Calculating labels of patch edges in mesh edge list" << nl;
61
62 // The output storage
63 labelList meshEdgeLabels(this->nEdges());
64
65 const labelListList& EdgeFaces = edgeFaces();
66
67 // WARNING: Remember that local edges address into local point list;
68 // local-to-global point label translation is necessary
69 forAll(meshEdgeLabels, edgei)
70 {
71 const edge globalEdge(this->meshEdge(edgei));
72
73 bool found = false;
74
75 // For each patch face sharing the edge
76 for (const label patchFacei : EdgeFaces[edgei])
77 {
78 // The cell next to the face
79 const label curCelli = faceCells[patchFacei];
80
81 // Check the cell edges
82 for (const label cellEdgei : cellEdges[curCelli])
83 {
84 if (allEdges[cellEdgei] == globalEdge)
85 {
86 found = true;
87 meshEdgeLabels[edgei] = cellEdgei;
88 break;
89 }
90 }
91
92 if (found) break;
93 }
94 }
95
96 return meshEdgeLabels;
97}
98
99
100template<class FaceList, class PointField>
103(
104 const edgeList& allEdges,
105 const labelListList& pointEdges
106) const
107{
109 << "Calculating labels of patch edges in mesh edge list" << nl;
110
111 labelList meshEdgeLabels(this->nEdges());
112
113 // WARNING: Remember that local edges address into local point list;
114 // local-to-global point label translation is necessary
115 forAll(meshEdgeLabels, edgei)
116 {
117 const edge globalEdge(this->meshEdge(edgei));
118
119 // Check the attached edges
120 for (const label meshEdgei : pointEdges[globalEdge.start()])
121 {
122 if (allEdges[meshEdgei] == globalEdge)
123 {
124 meshEdgeLabels[edgei] = meshEdgei;
125 break;
126 }
127 }
128 }
129
130 return meshEdgeLabels;
131}
132
133
134template<class FaceList, class PointField>
135Foam::label
137(
138 const label edgei,
139 const edgeList& allEdges,
140 const labelListList& pointEdges
141) const
142{
143 // Need local-to-global point label translation
144 const edge globalEdge(this->meshEdge(edgei));
145
146 // Check attached edges
147 for (const label meshEdgei : pointEdges[globalEdge.start()])
148 {
149 if (allEdges[meshEdgei] == globalEdge)
150 {
151 return meshEdgei;
152 }
153 }
154
155 return -1;
156}
157
158
159template<class FaceList, class PointField>
162(
163 const labelUList& edgeLabels,
164 const edgeList& allEdges,
165 const labelListList& pointEdges
166) const
167{
168 labelList meshEdgeLabels(edgeLabels.size());
169
170 forAll(meshEdgeLabels, edgei)
171 {
172 meshEdgeLabels[edgei] =
173 this->meshEdge(edgeLabels[edgei], allEdges, pointEdges);
174 }
175
176 return meshEdgeLabels;
177}
178
179
180template<class FaceList, class PointField>
181Foam::label
183(
184 const edge& e
185) const
186{
187 if (e.valid() && e.first() < nPoints() && e.second() < nPoints())
188 {
189 // Get pointEdges from the starting point and search all the candidates
190 const edgeList& myEdges = this->edges();
191
192 for (const label patchEdgei : pointEdges()[e.first()])
193 {
194 if (e == myEdges[patchEdgei])
195 {
196 return patchEdgei;
197 }
198 }
199 }
200
201 return -1; // Not found, or invalid edge
202}
203
204
205// ************************************************************************* //
bool found
edge meshEdge(const label edgei) const
From patch edge to global edge using meshPoints.
label findEdge(const edge &e) const
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
label start() const
Return start (first) vertex label.
Definition: edgeI.H:95
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:59
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: polyPatch.C:385
const labelList nEdges(UPstream::listGatherValues< label >(aMesh.nEdges()))
label nPoints
#define DebugInFunction
Report an information message using Foam::Info.
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
volScalarField & e
Definition: createFields.H:11
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333