PatchToolsEdgeOwner.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | foam-extend: Open Source CFD
4  \\ / O peration | Version: 3.2
5  \\ / A nd | Web: http://www.foam-extend.org
6  \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9  This file is part of foam-extend.
10 
11  foam-extend is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation, either version 3 of the License, or (at your
14  option) any later version.
15 
16  foam-extend is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "PatchTools.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 template
31 <
32  class Face,
33  template<class> class FaceList,
34  class PointField,
35  class PointType
36 >
37 
40 (
42 )
43 {
44  const edgeList& edges = p.edges();
45  const labelListList& edgeFaces = p.edgeFaces();
46  const List<Face>& localFaces = p.localFaces();
47 
48  // create the owner list
49  labelList edgeOwner(edges.size(), -1);
50 
51  forAll(edges, edgeI)
52  {
53  const labelList& nbrFaces = edgeFaces[edgeI];
54 
55  if (nbrFaces.size() == 1)
56  {
57  edgeOwner[edgeI] = nbrFaces[0];
58  }
59  else
60  {
61  // Find the first face whose vertices are aligned with the edge.
62  // with multiply connected edges, this is the best we can do
63  forAll(nbrFaces, i)
64  {
65  const Face& f = localFaces[nbrFaces[i]];
66 
67  if (f.edgeDirection(edges[edgeI]) > 0)
68  {
69  edgeOwner[edgeI] = nbrFaces[i];
70  break;
71  }
72  }
73 
74  if (edgeOwner[edgeI] == -1)
75  {
77  (
78  "PatchTools::edgeOwner()"
79  )
80  << "Edge " << edgeI << " vertices:" << edges[edgeI]
81  << " is used by faces " << nbrFaces
82  << " vertices:"
83  << UIndirectList<Face>(localFaces, nbrFaces)()
84  << " none of which use the edge vertices in the same order"
85  << nl << "I give up" << abort(FatalError);
86  }
87  }
88  }
89 
90  return edgeOwner;
91 }
92 
93 
94 // ************************************************************************* //
p
p
Definition: pEqn.H:62
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::FatalError
error FatalError
PatchTools.H
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
f
labelList f(nPoints)
Foam::PatchTools::edgeOwner
static labelList edgeOwner(const PrimitivePatch< Face, FaceList, PointField, PointType > &)
If 2 face neighbours: label of face where ordering of edge.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::UIndirectList
A List with indirect addressing.
Definition: fvMatrix.H:106
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88