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 -------------------------------------------------------------------------------
11 License
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 Class
28  Foam::labelledTri
29 
30 Description
31  A triFace with additional (region) index.
32 
33 SourceFiles
34  labelledTriI.H
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_labelledTri_H
39 #define Foam_labelledTri_H
40 
41 #include "triFace.H"
42 #include "ListListOps.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward Declarations
50 class labelledTri;
51 inline Istream& operator>>(Istream&, labelledTri&);
52 inline Ostream& operator<<(Ostream&, const labelledTri&);
53 
54 /*---------------------------------------------------------------------------*\
55  Class labelledTri Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class 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 
75 public:
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 p0,
95  const label p1,
96  const label p2,
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
161 
164 };
165 
166 
167 // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
168 
169 //- Contiguous data for labelledTri
170 template<> struct is_contiguous<labelledTri> : std::true_type {};
172 //- Contiguous label data for labelledTri
173 template<> struct is_contiguous_label<labelledTri> : std::true_type {};
174 
175 
176 //- Specialization to offset faces, used in ListListOps::combineOffset
177 template<>
178 struct offsetOp<labelledTri>
179 {
180  labelledTri operator()(const labelledTri& x, const label offset) const
181  {
182  labelledTri f(x);
183  f += offset;
184  return f;
185  }
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #include "labelledTriI.H"
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #endif
200 
201 // ************************************************************************* //
triPointRef tri(const UList< point > &points) const
Return the triangle.
Definition: triFaceI.H:167
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
label index() const noexcept
Return the index (eg, the region)
Definition: labelledTri.H:147
labelledTri()
Default construct, with invalid point labels and region (-1).
Definition: labelledTriI.H:53
T operator()(const T &x, const label offset) const
Definition: ListListOps.H:101
friend Ostream & operator<<(Ostream &, const labelledTri &)
void setIndex(const label idx) noexcept
Set the index (eg, the region)
Definition: labelledTri.H:163
label region() const noexcept
Return the region index.
Definition: labelledTri.H:171
A triangular face using a FixedList of labels corresponding to mesh vertices.
Definition: triFace.H:65
Istream & operator>>(Istream &, directionInfo &)
friend Istream & operator>>(Istream &, labelledTri &)
A triFace with additional (region) index.
Definition: labelledTri.H:53
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
labelList f(nPoints)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
Offset operator for ListListOps::combineOffset()
Definition: ListListOps.H:99
A template class to specify that a data type can be considered as being contiguous in memory...
Definition: contiguous.H:70
A template class to specify if a data type is composed solely of Foam::label elements.
Definition: contiguous.H:75
const volScalarField & p0
Definition: EEqn.H:36
Namespace for OpenFOAM.