zoneSetI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
27 
28 template<class ZoneType>
29 inline void Foam::zoneSet::checkValid(const tmpNrc<ZoneType>& zone) const
30 {
31  if (!zone.valid())
32  {
34  << "zoneSet does not contain a " << ZoneType::typeName << nl;
35 
36  if (pZone_.valid())
37  {
39  << " zoneSet contains pointZone " << pZone_().name() << nl;
40  }
41 
42  if (cZone_.valid())
43  {
45  << " zoneSet contains cellZone " << cZone_().name() << nl;
46  }
47 
48  if (fZone_.valid())
49  {
51  << " zoneSet contains facesZone " << fZone_().name() << nl;
52  }
53 
55  }
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 
62 :
63  pZone_(nullptr),
64  cZone_(nullptr),
65  fZone_(nullptr)
66 {}
67 
68 
70 :
71  pZone_(zs.pZone_),
72  cZone_(zs.cZone_),
73  fZone_(zs.fZone_)
74 {}
75 
76 
77 inline Foam::zoneSet::zoneSet(pointZone* pointZonePtr)
78 :
79  pZone_(pointZonePtr),
80  cZone_(nullptr),
81  fZone_(nullptr)
82 {}
83 
84 
85 inline Foam::zoneSet::zoneSet(cellZone* cellZonePtr)
86 :
87  pZone_(nullptr),
88  cZone_(cellZonePtr),
89  fZone_(nullptr)
90 {}
91 
92 
93 inline Foam::zoneSet::zoneSet(faceZone* faceZonePtr)
94 :
95  pZone_(nullptr),
96  cZone_(nullptr),
97  fZone_(faceZonePtr)
98 {}
99 
100 
102 (
103  pointZone* pointZonePtr,
104  cellZone* cellZonePtr,
105  faceZone* faceZonePtr
106 )
107 :
108  pZone_(pointZonePtr),
109  cZone_(cellZonePtr),
110  fZone_(faceZonePtr)
111 {}
112 
113 
114 inline Foam::zoneSet::zoneSet(const pointZone& pointZoneRef)
115 :
116  pZone_(pointZoneRef),
117  cZone_(nullptr),
118  fZone_(nullptr)
119 {}
120 
121 
122 inline Foam::zoneSet::zoneSet(const cellZone& cellZoneRef)
123 :
124  pZone_(nullptr),
125  cZone_(cellZoneRef),
126  fZone_(nullptr)
127 {}
128 
129 
130 inline Foam::zoneSet::zoneSet(const faceZone& faceZoneRef)
131 :
132  pZone_(nullptr),
133  cZone_(nullptr),
134  fZone_(faceZoneRef)
135 {}
136 
137 
138 inline Foam::zoneSet::zoneSet(const zoneSet& zs, bool allowTransfer)
139 :
140  pZone_(zs.pZone_, allowTransfer),
141  cZone_(zs.cZone_, allowTransfer),
142  fZone_(zs.fZone_, allowTransfer)
143 {}
144 
145 
147 {
148  return zoneSet
149  (
150  pZone_.valid()
151  ? pZone_().clone(name).ptr()
152  : nullptr,
153 
154  cZone_.valid()
155  ? cZone_().clone(name).ptr()
156  : nullptr,
157 
158  fZone_.valid()
159  ? fZone_().clone(name).ptr()
160  : nullptr
161  );
162 }
163 
164 
165 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
166 
167 inline bool Foam::zoneSet::pValid() const
168 {
169 
170  return pZone_.valid();
171 }
172 
173 
174 inline bool Foam::zoneSet::cValid() const
175 {
176 
177  return cZone_.valid();
178 }
179 
180 
181 inline bool Foam::zoneSet::fValid() const
182 {
183 
184  return fZone_.valid();
185 }
186 
187 
188 inline bool Foam::zoneSet::valid() const
189 {
190 
191  return pZone_.valid() || cZone_.valid() || fZone_.valid();
192 }
193 
194 
195 template<>
196 inline bool Foam::zoneSet::valid<Foam::pointZone>() const
197 {
198  return pValid();
199 }
200 
201 
202 template<>
203 inline bool Foam::zoneSet::valid<Foam::cellZone>() const
204 {
205  return cValid();
206 }
207 
208 
209 template<>
210 inline bool Foam::zoneSet::valid<Foam::faceZone>() const
211 {
212  return fValid();
213 }
214 
215 
217 {
218  checkValid(pZone_);
219  return pZone_();
220 }
221 
222 
224 {
225  checkValid(cZone_);
226  return cZone_();
227 }
228 
229 
231 {
232  checkValid(fZone_);
233  return fZone_();
234 }
235 
236 
237 template<>
238 inline const Foam::pointZone& Foam::zoneSet::zone<Foam::pointZone>() const
239 {
240  return pZone();
241 }
242 
243 
244 template<>
245 inline const Foam::cellZone& Foam::zoneSet::zone<Foam::cellZone>() const
246 {
247  return cZone();
248 }
249 
250 
251 template<>
252 inline const Foam::faceZone& Foam::zoneSet::zone<Foam::faceZone>() const
253 {
254  return fZone();
255 }
256 
257 
258 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
259 
260 inline void Foam::zoneSet::operator=(const pointZone& pZone)
261 {
262  pZone_ = pZone;
263 }
264 
265 
266 inline void Foam::zoneSet::operator=(const cellZone& cZone)
267 {
268  cZone_ = cZone;
269 }
270 
271 
272 inline void Foam::zoneSet::operator=(const faceZone& fZone)
273 {
274  fZone_ = fZone;
275 }
276 
277 
278 // ************************************************************************* //
Named list of cell indices representing a sub-set of the mesh.
Definition: cellZone.H:61
Named list of face indices representing a sub-set of the mesh faces.
Definition: faceZone.H:66
Named list of point indices representing a sub-set of the mesh faces.
Definition: pointZone.H:60
A class for handling words, derived from string.
Definition: word.H:62
Zone container returned by zoneGenerator::generate.
Definition: zoneSet.H:94
void operator=(const zoneSet &)
Assignment transferring the temporary zones.
Definition: zoneSet.C:93
const faceZone & fZone() const
Return a reference to the faceZone if allocated.
Definition: zoneSetI.H:230
bool valid() const
Return true if any of the zone types are allocated.
Definition: zoneSetI.H:188
const cellZone & cZone() const
Return a reference to the cellZone if allocated.
Definition: zoneSetI.H:223
bool pValid() const
Return true if the pointZone is allocated.
Definition: zoneSetI.H:167
zoneSet()
Construct null.
Definition: zoneSetI.H:61
const pointZone & pZone() const
Return a reference to the pointZone if allocated.
Definition: zoneSetI.H:216
bool fValid() const
Return true if the faceZone is allocated.
Definition: zoneSetI.H:181
const ZoneType & zone() const
Return a reference to the zone type.
zoneSet clone(const word &name) const
Construct and return a clone with a new name.
Definition: zoneSetI.H:146
bool cValid() const
Return true if the cellZone is allocated.
Definition: zoneSetI.H:174
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
T clone(const T &t)
Definition: List.H:55
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
static const char nl
Definition: Ostream.H:267