PrimitivePatchBdryFaces.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) 2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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 "PrimitivePatch.H"
29
30// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31
32template<class FaceList, class PointField>
35{
36 labelList bndFaces(nBoundaryEdges());
37
38 // The boundary slice
39 const SubList<labelList> bndEdgeToFace
40 (
41 edgeFaces(),
42 bndFaces.size(),
43 nInternalEdges()
44 );
45
46 // By definition boundary edges have a _single_ face attached
47 forAll(bndFaces, i)
48 {
49 bndFaces[i] = bndEdgeToFace[i][0];
50 }
51
52 return bndFaces;
53}
54
55
56template<class FaceList, class PointField>
59{
60 labelList bndFaces(this->boundaryFaces());
61
62 const label len = bndFaces.size();
63
64 if (len > 1)
65 {
66 Foam::sort(bndFaces);
67
68 label prev = bndFaces[0];
69 label nUniq = 1;
70
71 for (label i=1; i < len; ++i)
72 {
73 if (prev != bndFaces[i])
74 {
75 prev = bndFaces[i];
76 bndFaces[nUniq] = prev;
77 ++nUniq;
78 }
79 }
80
81 bndFaces.resize(nUniq);
82 }
83
84 return bndFaces;
85}
86
87
88// ************************************************************************* //
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
labelList boundaryFaces() const
labelList uniqBoundaryFaces() const
A List obtained as a section of another List.
Definition: SubList.H:70
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
void sort(UList< T > &list)
Sort the list.
Definition: UList.C:342
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333