zoneSet.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-2026 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 Class
25  Foam::zoneSet
26 
27 Description
28  Zone container returned by zoneGenerator::generate
29 
30  Optionally contains any combination of point, cell or face zones generated
31  by the zoneGenerator::generate function which may simply be the zones
32  returned by a lookup from the lists of zones stored on the mesh or generated
33  by the particular \c zoneGenerator from a geometric search for example.
34 
35  Having \c zoneSet optionally hold zones of more than one type is
36  particularly useful for the generation of complex coupled or related zone
37  systems, for example rotating regions requiring both the \c cellZone of the
38  rotating cells and the faces of the outer moving/sliding boundary.
39 
40 SourceFiles
41  zoneSetI.H
42  zoneSet.C
43 
44 See also
45  Foam::zoneGenerator
46 
47 \*---------------------------------------------------------------------------*/
48 
49 #ifndef zoneSet_H
50 #define zoneSet_H
51 
52 #include "NamedEnum.H"
53 #include "tmpNrc.H"
54 #include "pointZone.H"
55 #include "cellZone.H"
56 #include "faceZone.H"
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 namespace Foam
61 {
62 
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 
65 //- Enumeration defining the zone types
66 enum class zoneTypes
67 {
68  point,
69  cell,
70  face
71 };
72 
73 //- Named enumeration defining the zone type names
74 extern const NamedEnum<zoneTypes, 3> zoneTypesNames;
75 
76 //- Enumeration defining the zone types with an option for all the types
77 enum class zoneTypesAll
78 {
79  point,
80  cell,
81  face,
82  all
83 };
84 
85 //- Named enumeration defining the zone type names
86 // with an option for all the types
87 extern const NamedEnum<zoneTypesAll, 4> zoneTypesAllNames;
88 
89 
90 /*---------------------------------------------------------------------------*\
91  Class zoneSet Declaration
92 \*---------------------------------------------------------------------------*/
93 
94 class zoneSet
95 {
96  // Private Data
97 
98  //- Temporary pointZone
99  tmpNrc<pointZone> pZone_;
100 
101  //- Temporary cellZone
102  tmpNrc<cellZone> cZone_;
103 
104  //- Temporary faceZone
105  tmpNrc<faceZone> fZone_;
106 
107 
108  // Private Member Functions
109 
110  //- Print to FatalError the names of all the types zones allocated
111  template<class ZoneType>
112  void checkValid(const tmpNrc<ZoneType>& zone) const;
113 
114 
115 public:
116 
117  // Constructors
118 
119  //- Construct null
120  inline zoneSet();
121 
122  //- Construct copy transferring content of temporaries
123  inline zoneSet(const zoneSet&);
124 
125  //- Construct copy moving content
126  inline zoneSet(zoneSet&&) = default;
127 
128  //- Construct from pointZone pointer
129  inline zoneSet(pointZone* pointZonePtr);
130 
131  //- Construct from cellZone pointer
132  inline zoneSet(cellZone* cellZonePtr);
133 
134  //- Construct from faceZone pointer
135  inline zoneSet(faceZone* faceZonePtr);
136 
137  //- Construct from pointZone, cellZone and faceZone pointers
138  inline zoneSet
139  (
140  pointZone* pointZonePtr,
141  cellZone* cellZonePtr,
142  faceZone* faceZonePtr
143  );
144 
145  //- Construct from pointZone
146  inline zoneSet(const pointZone& pointZoneRef);
147 
148  //- Construct from cellZone
149  inline zoneSet(const cellZone& cellZoneRef);
150 
151  //- Construct from faceZone
152  inline zoneSet(const faceZone& faceZoneRef);
153 
154  //- Construct copy transferring content of temporaries if required
155  inline zoneSet(const zoneSet&, bool allowTransfer);
156 
157  //- Construct and return a clone with a new name
158  inline zoneSet clone(const word& name) const;
159 
160 
161  // Member Functions
162 
163  //- Return true if the pointZone is allocated
164  inline bool pValid() const;
165 
166  //- Return true if the cellZone is allocated
167  inline bool cValid() const;
168 
169  //- Return true if the faceZone is allocated
170  inline bool fValid() const;
171 
172  //- Return true if any of the zone types are allocated
173  inline bool valid() const;
174 
175  //- Return true if the zone type specified by template specialisation
176  // is allocated
177  template<class ZoneType>
178  inline bool valid() const;
179 
180  //- Return a reference to the pointZone if allocated
181  // otherwise stop with an error
182  inline const pointZone& pZone() const;
183 
184  //- Return a reference to the cellZone if allocated
185  // otherwise stop with an error
186  inline const cellZone& cZone() const;
187 
188  //- Return a reference to the faceZone if allocated
189  // otherwise stop with an error
190  inline const faceZone& fZone() const;
191 
192  //- Return a reference to the zone type
193  // specified by template specialisation if allocated
194  // otherwise stop with an error
195  template<class ZoneType>
196  inline const ZoneType& zone() const;
197 
198  //- Store the temporary zones and return the stored zoneSet
199  zoneSet store() const;
200 
201 
202  // Member Operators
203 
204  //- Assignment transferring the temporary zones
205  void operator=(const zoneSet&);
206 
207  //- Assignment moving content
208  inline zoneSet& operator=(zoneSet&&) = default;
209 
210  //- Assignment to pointZone, updating pZone_
211  inline void operator=(const pointZone&);
212 
213  //- Assignment to cellZone, updating cZone_
214  inline void operator=(const cellZone&);
215 
216  //- Assignment to faceZone, updating fZone_
217  inline void operator=(const faceZone&);
218 };
219 
220 
221 template<>
222 inline bool zoneSet::valid<pointZone>() const;
223 
224 template<>
225 inline bool zoneSet::valid<cellZone>() const;
226 
227 template<>
228 inline bool zoneSet::valid<faceZone>() const;
229 
230 
231 template<>
232 inline const pointZone& zoneSet::zone<pointZone>() const;
233 
234 template<>
235 inline const cellZone& zoneSet::zone<cellZone>() const;
236 
237 template<>
238 inline const faceZone& zoneSet::zone<faceZone>() const;
239 
240 
241 template<class ZoneType>
242 inline zoneTypes zoneType();
243 
244 template<>
246 
247 template<>
249 
250 template<>
252 
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 } // End namespace Foam
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #include "zoneSetI.H"
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 #endif
265 
266 // ************************************************************************* //
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
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:76
Named list of point indices representing a sub-set of the mesh faces.
Definition: pointZone.H:60
A class for managing temporary objects without reference counting.
Definition: tmpNrc.H:53
A class for handling words, derived from string.
Definition: word.H:63
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
zoneSet store() const
Store the temporary zones and return the stored zoneSet.
Definition: zoneSet.C:53
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
Namespace for OpenFOAM.
zoneTypes zoneType< pointZone >()
zoneTypesAll
Enumeration defining the zone types with an option for all the types.
Definition: zoneSet.H:77
zoneTypes zoneType()
zoneTypes zoneType< faceZone >()
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
zoneTypes
Enumeration defining the zone types.
Definition: zoneSet.H:66
const NamedEnum< zoneTypesAll, 4 > zoneTypesAllNames
Named enumeration defining the zone type names.
Definition: zoneSet.C:43
zoneTypes zoneType< cellZone >()
const NamedEnum< zoneTypes, 3 > zoneTypesNames
Named enumeration defining the zone type names.
Definition: zoneSet.C:35