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 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 zoneIdentifier_H
42#define zoneIdentifier_H
43
44#include "wordList.H"
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48namespace Foam
49{
50
51// Forward Declarations
52class dictionary;
53
54/*---------------------------------------------------------------------------*\
55 Class zoneIdentifier Declaration
56\*---------------------------------------------------------------------------*/
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 //- Copy assignment
82 zoneIdentifier& operator=(const zoneIdentifier&) = default;
83
84 //- Destructor
85 virtual ~zoneIdentifier() = default;
86
87
88 // Constructors
89
90 //- Default construct. Uses name="", index=0
92
93 //- Construct from mandatory components
94 zoneIdentifier(const word& name, const label index);
95
96 //- Construct from components
98 (
99 const word& name,
100 const label index,
101 const word& physicalType,
102 const wordList& inGroups = wordList()
103 );
104
105 //- Construct from dictionary
107 (
108 const word& name,
109 const dictionary& dict,
110 const label index
111 );
112
113 //- Copy construct, resetting the index
115 (
116 const zoneIdentifier& ident,
117 const label index
118 );
119
120
121 // Member Functions
122
123 //- The zone name
124 const word& name() const noexcept
125 {
126 return name_;
127 }
128
129 //- Modifiable zone name
131 {
132 return name_;
133 }
134
135 //- The index of this zone in the zone list
136 label index() const noexcept
137 {
138 return index_;
139 }
140
141 //- Modifiable index of this zone in the zone list
142 label& index() noexcept
143 {
144 return index_;
145 }
146
147 //- The (optional) type of the zone
148 const word& physicalType() const noexcept
149 {
150 return physicalType_;
151 }
152
153 //- Modifiable (optional) type of the zone
155 {
156 return physicalType_;
157 }
158
159 //- The (optional) groups that the zone belongs to
160 const wordList& inGroups() const noexcept
161 {
162 return inGroups_;
163 }
164
165 //- Modifiable (optional) groups that the zone belongs to
167 {
168 return inGroups_;
169 }
170
171 //- True if given name is in a group
172 bool inGroup(const word& name) const
173 {
174 return inGroups_.found(name);
175 }
176
177 //- Write (physicalType, inGroups) dictionary entries
178 //- (without surrounding braces)
179 void write(Ostream& os) const;
180};
181
182
183// Global Operators
184
185//- Write (physicalType, inGroups) dictionary entries
186//- (without surrounding braces)
187Ostream& operator<<(Ostream& os, const zoneIdentifier& p);
188
189
190// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191
192} // End namespace Foam
193
194// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195
196#endif
197
198// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
bool found(const T &val, label pos=0) const
True if the value if found in the list.
Definition: UListI.H:265
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling words, derived from Foam::string.
Definition: word.H:68
Identifies a mesh zone by name and index, with optional physical type and group information.
word & name() noexcept
Modifiable zone name.
const word & physicalType() const noexcept
The (optional) type of the zone.
zoneIdentifier()
Default construct. Uses 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.
virtual ~zoneIdentifier()=default
Destructor.
zoneIdentifier & operator=(const zoneIdentifier &)=default
Copy assignment.
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:63
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
const direction noexcept
Definition: Scalar.H:223
runTime write()
dictionary dict