Loading...
Searching...
No Matches
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-2023 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::patchIdentifier
29
30Description
31 Identifies a patch by name and index, with optional physical type
32 and group information.
33
34SourceFiles
35 patchIdentifier.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef Foam_patchIdentifier_H
40#define Foam_patchIdentifier_H
41
42#include "wordList.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49// Forward Declarations
50class dictionary;
52/*---------------------------------------------------------------------------*\
53 Class patchIdentifier Declaration
54\*---------------------------------------------------------------------------*/
55
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
72public:
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 //- Move construct
95
96 //- Copy assignment
97 patchIdentifier& operator=(const patchIdentifier&) = default;
99 //- Move assignment
101
102 //- Destructor
103 virtual ~patchIdentifier() = default;
104
105
106 // Constructors
107
108 //- Default construct: name="", index=0
110
111 //- Construct from mandatory components
112 patchIdentifier(const word& name, const label index);
114 //- Construct from components
116 (
117 const word& name,
118 const label index,
119 const word& physicalType,
120 const wordList& inGroups = wordList()
121 );
122
123 //- Construct from dictionary
125 (
126 const word& name,
127 const dictionary& dict,
128 const label index
129 );
130
131 //- Copy construct, resetting the index (if non-negative)
133 (
134 const patchIdentifier& ident,
135 const label newIndex
136 );
137
138 //- Move construct, resetting the index (if non-negative)
140 (
141 patchIdentifier&& ident,
142 const label newIndex
143 );
144
145
146 // Member Functions
147
148 //- The patch name
149 const word& name() const noexcept { return name_; }
150
151 //- Modifiable patch name
152 word& name() noexcept { return name_; }
153
154 //- The index of this patch in the boundaryMesh
155 label index() const noexcept { return index_; }
156
157 //- Modifiable index of this patch in the boundaryMesh
158 label& index() noexcept { return index_; }
159
160 //- The (optional) physical type of the patch
161 const word& physicalType() const noexcept { return physicalType_; }
162
163 //- Modifiable (optional) physical type of the patch
164 word& physicalType() noexcept { return physicalType_; }
165
166 //- The (optional) groups that the patch belongs to
167 const wordList& inGroups() const noexcept { return inGroups_; }
168
169 //- Modifiable (optional) groups that the patch belongs to
170 wordList& inGroups() noexcept { return inGroups_; }
171
172 //- True if given name is in a group
173 bool inGroup(const word& name) const
174 {
175 return (!name.empty() && inGroups_.contains(name));
176 }
177
178 //- Add (unique) group for the patch
179 void addGroup(const word& name)
180 {
181 if (!name.empty() && !inGroups_.contains(name))
182 {
183 inGroups_.push_back(name);
184 }
185 }
186
187 //- Remove group for the patch
188 void removeGroup(const word& name);
189
190 //- Write (physicalType, inGroups) dictionary entries
191 //- (without surrounding braces)
192 void write(Ostream& os) const;
194
195
196// Global Operators
197
198//- Write (physicalType, inGroups) dictionary entries
199//- (without surrounding braces)
201
202
203// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204
205} // End namespace Foam
206
207// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209#endif
210
211// ************************************************************************* //
label n
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Identifies a patch by name and index, with optional physical type and group information.
word & name() noexcept
Modifiable patch name.
const word & physicalType() const noexcept
The (optional) physical type of the patch.
virtual ~patchIdentifier()=default
Destructor.
patchIdentifier & operator=(const patchIdentifier &)=default
Copy assignment.
patchIdentifier()
Default construct: name="", index=0.
bool inGroup(const word &name) const
True if given name is in a group.
label & index() noexcept
Modifiable index of this patch in the boundaryMesh.
const wordList & inGroups() const noexcept
The (optional) groups that the patch belongs to.
label index() const noexcept
The index of this patch in the boundaryMesh.
word & physicalType() noexcept
Modifiable (optional) physical type of the patch.
wordList & inGroups() noexcept
Modifiable (optional) groups that the patch belongs to.
const word & name() const noexcept
The patch name.
patchIdentifier & operator=(patchIdentifier &&)=default
Move assignment.
static word defaultName(const label n=-1)
Default patch name: "patch" or "patchN".
patchIdentifier(patchIdentifier &&)=default
Move construct.
void removeGroup(const word &name)
Remove group for the patch.
patchIdentifier(const patchIdentifier &)=default
Copy construct.
void addGroup(const word &name)
Add (unique) group for the patch.
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
const direction noexcept
Definition scalarImpl.H:265
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
runTime write()
dictionary dict