PatchToolsEdgeOwner.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 "PatchTools.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 template<class FaceList, class PointField>
32 (
34 )
35 {
36  typedef typename PrimitivePatch<FaceList, PointField>::FaceType FaceType;
37 
38  const edgeList& edges = p.edges();
39  const labelListList& edgeFaces = p.edgeFaces();
40  const List<FaceType>& localFaces = p.localFaces();
41 
42  // create the owner list
43  labelList edgeOwner(edges.size(), -1);
44 
45  forAll(edges, edgeI)
46  {
47  const labelList& nbrFaces = edgeFaces[edgeI];
48 
49  if (nbrFaces.size() == 1)
50  {
51  edgeOwner[edgeI] = nbrFaces[0];
52  }
53  else
54  {
55  // Find the first face whose vertices are aligned with the edge.
56  // with multiply connected edges, this is the best we can do
57  forAll(nbrFaces, i)
58  {
59  const FaceType& f = localFaces[nbrFaces[i]];
60 
61  if (f.edgeDirection(edges[edgeI]) > 0)
62  {
63  edgeOwner[edgeI] = nbrFaces[i];
64  break;
65  }
66  }
67 
68  if (edgeOwner[edgeI] == -1)
69  {
71  << "Edge " << edgeI << " vertices:" << edges[edgeI]
72  << " is used by faces " << nbrFaces
73  << " vertices:"
74  << UIndirectList<FaceType>(localFaces, nbrFaces)()
75  << " none of which use the edge vertices in the same order"
76  << nl << "I give up" << abort(FatalError);
77  }
78  }
79  }
80 
81  return edgeOwner;
82 }
83 
84 
85 // ************************************************************************* //
static labelList edgeOwner(const PrimitivePatch< FaceList, PointField > &)
If 2 face neighbours: label of face where ordering of edge.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
A list of faces which address into the list of points.
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:260
labelList f(nPoints)
std::remove_reference< FaceList >::type::value_type FaceType
const List< FaceType > & localFaces() const
Return patch faces addressing into local point list.
A List with indirect addressing.
Definition: fvMatrix.H:106