patchIdentifier.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-2013 OpenFOAM Foundation
9  Copyright (C) 2020-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::patchIdentifier
29 
30 Description
31  Identifies a patch by name and index, with optional physical type
32  and group information.
33 
34 SourceFiles
35  patchIdentifier.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef patchIdentifier_H
40 #define patchIdentifier_H
41 
42 #include "wordList.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward Declarations
50 class dictionary;
51 
52 /*---------------------------------------------------------------------------*\
53  Class patchIdentifier Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class patchIdentifier
57 {
58  // Private Data
59 
60  //- Patch name
61  word name_;
62 
63  //- Patch index in boundary
64  label index_;
65 
66  //- Patch physical type (optional)
67  word physicalType_;
68 
69  //- Groups to which the patch belongs (optional)
70  wordList inGroups_;
71 
72 public:
73 
74  // Static Member Functions
75 
76  //- Default patch name: "patch" or "patchN"
77  static word defaultName(const label n = -1)
78  {
79  return
80  (
81  n < 0
82  ? word("patch", false)
83  : word("patch" + std::to_string(n), false)
84  );
85  }
86 
87 
88  // Generated Methods
89 
90  //- Copy construct
91  patchIdentifier(const patchIdentifier&) = default;
92 
93  //- Copy assignment
94  patchIdentifier& operator=(const patchIdentifier&) = default;
95 
96  //- Destructor
97  virtual ~patchIdentifier() = default;
98 
99 
100  // Constructors
101 
102  //- Default construct. Uses name="", index=0
103  patchIdentifier();
104 
105  //- Construct from mandatory components
106  patchIdentifier(const word& name, const label index);
107 
108  //- Construct from components
110  (
111  const word& name,
112  const label index,
113  const word& physicalType,
114  const wordList& inGroups = wordList()
115  );
116 
117  //- Construct from dictionary
119  (
120  const word& name,
121  const dictionary& dict,
122  const label index
123  );
124 
125  //- Copy construct, resetting the index
127  (
128  const patchIdentifier& ident,
129  const label index
130  );
131 
132 
133  // Member Functions
134 
135  //- The patch name
136  const word& name() const noexcept
137  {
138  return name_;
139  }
140 
141  //- Modifiable patch name
142  word& name() noexcept
143  {
144  return name_;
145  }
146 
147  //- The index of this patch in the boundaryMesh
148  label index() const noexcept
149  {
150  return index_;
151  }
152 
153  //- Modifiable index of this patch in the boundaryMesh
154  label& index() noexcept
155  {
156  return index_;
157  }
158 
159  //- The (optional) physical type of the patch
160  const word& physicalType() const noexcept
161  {
162  return physicalType_;
163  }
164 
165  //- Modifiable (optional) physical type of the patch
166  word& physicalType() noexcept
167  {
168  return physicalType_;
169  }
170 
171  //- The (optional) groups that the patch belongs to
172  const wordList& inGroups() const noexcept
173  {
174  return inGroups_;
175  }
176 
177  //- Modifiable (optional) groups that the patch belongs to
178  wordList& inGroups() noexcept
179  {
180  return inGroups_;
181  }
182 
183  //- True if given name is in a group
184  bool inGroup(const word& name) const
185  {
186  return inGroups_.found(name);
187  }
188 
189  //- Write (physicalType, inGroups) dictionary entries
190  //- (without surrounding braces)
191  void write(Ostream& os) const;
192 };
193 
194 
195 // Global Operators
196 
197 //- Write (physicalType, inGroups) dictionary entries
198 //- (without surrounding braces)
199 Ostream& operator<<(Ostream& os, const patchIdentifier& ident);
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 } // End namespace Foam
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #endif
209 
210 // ************************************************************************* //
Foam::patchIdentifier::operator=
patchIdentifier & operator=(const patchIdentifier &)=default
Copy assignment.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::patchIdentifier::name
word & name() noexcept
Modifiable patch name.
Definition: patchIdentifier.H:141
Foam::patchIdentifier::physicalType
word & physicalType() noexcept
Modifiable (optional) physical type of the patch.
Definition: patchIdentifier.H:165
Foam::patchIdentifier::index
label & index() noexcept
Modifiable index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:153
wordList.H
Foam::patchIdentifier::~patchIdentifier
virtual ~patchIdentifier()=default
Destructor.
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
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::patchIdentifier
Identifies a patch by name and index, with optional physical type and group information.
Definition: patchIdentifier.H:55
Foam::patchIdentifier::inGroups
const wordList & inGroups() const noexcept
The (optional) groups that the patch belongs to.
Definition: patchIdentifier.H:171
Foam::patchIdentifier::inGroup
bool inGroup(const word &name) const
True if given name is in a group.
Definition: patchIdentifier.H:183
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::patchIdentifier::patchIdentifier
patchIdentifier()
Default construct. Uses name="", index=0.
Definition: patchIdentifier.C:34
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::patchIdentifier::index
label index() const noexcept
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:147
Foam::List< word >
Foam::patchIdentifier::write
void write(Ostream &os) const
Definition: patchIdentifier.C:96
Foam::patchIdentifier::name
const word & name() const noexcept
The patch name.
Definition: patchIdentifier.H:135
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::patchIdentifier::defaultName
static word defaultName(const label n=-1)
Default patch name: "patch" or "patchN".
Definition: patchIdentifier.H:76
Foam::patchIdentifier::physicalType
const word & physicalType() const noexcept
The (optional) physical type of the patch.
Definition: patchIdentifier.H:159
Foam::patchIdentifier::inGroups
wordList & inGroups() noexcept
Modifiable (optional) groups that the patch belongs to.
Definition: patchIdentifier.H:177