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 -------------------------------------------------------------------------------
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::geometricSurfacePatch
29 
30 Description
31  Identifies a surface patch/zone by name and index,
32  with geometric type.
33 
34 SourceFiles
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 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class geometricSurfacePatch Declaration
52 \*---------------------------------------------------------------------------*/
53 
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 
67 public:
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  {
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
156  word& name() noexcept
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
180  word& geometricType() noexcept
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
199  FOAM_DEPRECATED(2020-01)
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
223 bool operator==(const geometricSurfacePatch& a, const geometricSurfacePatch& b);
224 
225 //- Compare patches for inequality
226 bool operator!=(const geometricSurfacePatch& a, const geometricSurfacePatch& b);
227 
228 
229 //- Read name, geometricType
230 Istream& operator>>(Istream& is, geometricSurfacePatch& obj);
231 
232 //- Write name, geometricType. Entries are quoted to support empty words.
233 Ostream& operator<<(Ostream& os, const geometricSurfacePatch& obj);
234 
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 } // End namespace Foam
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 #endif
243 
244 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::geometricSurfacePatch
Identifies a surface patch/zone by name and index, with geometric type.
Definition: geometricSurfacePatch.H:53
Foam::geometricSurfacePatch::geometricSurfacePatch
geometricSurfacePatch()
Definition: geometricSurfacePatch.C:34
Foam::geometricSurfacePatch::defaultName
static word defaultName(const label n=-1)
Default patch name: "patch" or "patchN".
Definition: geometricSurfacePatch.H:77
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
surfZoneIdentifier.H
Foam::geometricSurfacePatch::index
label & index() noexcept
Modifiable index of this patch/zone in the surface mesh.
Definition: geometricSurfacePatch.H:167
Foam::surfZoneIdentifier
Identifies a surface patch/zone by name and index, with optional geometric type.
Definition: surfZoneIdentifier.H:59
Foam::geometricSurfacePatch::name
word & name() noexcept
Modifiable patch/zone name.
Definition: geometricSurfacePatch.H:155
Foam::geometricSurfacePatch::geometricType
word & geometricType() noexcept
Modifiable geometric type of the patch/zone.
Definition: geometricSurfacePatch.H:179
Foam::operator!=
bool operator!=(const eddy &a, const eddy &b)
Definition: eddy.H:239
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::geometricSurfacePatch::index
label index() const noexcept
The index of this patch/zone in the surface mesh.
Definition: geometricSurfacePatch.H:161
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::geometricSurfacePatch::write
void write(Ostream &os) const
Definition: geometricSurfacePatch.C:97
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
FOAM_DEPRECATED
#define FOAM_DEPRECATED(since)
Definition: stdFoam.H:65
Foam::geometricSurfacePatch::fromIdentifier
Helper to convert identifier types as an operation.
Definition: geometricSurfacePatch.H:91
stdFoam.H
Foam::geometricSurfacePatch::emptyType
static constexpr const char *const emptyType
The name for an 'empty' type.
Definition: geometricSurfacePatch.H:71
Foam::FOAM_DEPRECATED_FOR
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
Definition: NamedEnum.H:69
Foam::geometricSurfacePatch::geometricType
const word & geometricType() const noexcept
The geometric type of the patch/zone.
Definition: geometricSurfacePatch.H:173
Foam::geometricSurfacePatch::name
const word & name() const noexcept
The patch/zone name.
Definition: geometricSurfacePatch.H:149
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::geometricSurfacePatch::writeDict
void writeDict(Ostream &os) const
Deprecated(2020-01) Write dictionary.
Definition: geometricSurfacePatch.H:212
Foam::geometricSurfacePatch::operator=
geometricSurfacePatch & operator=(const geometricSurfacePatch &)=default
Copy assignment.