triSurfaceAddressing.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
27Description
28 Contains fix for PrimitivePatch addressing (which doesn't work if surface
29 is non-manifold). Should be moved into PrimitivePatch.
30
31\*---------------------------------------------------------------------------*/
32
33#include "triSurface.H"
34#include "PatchTools.H"
35
36// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
37
38void Foam::triSurface::calcSortedEdgeFaces() const
39{
40 if (sortedEdgeFacesPtr_)
41 {
43 << "sortedEdgeFacesPtr_ already set"
44 << abort(FatalError);
45 }
46
47 const labelListList& eFaces = edgeFaces();
48
49 sortedEdgeFacesPtr_.reset(new labelListList(eFaces.size()));
50 auto& sortedEdgeFaces = *sortedEdgeFacesPtr_;
51
53}
54
55
56void Foam::triSurface::calcEdgeOwner() const
57{
58 if (edgeOwnerPtr_)
59 {
61 << "edgeOwnerPtr_ already set"
62 << abort(FatalError);
63 }
64
65 edgeOwnerPtr_.reset(new labelList(nEdges()));
66 auto& edgeOwner = *edgeOwnerPtr_;
67
68 forAll(edges(), edgeI)
69 {
70 const edge& e = edges()[edgeI];
71
72 const labelList& myFaces = edgeFaces()[edgeI];
73
74 if (myFaces.size() == 1)
75 {
76 edgeOwner[edgeI] = myFaces[0];
77 }
78 else
79 {
80 // Find the first face whose vertices are aligned with the edge.
81 // (in case of multiply connected edge the best we can do)
82 edgeOwner[edgeI] = -1;
83
84 forAll(myFaces, i)
85 {
86 const labelledTri& f = localFaces()[myFaces[i]];
87
88 if
89 (
90 ((f[0] == e.start()) && (f[1] == e.end()))
91 || ((f[1] == e.start()) && (f[2] == e.end()))
92 || ((f[2] == e.start()) && (f[0] == e.end()))
93 )
94 {
95 edgeOwner[edgeI] = myFaces[i];
96
97 break;
98 }
99 }
100
101 if (edgeOwner[edgeI] == -1)
102 {
104 << "Edge " << edgeI << " vertices:" << e
105 << " is used by faces " << myFaces
106 << " vertices:"
107 << UIndirectList<labelledTri>(localFaces(), myFaces)
108 << " none of which use the edge vertices in the same order"
109 << nl << "I give up" << abort(FatalError);
110 }
111 }
112 }
113}
114
115
116// ************************************************************************* //
const labelListList & edgeFaces() const
Return edge-face addressing.
iterator end() noexcept
Return an iterator to end traversing the UList.
Definition: UListI.H:350
const labelListList & sortedEdgeFaces() const
Return edge-face addressing sorted (for edges with more than.
Definition: triSurface.C:590
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
const labelList nEdges(UPstream::listGatherValues< label >(aMesh.nEdges()))
List< label > labelList
A List of labels.
Definition: List.H:66
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:56
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)
volScalarField & e
Definition: createFields.H:11
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333