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 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 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 template<class FaceList, class PointField>
37 (
38  const edgeList& allEdges,
39  const labelListList& cellEdges,
40  const labelList& faceCells
41 ) const
42 {
44  << "Calculating labels of patch edges in mesh edge list" << nl;
45 
46  // get reference to the list of edges on the patch
47  const edgeList& PatchEdges = edges();
48 
49  const labelListList& EdgeFaces = edgeFaces();
50 
51  // create the storage
52  labelList meshEdges(PatchEdges.size());
53 
54  bool found = false;
55 
56  // get reference to the points on the patch
57  const labelList& pp = meshPoints();
58 
59  // WARNING: Remember that local edges address into local point list;
60  // local-to-global point label translation is necessary
61  forAll(PatchEdges, edgeI)
62  {
63  const edge curEdge
64  (pp[PatchEdges[edgeI].start()], pp[PatchEdges[edgeI].end()]);
65 
66  found = false;
67 
68  // get the patch faces sharing the edge
69  const labelList& curFaces = EdgeFaces[edgeI];
70 
71  forAll(curFaces, facei)
72  {
73  // get the cell next to the face
74  label curCell = faceCells[curFaces[facei]];
75 
76  // get reference to edges on the cell
77  const labelList& ce = cellEdges[curCell];
78 
79  forAll(ce, cellEdgeI)
80  {
81  if (allEdges[ce[cellEdgeI]] == curEdge)
82  {
83  found = true;
84 
85  meshEdges[edgeI] = ce[cellEdgeI];
86 
87  break;
88  }
89  }
90 
91  if (found) break;
92  }
93  }
94 
95  return meshEdges;
96 }
97 
98 
99 template<class FaceList, class PointField>
102 (
103  const edgeList& allEdges,
104  const labelListList& pointEdges
105 ) const
106 {
108  << "Calculating labels of patch edges in mesh edge list" << nl;
109 
110  // get reference to the list of edges on the patch
111  const edgeList& PatchEdges = edges();
112 
113  // create the storage
114  labelList meshEdges(PatchEdges.size());
115 
116  // get reference to the points on the patch
117  const labelList& pp = meshPoints();
118 
119  // WARNING: Remember that local edges address into local point list;
120  // local-to-global point label translation is necessary
121  forAll(PatchEdges, edgeI)
122  {
123  const label globalPointi = pp[PatchEdges[edgeI].start()];
124  const edge curEdge(globalPointi, pp[PatchEdges[edgeI].end()]);
125 
126  const labelList& pe = pointEdges[globalPointi];
127 
128  forAll(pe, i)
129  {
130  if (allEdges[pe[i]] == curEdge)
131  {
132  meshEdges[edgeI] = pe[i];
133  break;
134  }
135  }
136  }
137 
138  return meshEdges;
139 }
140 
141 
142 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
143 
144 template<class FaceList, class PointField>
145 Foam::label
147 (
148  const edge& e
149 ) const
150 {
151  // Get pointEdges from the starting point and search all the candidates
152  const edgeList& Edges = edges();
153 
154  if (e.start() > -1 && e.start() < nPoints())
155  {
156  const labelList& pe = pointEdges()[e.start()];
157 
158  forAll(pe, peI)
159  {
160  if (e == Edges[pe[peI]])
161  {
162  return pe[peI];
163  }
164  }
165  }
166 
167  // Edge not found. Return -1
168  return -1;
169 }
170 
171 
172 // ************************************************************************* //
Foam::PrimitivePatch::meshEdges
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Definition: PrimitivePatchMeshEdges.C:37
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:63
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
PrimitivePatch.H
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:365
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
found
bool found
Definition: TABSMDCalcMethod2.H:32
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::List< label >
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::PrimitivePatch::whichEdge
label whichEdge(const edge &) const
Definition: PrimitivePatchMeshEdges.C:147
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56