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-------------------------------------------------------------------------------
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 patchIdentifier_H
40#define patchIdentifier_H
41
42#include "wordList.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49// Forward Declarations
50class dictionary;
51
52/*---------------------------------------------------------------------------*\
53 Class patchIdentifier Declaration
54\*---------------------------------------------------------------------------*/
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 //- 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
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
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
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
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)
199Ostream& operator<<(Ostream& os, const patchIdentifier& ident);
200
201
202// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203
204} // End namespace Foam
205
206// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207
208#endif
209
210// ************************************************************************* //
label n
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
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. Uses 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.
static word defaultName(const label n=-1)
Default patch name: "patch" or "patchN".
patchIdentifier(const patchIdentifier &)=default
Copy construct.
A class for handling words, derived from Foam::string.
Definition: word.H:68
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