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-------------------------------------------------------------------------------
11License
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
33template<class FaceList, class PointField>
36(
38)
39{
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// ************************************************************************* //
static labelList edgeOwner(const PrimitivePatch< FaceList, PointField > &)
If 2 face neighbours: label of face where ordering of edge.
A list of faces which address into the list of points.
std::remove_reference< FaceList >::type::value_type face_type
The face type.
A List with indirect addressing. Like IndirectList but does not store addressing.
Definition: IndirectList.H:79
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
const labelList & edgeOwner() const noexcept
Edge owner addressing.
Definition: faMeshI.H:110
volScalarField & p
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
labelList f(nPoints)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333