geometricSurfacePatch.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 OpenFOAM Foundation
9 Copyright (C) 2017-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::geometricSurfacePatch
29
30Description
31 Identifies a surface patch/zone by name and index,
32 with geometric type.
33
34SourceFiles
35 geometricSurfacePatch.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef geometricSurfacePatch_H
40#define geometricSurfacePatch_H
41
42#include "surfZoneIdentifier.H"
43#include "stdFoam.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50/*---------------------------------------------------------------------------*\
51 Class geometricSurfacePatch Declaration
52\*---------------------------------------------------------------------------*/
55{
56 // Private Data
57
58 //- Patch/zone name
59 word name_;
60
61 //- Patch/zone index in meshed surface
62 label index_;
63
64 //- Patch/zone type
65 word geometricType_;
66
67public:
68
69 // Public Data
70
71 //- The name for an 'empty' type
72 static constexpr const char* const emptyType = "empty";
73
74
75 // Static Member Functions
76
77 //- Default patch name: "patch" or "patchN"
78 static word defaultName(const label n = -1)
79 {
80 return
81 (
82 n < 0
83 ? word("patch", false)
84 : word("patch" + std::to_string(n), false)
85 );
86 }
87
88
89 // Public Classes
90
91 //- Helper to convert identifier types as an operation
92 struct fromIdentifier
93 {
94 geometricSurfacePatch operator()
95 (
96 const surfZoneIdentifier& ident
97 ) const
98 {
99 return geometricSurfacePatch(ident);
100 }
101 };
102
103
104 // Generated Methods
105
106 //- Copy construct
108
109 //- Copy assignment
111 operator=(const geometricSurfacePatch&) = default;
112
113
114 // Constructors
115
116 //- Default construct.
117 //- Uses name="patch", index=0, type=""
119
120 //- Construct null with specified index.
121 //- Uses name="patch", type=""
122 explicit geometricSurfacePatch(const label index);
123
124 //- Construct from mandatory components, type=""
125 geometricSurfacePatch(const word& name, const label index);
126
127 //- Construct from components
129 (
130 const word& name,
131 const label index,
132 const word& geometricType
133 );
134
135 //- Construct from dictionary
137 (
138 const word& name,
139 const dictionary& dict,
140 const label index
141 );
142
143 //- Implicit conversion from surfZoneIdentifier
145
146
147 // Member Functions
148
149 //- The patch/zone name
150 const word& name() const noexcept
151 {
152 return name_;
153 }
154
155 //- Modifiable patch/zone name
157 {
158 return name_;
159 }
160
161 //- The index of this patch/zone in the surface mesh
162 label index() const noexcept
163 {
164 return index_;
165 }
166
167 //- Modifiable index of this patch/zone in the surface mesh
168 label& index() noexcept
169 {
170 return index_;
171 }
172
173 //- The geometric type of the patch/zone
174 const word& geometricType() const noexcept
175 {
176 return geometricType_;
177 }
178
179 //- Modifiable geometric type of the patch/zone
181 {
182 return geometricType_;
183 }
184
185 //- Write (geometricType) dictionary entry
186 //- (without surrounding braces)
187 // \warning Prior to 2020-01 was identical to operator<< output
188 void write(Ostream& os) const;
189
190
191 // Housekeeping
192
193 //- Removed(2020-01) Construct from Istream
194 // \deprecated(2020-01) - unused, inconsistent
195 geometricSurfacePatch(Istream& is, const label index) = delete;
196
197 //- Deprecated(2020-01) Construct from components
198 // \deprecated(2020-01) - order inconsistent with other identifiers
201 (
202 const word& geometricType,
203 const word& name,
204 const label index
205 )
206 :
208 {}
209
210 //- Deprecated(2020-01) Write dictionary
211 // \deprecated(2020-01) - Write dictionary
212 FOAM_DEPRECATED_FOR(2020-01, "write() or operator<<")
213 void writeDict(Ostream& os) const
214 {
215 write(os);
216 }
217};
218
219
220// Global Operators
221
222//- Compare patches for equality
223bool operator==(const geometricSurfacePatch& a, const geometricSurfacePatch& b);
224
225//- Compare patches for inequality
226bool operator!=(const geometricSurfacePatch& a, const geometricSurfacePatch& b);
227
228
229//- Read name, geometricType
230Istream& operator>>(Istream& is, geometricSurfacePatch& obj);
231
232//- Write name, geometricType. Entries are quoted to support empty words.
233Ostream& operator<<(Ostream& os, const geometricSurfacePatch& obj);
234
235
236// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237
238} // End namespace Foam
239
240// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241
242#endif
243
244// ************************************************************************* //
label n
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 list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Identifies a surface patch/zone by name and index, with geometric type.
word & name() noexcept
Modifiable patch/zone name.
const word & geometricType() const noexcept
The geometric type of the patch/zone.
static constexpr const char *const emptyType
The name for an 'empty' type.
label & index() noexcept
Modifiable index of this patch/zone in the surface mesh.
label index() const noexcept
The index of this patch/zone in the surface mesh.
const word & name() const noexcept
The patch/zone name.
void writeDict(Ostream &os) const
Deprecated(2020-01) Write dictionary.
static word defaultName(const label n=-1)
Default patch name: "patch" or "patchN".
word & geometricType() noexcept
Modifiable geometric type of the patch/zone.
geometricSurfacePatch & operator=(const geometricSurfacePatch &)=default
Copy assignment.
geometricSurfacePatch(const geometricSurfacePatch &)=default
Copy construct.
Identifies a surface patch/zone by name and index, with optional geometric type.
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
bool operator!=(const eddy &a, const eddy &b)
Definition: eddy.H:239
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Istream & operator>>(Istream &, directionInfo &)
const direction noexcept
Definition: Scalar.H:223
runTime write()
dictionary dict
volScalarField & b
Definition: createFields.H:27
Includes some standard C++ headers, defines global macros and templates used in multiple places by Op...
#define FOAM_DEPRECATED(since)
Definition: stdFoam.H:51
#define FOAM_DEPRECATED_FOR(since, replacement)
Definition: stdFoam.H:52
Helper to convert identifier types as an operation.