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 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  //- Enumeration defining the zone types
118  enum class zoneTypess
119  {
120  point,
121  cell,
122  face
123  };
124 
125 
126  // Constructors
127 
128  //- Construct null
129  inline zoneSet();
130 
131  //- Construct copy transferring content of temporaries
132  inline zoneSet(const zoneSet&);
133 
134  //- Construct copy moving content
135  inline zoneSet(zoneSet&&) = default;
136 
137  //- Construct from pointZone pointer
138  inline zoneSet(pointZone* pointZonePtr);
139 
140  //- Construct from cellZone pointer
141  inline zoneSet(cellZone* cellZonePtr);
142 
143  //- Construct from faceZone pointer
144  inline zoneSet(faceZone* faceZonePtr);
145 
146  //- Construct from pointZone, cellZone and faceZone pointers
147  inline zoneSet
148  (
149  pointZone* pointZonePtr,
150  cellZone* cellZonePtr,
151  faceZone* faceZonePtr
152  );
153 
154  //- Construct from pointZone
155  inline zoneSet(const pointZone& pointZoneRef);
156 
157  //- Construct from cellZone
158  inline zoneSet(const cellZone& cellZoneRef);
159 
160  //- Construct from faceZone
161  inline zoneSet(const faceZone& faceZoneRef);
162 
163  //- Construct copy transferring content of temporaries if required
164  inline zoneSet(const zoneSet&, bool allowTransfer);
165 
166  //- Construct and return a clone with a new name
167  inline zoneSet clone(const word& name) const;
168 
169 
170  // Member Functions
171 
172  //- Return true if the pointZone is allocated
173  inline bool pValid() const;
174 
175  //- Return true if the cellZone is allocated
176  inline bool cValid() const;
177 
178  //- Return true if the faceZone is allocated
179  inline bool fValid() const;
180 
181  //- Return true if any of the zone types are allocated
182  inline bool valid() const;
183 
184  //- Return true if the zone type specified by template specialisation
185  // is allocated
186  template<class ZoneType>
187  inline bool valid() const;
188 
189  //- Return a reference to the pointZone if allocated
190  // otherwise stop with an error
191  inline const pointZone& pZone() const;
192 
193  //- Return a reference to the cellZone if allocated
194  // otherwise stop with an error
195  inline const cellZone& cZone() const;
196 
197  //- Return a reference to the faceZone if allocated
198  // otherwise stop with an error
199  inline const faceZone& fZone() const;
200 
201  //- Return a reference to the zone type
202  // specified by template specialisation if allocated
203  // otherwise stop with an error
204  template<class ZoneType>
205  inline const ZoneType& zone() const;
206 
207  //- Store the temporary zones and return the stored zoneSet
208  zoneSet store() const;
209 
210 
211  // Member Operators
212 
213  //- Assignment transferring the temporary zones
214  void operator=(const zoneSet&);
215 
216  //- Assignment moving content
217  inline zoneSet& operator=(zoneSet&&) = default;
218 
219  //- Assignment to pointZone, updating pZone_
220  inline void operator=(const pointZone&);
221 
222  //- Assignment to cellZone, updating cZone_
223  inline void operator=(const cellZone&);
224 
225  //- Assignment to faceZone, updating fZone_
226  inline void operator=(const faceZone&);
227 };
228 
229 
230 template<>
231 inline bool zoneSet::valid<pointZone>() const;
232 
233 template<>
234 inline bool zoneSet::valid<cellZone>() const;
235 
236 template<>
237 inline bool zoneSet::valid<faceZone>() const;
238 
239 
240 template<>
241 inline const pointZone& zoneSet::zone<pointZone>() const;
242 
243 template<>
244 inline const cellZone& zoneSet::zone<cellZone>() const;
245 
246 template<>
247 inline const faceZone& zoneSet::zone<faceZone>() const;
248 
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 } // End namespace Foam
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #include "zoneSetI.H"
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #endif
261 
262 // ************************************************************************* //
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: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
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.
zoneTypess
Enumeration defining the zone types.
Definition: zoneSet.H:118
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.
zoneTypesAll
Enumeration defining the zone types with an option for all the types.
Definition: zoneSet.H:77
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
const NamedEnum< zoneTypes, 3 > zoneTypesNames
Named enumeration defining the zone type names.
Definition: zoneSet.C:35