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 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::patchIdentifier
29 
30 Description
31  Identifies a patch by name, patch index and physical type
32 
33 SourceFiles
34  patchIdentifier.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef patchIdentifier_H
39 #define patchIdentifier_H
40 
41 #include "wordList.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward Declarations
49 class dictionary;
50 
51 /*---------------------------------------------------------------------------*\
52  Class patchIdentifier Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class patchIdentifier
56 {
57  // Private Data
58 
59  //- Name of patch
60  word name_;
61 
62  //- Index of patch in boundary
63  label index_;
64 
65  //- Optional physical type
66  mutable word physicalType_;
67 
68  //- Optional groups to which the patch belongs
69  wordList inGroups_;
70 
71 public:
72 
73  // Static Member Functions
74 
75  //- Default patch name: "patch" or "patchN"
76  static word defaultName(const label n = -1)
77  {
78  return
79  (
80  n < 0
81  ? word("patch", false)
82  : word("patch" + std::to_string(n), false)
83  );
84  }
85 
86 
87  // Generated Methods
88 
89  //- Copy construct
90  patchIdentifier(const patchIdentifier&) = default;
91 
92  //- Copy assignment
93  patchIdentifier& operator=(const patchIdentifier&) = default;
94 
95  //- Destructor
96  virtual ~patchIdentifier() = default;
97 
98 
99  // Constructors
100 
101  //- Default construct, with index zero
102  patchIdentifier();
103 
104  //- Construct from mandatory components
105  patchIdentifier(const word& name, const label index);
106 
107  //- Construct from components
109  (
110  const word& name,
111  const label index,
112  const word& physicalType,
113  const wordList& inGroups = wordList()
114  );
115 
116  //- Construct from dictionary
118  (
119  const word& name,
120  const dictionary& dict,
121  const label index
122  );
123 
124  //- Copy construct, resetting the index
126  (
127  const patchIdentifier& p,
128  const label index
129  );
130 
131 
132  // Member Functions
133 
134  //- The patch name
135  const word& name() const
136  {
137  return name_;
138  }
139 
140  //- Modifiable patch name
141  word& name()
142  {
143  return name_;
144  }
145 
146  //- The (optional) physical type of the patch
147  const word& physicalType() const
148  {
149  return physicalType_;
150  }
151 
152  //- Modifiable (optional) physical type of the patch
153  word& physicalType()
154  {
155  return physicalType_;
156  }
157 
158  //- The index of this patch in the boundaryMesh
159  label index() const
160  {
161  return index_;
162  }
163 
164  //- Modifiable index of this patch in the boundaryMesh
165  label& index()
166  {
167  return index_;
168  }
169 
170  //- The (optional) groups that the patch belongs to
171  const wordList& inGroups() const
172  {
173  return inGroups_;
174  }
175 
176  //- Modifiable (optional) groups that the patch belongs to
177  wordList& inGroups()
178  {
179  return inGroups_;
180  }
181 
182  //- True if the patch is in named group
183  bool inGroup(const word& name) const
184  {
185  return inGroups_.found(name);
186  }
187 
188  //- Write (physicalType, inGroups) dictionary entries
189  //- (without surrounding braces)
190  void write(Ostream& os) const;
191 };
192 
193 
194 // Global Operators
195 
196 //- Write (physicalType, inGroups) dictionary entries
197 //- (without surrounding braces)
198 Ostream& operator<<(Ostream& os, const patchIdentifier& p);
199 
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 } // End namespace Foam
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 #endif
208 
209 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::patchIdentifier::operator=
patchIdentifier & operator=(const patchIdentifier &)=default
Copy assignment.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::patchIdentifier::index
label & index()
Modifiable index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:164
wordList.H
Foam::patchIdentifier::~patchIdentifier
virtual ~patchIdentifier()=default
Destructor.
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::patchIdentifier
Identifies a patch by name, patch index and physical type.
Definition: patchIdentifier.H:54
Foam::patchIdentifier::inGroups
const wordList & inGroups() const
The (optional) groups that the patch belongs to.
Definition: patchIdentifier.H:170
Foam::patchIdentifier::inGroup
bool inGroup(const word &name) const
True if the patch is in named group.
Definition: patchIdentifier.H:182
Foam::patchIdentifier::physicalType
const word & physicalType() const
The (optional) physical type of the patch.
Definition: patchIdentifier.H:146
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::patchIdentifier::patchIdentifier
patchIdentifier()
Default construct, with index zero.
Definition: patchIdentifier.C:34
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::patchIdentifier::inGroups
wordList & inGroups()
Modifiable (optional) groups that the patch belongs to.
Definition: patchIdentifier.H:176
Foam::patchIdentifier::physicalType
word & physicalType()
Modifiable (optional) physical type of the patch.
Definition: patchIdentifier.H:152
Foam::List< word >
Foam::patchIdentifier::write
void write(Ostream &os) const
Definition: patchIdentifier.C:96
Foam::patchIdentifier::name
word & name()
Modifiable patch name.
Definition: patchIdentifier.H:140
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::patchIdentifier::defaultName
static word defaultName(const label n=-1)
Default patch name: "patch" or "patchN".
Definition: patchIdentifier.H:75
Foam::patchIdentifier::name
const word & name() const
The patch name.
Definition: patchIdentifier.H:134
Foam::patchIdentifier::index
label index() const
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:158