PatchToolsEdgeOwner.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 | Copyright (C) 2011-2015 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 "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  << "Edge " << edgeI << " vertices:" << edges[edgeI]
78  << " is used by faces " << nbrFaces
79  << " vertices:"
80  << UIndirectList<Face>(localFaces, nbrFaces)()
81  << " none of which use the edge vertices in the same order"
82  << nl << "I give up" << abort(FatalError);
83  }
84  }
85  }
86 
87  return edgeOwner;
88 }
89 
90 
91 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
A list of faces which address into the list of points.
static labelList edgeOwner(const PrimitivePatch< Face, FaceList, PointField, PointType > &)
If 2 face neighbours: label of face where ordering of edge.
const labelListList & edgeFaces() const
Return edge-face addressing.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
errorManip< error > abort(error &err)
Definition: errorManip.H:131
static const char nl
Definition: Ostream.H:262
labelList f(nPoints)
A List with indirect addressing.
Definition: fvMatrix.H:106