Loading...
Searching...
No Matches
zoneIdentifier.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) 2021-2023 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::zoneIdentifier
28
29Description
30 Identifies a mesh zone by name and index, with optional physical type
31 and group information.
32
33SeeAlso
34 patchIdentifier
35
36SourceFiles
37 zoneIdentifier.C
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef Foam_zoneIdentifier_H
42#define Foam_zoneIdentifier_H
43
44#include "wordList.H"
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48namespace Foam
49{
50
51// Forward Declarations
52class dictionary;
54/*---------------------------------------------------------------------------*\
55 Class zoneIdentifier Declaration
56\*---------------------------------------------------------------------------*/
57
59{
60 // Private Data
61
62 //- Zone name
63 word name_;
64
65 //- Zone index in mesh
66 label index_;
67
68 //- Zone type (optional)
69 word physicalType_;
70
71 //- Groups to which the zone belongs (optional)
72 wordList inGroups_;
73
74public:
75
76 // Generated Methods
77
78 //- Copy construct
79 zoneIdentifier(const zoneIdentifier&) = default;
80
81 //- Move construct
82 zoneIdentifier(zoneIdentifier&&) = default;
83
84 //- Copy assignment
85 zoneIdentifier& operator=(const zoneIdentifier&) = default;
86
87 //- Move assignment
90 //- Destructor
91 virtual ~zoneIdentifier() = default;
92
93
94 // Constructors
95
96 //- Default construct: name="", index=0
98
99 //- Construct from mandatory components
100 zoneIdentifier(const word& name, const label index);
101
102 //- Construct from components
105 const word& name,
106 const label index,
107 const word& physicalType,
108 const wordList& inGroups = wordList()
109 );
110
111 //- Construct from dictionary
113 (
114 const word& name,
115 const dictionary& dict,
116 const label index
117 );
118
119 //- Copy construct, resetting the index (if non-negative)
121 (
122 const zoneIdentifier& ident,
123 const label newIndex
124 );
125
126 //- Move construct, resetting the index (if non-negative)
128 (
129 zoneIdentifier&& ident,
130 const label newIndex
131 );
132
133
134 // Member Functions
135
136 //- The zone name
137 const word& name() const noexcept { return name_; }
138
139 //- Modifiable zone name
140 word& name() noexcept { return name_; }
141
142 //- The index of this zone in the zone list
143 label index() const noexcept { return index_; }
144
145 //- Modifiable index of this zone in the zone list
146 label& index() noexcept { return index_; }
147
148 //- The (optional) type of the zone
149 const word& physicalType() const noexcept { return physicalType_; }
150
151 //- Modifiable (optional) type of the zone
152 word& physicalType() noexcept { return physicalType_; }
153
154 //- The (optional) groups that the zone belongs to
155 const wordList& inGroups() const noexcept { return inGroups_; }
156
157 //- Modifiable (optional) groups that the zone belongs to
158 wordList& inGroups() noexcept { return inGroups_; }
159
160 //- True if given name is in a group
161 bool inGroup(const word& name) const
162 {
163 return (!name.empty() && inGroups_.contains(name));
165
166 //- Add (unique) group for the zone
167 void addGroup(const word& name)
168 {
169 if (!name.empty() && !inGroups_.contains(name))
170 {
171 inGroups_.push_back(name);
172 }
173 }
175 //- Remove group for the zone
176 void removeGroup(const word& name);
177
178 //- Write (physicalType, inGroups) dictionary entries
179 //- (without surrounding braces)
180 void write(Ostream& os) const;
181};
182
183
184// Global Operators
185
186//- Write (physicalType, inGroups) dictionary entries
187//- (without surrounding braces)
190
191// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192
193} // End namespace Foam
195// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196
197#endif
198
199// ************************************************************************* //
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
A class for handling words, derived from Foam::string.
Definition word.H:66
word & name() noexcept
Modifiable zone name.
const word & physicalType() const noexcept
The (optional) type of the zone.
zoneIdentifier()
Default construct: name="", index=0.
zoneIdentifier(const zoneIdentifier &)=default
Copy construct.
bool inGroup(const word &name) const
True if given name is in a group.
label & index() noexcept
Modifiable index of this zone in the zone list.
const wordList & inGroups() const noexcept
The (optional) groups that the zone belongs to.
label index() const noexcept
The index of this zone in the zone list.
word & physicalType() noexcept
Modifiable (optional) type of the zone.
wordList & inGroups() noexcept
Modifiable (optional) groups that the zone belongs to.
const word & name() const noexcept
The zone name.
zoneIdentifier(zoneIdentifier &&)=default
Move construct.
virtual ~zoneIdentifier()=default
Destructor.
zoneIdentifier & operator=(const zoneIdentifier &)=default
Copy assignment.
void removeGroup(const word &name)
Remove group for the zone.
zoneIdentifier & operator=(zoneIdentifier &&)=default
Move assignment.
void addGroup(const word &name)
Add (unique) group for the zone.
volScalarField & p
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