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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::zoneIdentifier
28 
29 Description
30  Identifies a mesh zone by name and index, with optional physical type
31  and group information.
32 
33 SeeAlso
34  patchIdentifier
35 
36 SourceFiles
37  zoneIdentifier.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef zoneIdentifier_H
42 #define zoneIdentifier_H
43 
44 #include "wordList.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward Declarations
52 class dictionary;
53 
54 /*---------------------------------------------------------------------------*\
55  Class zoneIdentifier Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class zoneIdentifier
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 
74 public:
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
130  word& name() noexcept
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)
188 
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 } // End namespace Foam
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 #endif
197 
198 // ************************************************************************* //
dictionary dict
bool inGroup(const word &name) const
True if given name is in a group.
zoneIdentifier()
Default construct. Uses name="", index=0.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
bool found(const T &val, label pos=0) const
True if the value if found in the list.
Definition: UListI.H:258
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual ~zoneIdentifier()=default
Destructor.
void write(Ostream &os) const
Write (physicalType, inGroups) dictionary entries (without surrounding braces)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
const direction noexcept
Definition: Scalar.H:258
label index() const noexcept
The index of this zone in the zone list.
OBJstream os(runTime.globalPath()/outputName)
const word & physicalType() const noexcept
The (optional) type of the zone.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:76
List< word > wordList
A List of words.
Definition: fileName.H:58
Identifies a mesh zone by name and index, with optional physical type and group information.
const word & name() const noexcept
The zone name.
const wordList & inGroups() const noexcept
The (optional) groups that the zone belongs to.
zoneIdentifier & operator=(const zoneIdentifier &)=default
Copy assignment.
volScalarField & p
Namespace for OpenFOAM.