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