Loading...
Searching...
No Matches
cellZone.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-2016 OpenFOAM Foundation
9 Copyright (C) 2017-2025 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::cellZone
29
30Description
31 A subset of mesh cells.
32
33 Currently set up as an indirect list but will be extended to use a
34 primitive mesh. For quick check whether a cell belongs to the zone use
35 the lookup mechanism in cellZoneMesh, where all the zoned cells are
36 registered with their zone number.
37
38SourceFiles
39 cellZone.C
40 cellZoneNew.C
41
42\*---------------------------------------------------------------------------*/
43
44#ifndef Foam_cellZone_H
45#define Foam_cellZone_H
46
47#include "zone.H"
48#include "cellZoneMeshFwd.H"
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52namespace Foam
53{
54
55// Forward Declarations
56class cellZone;
59/*---------------------------------------------------------------------------*\
60 Class cellZone Declaration
61\*---------------------------------------------------------------------------*/
62
63class cellZone
64:
65 public zone
66{
67 // Private Data
68
69 //- Reference to zone list
70 const cellZoneMesh& zoneMesh_;
71
72
73public:
74
75 // Static Data Members
76
77 //- The name associated with the zone-labels dictionary entry
78 static constexpr const char* labelsName() { return "cellLabels"; }
79
80
81 //- Runtime type information
82 TypeName("cellZone");
84
85 // Declare run-time constructor selection tables
86
88 (
89 autoPtr,
92 (
93 const word& name,
94 const dictionary& dict,
95 const label index,
96 const cellZoneMesh& zm
97 ),
98 (name, dict, index, zm)
99 );
100
101
102 // Constructors
103
104 //- No copy construct
105 cellZone(const cellZone&) = delete;
106
107 //- Construct an empty zone - name="", index=0
108 explicit cellZone(const cellZoneMesh& zm);
109
110 //- Construct an empty zone with specified name and index
112 (
113 const word& name,
114 const label index,
115 const cellZoneMesh& zm
116 );
117
118 //- Construct from components
120 (
121 const word& name,
122 const labelUList& addr,
123 const label index,
124 const cellZoneMesh& zm
125 );
126
127 //- Construct from components, transferring addressing
129 (
130 const word& name,
131 labelList&& addr,
132 const label index,
133 const cellZoneMesh& zm
134 );
135
136 //- Construct from dictionary
138 (
139 const word& name,
140 const dictionary& dict,
141 const label index,
142 const cellZoneMesh& zm
143 );
144
145 //- Copy construct with new mesh reference.
147 (
148 const cellZone& originalZone,
149 const cellZoneMesh& zm,
151 const label newIndex = -1
152 );
153
154 //- Construct empty with original zone information (name, index, groups)
155 //- and mesh reference.
157 (
158 const cellZone& originalZone,
160 const cellZoneMesh& zm,
162 const label newIndex = -1
163 );
164
165 //- Construct empty with original zone information (name, groups),
166 //- resetting the index and zone mesh reference.
168 (
169 const cellZone& originalZone,
172 const label index,
173 const cellZoneMesh& zm
174 );
175
176 //- Construct with original zone information (name, groups),
177 //- resetting the cell list, the index and zone mesh reference.
179 (
180 const cellZone& originalZone,
181 const labelUList& addr,
183 const label index,
184 const cellZoneMesh& zm
185 );
186
187 //- Construct with original zone information (name, groups),
188 //- resetting the cell list, the index and zone mesh reference.
190 (
191 const cellZone& originalZone,
192 labelList&& addr,
194 const label index,
195 const cellZoneMesh& zm
196 );
197
198
199 //- Construct and return a clone, resetting the zone mesh
201 (
202 const cellZoneMesh& zm,
204 const label newIndex = -1
205 ) const
206 {
207 return autoPtr<cellZone>::New(*this, zm, newIndex);
208 }
209
210 //- Construct and return a clone,
211 //- resetting the cell list and zone mesh
213 (
214 const labelUList& addr,
216 const label index,
217 const cellZoneMesh& zm
218 ) const
219 {
220 return autoPtr<cellZone>::New(*this, addr, index, zm);
221 }
222
223
224 // Selectors
226 //- Return a pointer to a new cell zone
227 //- created on freestore from dictionary
229 (
230 const word& name,
231 const dictionary& dict,
232 const label index,
233 const cellZoneMesh& zm
234 );
235
236
237 //- Destructor
238 virtual ~cellZone() = default;
240
241 // Member Functions
242
243 //- The maximum index the zone may contain == mesh nCells()
244 label max_index() const noexcept;
245
246 //- Return reference to the zone mesh
247 const cellZoneMesh& zoneMesh() const noexcept { return zoneMesh_; }
248
249 //- The addressing (cell IDs) used for the zone
250 using zone::addressing;
251
252 //- The local index of the given mesh cell, -1 if not in the zone
253 label whichCell(const label meshCellID) const
254 {
255 return zone::localID(meshCellID);
256 }
257
258
259 // Checks
260
261 //- Check zone definition.
262 // \return True if any errors.
263 virtual bool checkDefinition(const bool report = false) const
264 {
265 return zone::checkDefinition(max_index(), report);
266 }
267
268 //- Check whether zone is synchronised across coupled boundaries.
269 // \return True if any errors.
270 virtual bool checkParallelSync(const bool report = false) const
271 {
272 return false;
273 }
274
275
276 // Assign addressing
277
278 //- Move reset addressing from another zone
279 virtual void resetAddressing(cellZone&& zn);
280
281 //- Copy reset addressing from another zone
282 virtual void resetAddressing(const cellZone& zn);
283
284 //- Copy assign addressing
285 virtual void resetAddressing(const labelUList& addr);
286
287 //- Move assign addressing
288 virtual void resetAddressing(labelList&& addr);
289
290 //- Assign addressing, clearing demand-driven data
291 void operator=(const cellZone& zn);
293 //- Assign addressing, clearing demand-driven data
294 void operator=(const labelUList& addr);
295
296 //- Move assign addressing, clearing demand-driven data
297 void operator=(labelList&& addr);
298
299
300 // I-O
301
302 //- Write (dictionary entries)
303 virtual void write(Ostream& os) const;
304
305 //- Ostream Operator
306 friend Ostream& operator<<(Ostream& os, const cellZone& zn);
307
308
309 // Housekeeping
310
311 //- Deprecated(2025-09) Write dictionary
312 // \deprecated(2025-09) Write dictionary
313 FOAM_DEPRECATED_FOR(2025-09, "write() or operator<<")
314 void writeDict(Ostream& os) const
316 os.beginBlock(name()); write(os); os.endBlock();
317 }
318};
319
320
321// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
322
323} // End namespace Foam
324
325// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
326
327#endif
328
329// ************************************************************************* //
autoPtr< List< label > > clone() const
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition autoPtr.H:178
A subset of mesh cells.
Definition cellZone.H:61
void operator=(const cellZone &zn)
Assign addressing, clearing demand-driven data.
Definition cellZone.C:226
virtual bool checkDefinition(const bool report=false) const
Check zone definition.
Definition cellZone.H:305
label whichCell(const label meshCellID) const
The local index of the given mesh cell, -1 if not in the zone.
Definition cellZone.H:292
static autoPtr< cellZone > New(const word &name, const dictionary &dict, const label index, const cellZoneMesh &zm)
Return a pointer to a new cell zone created on freestore from dictionary.
Definition cellZoneNew.C:28
static constexpr const char * labelsName()
The name associated with the zone-labels dictionary entry.
Definition cellZone.H:77
virtual bool checkParallelSync(const bool report=false) const
Check whether zone is synchronised across coupled boundaries.
Definition cellZone.H:315
virtual void resetAddressing(cellZone &&zn)
Move reset addressing from another zone.
Definition cellZone.C:178
virtual autoPtr< cellZone > clone(const cellZoneMesh &zm, const label newIndex=-1) const
Construct and return a clone, resetting the zone mesh.
Definition cellZone.H:226
declareRunTimeSelectionTable(autoPtr, cellZone, dictionary,(const word &name, const dictionary &dict, const label index, const cellZoneMesh &zm),(name, dict, index, zm))
virtual autoPtr< cellZone > clone(const labelUList &addr, const label index, const cellZoneMesh &zm) const
Construct and return a clone, resetting the cell list and zone mesh.
Definition cellZone.H:240
friend Ostream & operator<<(Ostream &os, const cellZone &zn)
Ostream Operator.
label max_index() const noexcept
The maximum index the zone may contain == mesh nCells().
Definition cellZone.C:165
const cellZoneMesh & zoneMesh() const noexcept
Return reference to the zone mesh.
Definition cellZone.H:282
void writeDict(Ostream &os) const
Deprecated(2025-09) Write dictionary.
Definition cellZone.H:380
TypeName("cellZone")
Runtime type information.
virtual ~cellZone()=default
Destructor.
cellZone(const cellZone &)=delete
No copy construct.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling words, derived from Foam::string.
Definition word.H:66
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
label index() const noexcept
The index of this zone in the zone list.
const word & name() const noexcept
The zone name.
virtual bool checkDefinition(const bool report=false) const =0
Check zone definition. Return true if in error.
label localID(const label globalID) const
Lookup local address in zone for given global index.
Definition zone.C:149
zone()
Default construct: empty zone with name="", index=0.
Definition zone.C:37
const labelList & addressing() const noexcept
The addressing used by the zone.
Definition zone.H:182
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
ZoneMesh< cellZone, polyMesh > cellZoneMesh
A ZoneMesh with cellZone content on a polyMesh.
const direction noexcept
Definition scalarImpl.H:265
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
UList< label > labelUList
A UList of labels.
Definition UList.H:75
runTime write()
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
dictionary dict
#define FOAM_DEPRECATED_FOR(since, replacement)
Definition stdFoam.H:43
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68