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 -------------------------------------------------------------------------------
11 License
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 
33 template<class FaceList, class PointField>
36 {
37  return Foam::edge(this->meshPoints(), this->edges()[edgei]);
38 }
39 
40 
41 template<class FaceList, class PointField>
44 {
45  return Foam::edge(this->meshPoints(), e);
46 }
47 
48 
49 template<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 
100 template<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 
134 template<class FaceList, class PointField>
135 Foam::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 
159 template<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 
180 template<class FaceList, class PointField>
181 Foam::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 // ************************************************************************* //
Foam::PrimitivePatch::meshEdges
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Definition: PrimitivePatchMeshEdges.C:53
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:63
Foam::PrimitivePatch::meshEdge
edge meshEdge(const label edgei) const
From patch edge to global edge using meshPoints.
Definition: PrimitivePatchMeshEdges.C:35
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
Foam::edge::start
label start() const
Return start (first) vertex label.
Definition: edgeI.H:95
PrimitivePatch.H
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:388
found
bool found
Definition: TABSMDCalcMethod2.H:32
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::List< label >
Foam::UList< label >
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::UList::size
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56
Foam::PrimitivePatch::findEdge
label findEdge(const edge &e) const
Definition: PrimitivePatchMeshEdges.C:183