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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "PatchTools.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 template
33 <
34  class Face,
35  template<class> class FaceList,
36  class PointField,
37  class PointType
38 >
39 
42 (
44 )
45 {
46  const edgeList& edges = p.edges();
47  const labelListList& edgeFaces = p.edgeFaces();
48  const List<Face>& localFaces = p.localFaces();
49 
50  // create the owner list
51  labelList edgeOwner(edges.size(), -1);
52 
53  forAll(edges, edgeI)
54  {
55  const labelList& nbrFaces = edgeFaces[edgeI];
56 
57  if (nbrFaces.size() == 1)
58  {
59  edgeOwner[edgeI] = nbrFaces[0];
60  }
61  else
62  {
63  // Find the first face whose vertices are aligned with the edge.
64  // with multiply connected edges, this is the best we can do
65  forAll(nbrFaces, i)
66  {
67  const Face& f = localFaces[nbrFaces[i]];
68 
69  if (f.edgeDirection(edges[edgeI]) > 0)
70  {
71  edgeOwner[edgeI] = nbrFaces[i];
72  break;
73  }
74  }
75 
76  if (edgeOwner[edgeI] == -1)
77  {
79  << "Edge " << edgeI << " vertices:" << edges[edgeI]
80  << " is used by faces " << nbrFaces
81  << " vertices:"
82  << UIndirectList<Face>(localFaces, nbrFaces)
83  << " none of which use the edge vertices in the same order"
84  << nl << "I give up" << abort(FatalError);
85  }
86  }
87  }
88 
89  return edgeOwner;
90 }
91 
92 
93 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
PatchTools.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::nl
constexpr char nl
Definition: Ostream.H:372
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:102
Foam::UIndirectList
A List with indirect addressing.
Definition: fvMatrix.H:109
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:90