labelledTri.H
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-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2021 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
27Class
28 Foam::labelledTri
29
30Description
31 A triFace with additional (region) index.
32
33SourceFiles
34 labelledTriI.H
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef labelledTri_H
39#define labelledTri_H
40
41#include "triFace.H"
42#include "ListListOps.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49// Forward Declarations
50class labelledTri;
51inline Istream& operator>>(Istream&, labelledTri&);
52inline Ostream& operator<<(Ostream&, const labelledTri&);
53
54/*---------------------------------------------------------------------------*\
55 Class labelledTri Declaration
56\*---------------------------------------------------------------------------*/
58class labelledTri
59:
60 public triFace
61{
62 // Private Data
63
64 //- The object index (region)
65 label index_;
66
67
68 // Private Member Functions
69
70 //- Assign from 3 or 4 labels, default region is 0.
71 template<class ListType>
72 inline void assignList(const ListType& list);
73
74
75public:
76
77 // Constructors
78
79 //- Default construct, with invalid point labels and region (-1).
80 inline labelledTri();
81
82 //- Construct from triFace
83 //- and optional region index (0 if unspecified)
84 inline labelledTri
85 (
86 const triFace& tri,
87 const label region = 0
88 );
89
90 //- Construct from three point labels
91 //- and optional region index (0 if unspecified)
92 inline labelledTri
93 (
94 const label a,
95 const label b,
96 const label c,
97 const label region = 0
98 );
99
100 //- Construct from a list of 3 or 4 labels. Default region is 0.
101 inline explicit labelledTri(const labelUList& list);
102
103 //- Construct from a list of 3 or 4 labels. Default region is 0.
104 inline explicit labelledTri(std::initializer_list<label>);
105
106 //- Copy construct from a subset of point labels
107 //- and optional region index (0 if unspecified)
108 inline labelledTri
109 (
110 const labelUList& list,
111 const FixedList<label, 3>& triIndices,
112 const label region = 0
113 );
114
115 //- Copy construct from a subset of point labels
116 //- with region index from input labelledTri
117 inline labelledTri
118 (
119 const labelUList& list,
120 const labelledTri& triIndices
121 );
122
123 //- Construct from Istream
124 inline labelledTri(Istream& is);
125
126
127 // Member Functions
128
129 //- Return the index (eg, the region)
130 label index() const noexcept
131 {
132 return index_;
133 }
134
135 //- Non-const access to the index (eg, the region)
136 label& index() noexcept
137 {
138 return index_;
139 }
140
141 //- Set the index (eg, the region)
142 void setIndex(const label idx) noexcept
143 {
144 index_ = idx;
145 }
146
147 //- Return the region index
148 label region() const noexcept
149 {
150 return index_;
151 }
152
153 //- Non-const access to the region index
154 label& region() noexcept
155 {
156 return index_;
157 }
158
159
160 // IOstream Operators
163 friend Ostream& operator<<(Ostream&, const labelledTri&);
164};
165
166
167// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
168
169//- Contiguous data for labelledTri
170template<> struct is_contiguous<labelledTri> : std::true_type {};
171
172//- Contiguous label data for labelledTri
173template<> struct is_contiguous_label<labelledTri> : std::true_type {};
174
175
176//- Specialization to offset faces, used in ListListOps::combineOffset
177template<>
178struct offsetOp<labelledTri>
180 labelledTri operator()(const labelledTri& x, const label offset) const
181 {
182 labelledTri result(x);
183
184 forAll(x, xi)
185 {
186 result[xi] = x[xi] + offset;
187 }
188 return result;
189 }
190};
191
192
193// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194
195} // End namespace Foam
196
197// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198
199#include "labelledTriI.H"
200
201// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202
203#endif
204
205// ************************************************************************* //
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: FixedList.H:81
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A triFace with additional (region) index.
Definition: labelledTri.H:60
labelledTri()
Default construct, with invalid point labels and region (-1).
Definition: labelledTriI.H:60
friend Istream & operator>>(Istream &, labelledTri &)
void setIndex(const label idx) noexcept
Set the index (eg, the region)
Definition: labelledTri.H:141
label & index() noexcept
Non-const access to the index (eg, the region)
Definition: labelledTri.H:135
label index() const noexcept
Return the index (eg, the region)
Definition: labelledTri.H:129
friend Ostream & operator<<(Ostream &, const labelledTri &)
label region() const noexcept
Return the region index.
Definition: labelledTri.H:147
label & region() noexcept
Non-const access to the region index.
Definition: labelledTri.H:153
A triangular face using a FixedList of labels corresponding to mesh vertices.
Definition: triFace.H:72
triPointRef tri(const UList< point > &points) const
Return the triangle.
Definition: triFaceI.H:176
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)
const direction noexcept
Definition: Scalar.H:223
volScalarField & b
Definition: createFields.H:27
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
A template class to specify if a data type is composed solely of Foam::label elements.
Definition: contiguous.H:86
A template class to specify that a data type can be considered as being contiguous in memory.
Definition: contiguous.H:78
labelledTri operator()(const labelledTri &x, const label offset) const
Definition: labelledTri.H:179
Offset operator for ListListOps::combineOffset()
Definition: ListListOps.H:102
T operator()(const T &x, const label offset) const
Definition: ListListOps.H:103