PrimitivePatchMeshEdges.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 "PrimitivePatch.H"
27 
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 template<class FaceList, class PointField>
33 (
34  const edgeList& allEdges,
35  const labelListList& cellEdges,
36  const labelList& faceCells
37 ) const
38 {
39  if (debug)
40  {
42  << "Calculating labels of patch edges in mesh edge list" << endl;
43  }
44 
45  // get reference to the list of edges on the patch
46  const edgeList& PatchEdges = edges();
47 
48  const labelListList& EdgeFaces = edgeFaces();
49 
50  // create the storage
51  labelList meshEdges(PatchEdges.size());
52 
53  bool found = false;
54 
55  // get reference to the points on the patch
56  const labelList& pp = meshPoints();
57 
58  // WARNING: Remember that local edges address into local point list;
59  // local-to-global point label translation is necessary
60  forAll(PatchEdges, edgeI)
61  {
62  const edge curEdge
63  (pp[PatchEdges[edgeI].start()], pp[PatchEdges[edgeI].end()]);
64 
65  found = false;
66 
67  // get the patch faces sharing the edge
68  const labelList& curFaces = EdgeFaces[edgeI];
69 
70  forAll(curFaces, facei)
71  {
72  // get the cell next to the face
73  label curCell = faceCells[curFaces[facei]];
74 
75  // get reference to edges on the cell
76  const labelList& ce = cellEdges[curCell];
77 
78  forAll(ce, cellEdgeI)
79  {
80  if (allEdges[ce[cellEdgeI]] == curEdge)
81  {
82  found = true;
83 
84  meshEdges[edgeI] = ce[cellEdgeI];
85 
86  break;
87  }
88  }
89 
90  if (found) break;
91  }
92  }
93 
94  return meshEdges;
95 }
96 
97 
98 template<class FaceList, class PointField>
100 (
101  const edgeList& allEdges,
102  const labelListList& pointEdges
103 ) const
104 {
105  if (debug)
106  {
108  << "Calculating labels of patch edges in mesh edge list" << endl;
109  }
110 
111  // get reference to the list of edges on the patch
112  const edgeList& PatchEdges = edges();
113 
114  // create the storage
115  labelList meshEdges(PatchEdges.size());
116 
117  // get reference to the points on the patch
118  const labelList& pp = meshPoints();
119 
120  // WARNING: Remember that local edges address into local point list;
121  // local-to-global point label translation is necessary
122  forAll(PatchEdges, edgeI)
123  {
124  const label globalPointi = pp[PatchEdges[edgeI].start()];
125  const edge curEdge(globalPointi, pp[PatchEdges[edgeI].end()]);
126 
127  const labelList& pe = pointEdges[globalPointi];
128 
129  forAll(pe, i)
130  {
131  if (allEdges[pe[i]] == curEdge)
132  {
133  meshEdges[edgeI] = pe[i];
134  break;
135  }
136  }
137  }
138 
139  return meshEdges;
140 }
141 
142 
143 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
144 
145 template<class FaceList, class PointField>
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 // ************************************************************************* //
#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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
label whichEdge(const edge &) const
Given an edge in local point labels, return its.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
label nPoints
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Return labels of patch edges in the global edge list using.
bool found
label start() const
Return start vertex label.
Definition: edgeI.H:81
#define InfoInFunction
Report an information message using Foam::Info.