Loading...
Searching...
No Matches
primitiveMeshEdgeFaces.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) 2021-2024 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 "primitiveMesh.H"
30#include "ListOps.H"
31
32// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
33
35{
36 if (!efPtr_)
37 {
38 if (debug)
39 {
40 Pout<< "primitiveMesh::edgeFaces() : calculating edgeFaces" << endl;
41
42 if (debug == -1)
43 {
44 // For checking calls:abort so we can quickly hunt down
45 // origin of call
47 << abort(FatalError);
48 }
49 }
50
51 // Invert faceEdges
52 efPtr_ = std::make_unique<labelListList>(nEdges());
54 }
55
56 return *efPtr_;
57}
58
59
61(
62 const label edgei,
63 DynamicList<label>& storage
64) const
65{
66 if (hasEdgeFaces())
67 {
68 return edgeFaces()[edgei];
69 }
70 else
71 {
72 // Use the fact that pointFaces are sorted in incrementing edge order
73 // (since they get constructed by inverting the faces which walks
74 // in increasing face order)
75 const edge& e = edges()[edgei];
76 const labelList& pFaces0 = pointFaces()[e[0]];
77 const labelList& pFaces1 = pointFaces()[e[1]];
78
79 label i0 = 0;
80 label i1 = 0;
81
82 storage.clear();
83
84 while (i0 < pFaces0.size() && i1 < pFaces1.size())
85 {
86 const label f0 = pFaces0[i0];
87 const label f1 = pFaces1[i1];
88
89 if (f0 < f1)
90 {
91 ++i0;
92 }
93 else if (f0 > f1)
94 {
95 ++i1;
96 }
97 else
98 {
99 // Equal face. Check if indeed on consecutive vertices on both
100 // faces since it could be that there is an 'ear' where one
101 // side is a triangle and the other side is part of a bigger
102 // face (e.g. quad). Now all vertex-vertex pairs on the
103 // triangle are edges but there is no cross connection on the
104 // bigger face.
105 const face& f = faces()[f0];
106 const label fp0 = f.find(e[0]);
107
108 if (f[f.fcIndex(fp0)] == e[1] || f[f.rcIndex(fp0)] == e[1])
109 {
110 storage.append(f0);
111 ++i0;
112 ++i1;
113 }
114 else
115 {
116 ++i1;
117 }
118 }
120
121 return storage;
122 }
123}
124
125
126const Foam::labelList& Foam::primitiveMesh::edgeFaces(const label edgei) const
127{
128 return edgeFaces(edgei, labels_);
129}
130
131
132// ************************************************************************* //
Various functions to operate on Lists.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
label rcIndex(const label i) const noexcept
The reverse circular index. The previous index in the list which returns to the last at the beginning...
Definition UListI.H:106
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
label find(const T &val) const
Find index of the first occurrence of the value.
Definition UList.C:160
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
Definition UListI.H:99
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Definition edge.H:62
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
virtual const faceList & faces() const =0
Return faces.
bool hasEdgeFaces() const noexcept
const labelListList & pointFaces() const
const labelListList & edgeFaces() const
const labelListList & faceEdges() const
label nEdges() const
Number of mesh edges.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
Namespace for handling debugging switches.
Definition debug.C:45
void invertManyToMany(const label len, const UList< InputIntListType > &input, List< OutputIntListType > &output)
Invert many-to-many.
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
labelList f(nPoints)
volScalarField & e