Loading...
Searching...
No Matches
pointZone.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 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::pointZone
29
30Description
31 A subset of mesh points.
32
33 The labels of points in the zone can be obtained from the addressing()
34 list.
35
36 For quick check whether a point belongs to the zone use the lookup
37 mechanism in pointZoneMesh, where all the zoned points are registered
38 with their zone number.
39
40SourceFiles
41 pointZone.C
42 pointZoneNew.C
43
44\*---------------------------------------------------------------------------*/
45
46#ifndef Foam_pointZone_H
47#define Foam_pointZone_H
48
49#include "zone.H"
50#include "pointZoneMeshFwd.H"
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54namespace Foam
55{
56
57// Forward Declarations
58class pointZone;
60
62/*---------------------------------------------------------------------------*\
63 Class pointZone Declaration
64\*---------------------------------------------------------------------------*/
65
66class pointZone
67:
68 public zone
69{
70 // Private Data
71
72 //- Reference to zone list
73 const pointZoneMesh& zoneMesh_;
74
75public:
76
77 // Static Data Members
78
79 //- The name associated with the zone-labels dictionary entry
80 static constexpr const char* labelsName() { return "pointLabels"; }
81
82
83 //- Runtime type information
84 TypeName("pointZone");
86
87 // Declare run-time constructor selection tables
88
90 (
91 autoPtr,
94 (
95 const word& name,
96 const dictionary& dict,
97 const label index,
98 const pointZoneMesh& zm
99 ),
100 (name, dict, index, zm)
101 );
102
103
104 // Constructors
105
106 //- No copy construct
107 pointZone(const pointZone&) = delete;
108
109 //- Construct an empty zone - name="", index=0
110 explicit pointZone(const pointZoneMesh& zm);
111
112 //- Construct an empty zone with specified name and index
114 (
115 const word& name,
116 const label index,
117 const pointZoneMesh& zm
118 );
119
120 //- Construct from components
122 (
123 const word& name,
124 const labelUList& addr,
125 const label index,
126 const pointZoneMesh& zm
127 );
128
129 //- Construct from components, transferring addressing
131 (
132 const word& name,
133 labelList&& addr,
134 const label index,
135 const pointZoneMesh& zm
136 );
137
138 //- Construct from dictionary
140 (
141 const word& name,
142 const dictionary& dict,
143 const label index,
144 const pointZoneMesh& zm
145 );
146
147 //- Copy construct with new mesh reference.
149 (
150 const pointZone& originalZone,
151 const pointZoneMesh& zm,
153 const label newIndex = -1
154 );
155
156 //- Construct empty with original zone information (name, index, groups)
157 //- and mesh reference.
159 (
160 const pointZone& originalZone,
162 const pointZoneMesh& zm,
164 const label newIndex = -1
165 );
166
167 //- Construct empty with original zone information (name, groups),
168 //- resetting the index and zone mesh reference.
170 (
171 const pointZone& originalZone,
174 const label index,
175 const pointZoneMesh& zm
176 );
177
178 //- Construct with original zone information (name, groups),
179 //- resetting the point addressing, the index and zone mesh reference.
181 (
182 const pointZone& originalZone,
183 const labelUList& addr,
185 const label index,
186 const pointZoneMesh& zm
187 );
188
189 //- Construct with a new index and zone mesh information, the name
190 //- of the original zone, (move) resetting the point addressing.
192 (
193 const pointZone& originalZone,
194 labelList&& addr,
196 const label index,
197 const pointZoneMesh& zm
198 );
199
200
201 //- Construct and return a clone, resetting the zone mesh
203 (
204 const pointZoneMesh& zm,
206 const label newIndex = -1
207 ) const
208 {
209 return autoPtr<pointZone>::New(*this, zm, newIndex);
210 }
211
212 //- Construct and return a clone,
213 //- resetting the point list and zone mesh
215 (
216 const pointZoneMesh& zm,
218 const label index,
219 const labelUList& addr
220 ) const
221 {
222 return autoPtr<pointZone>::New(*this, addr, index, zm);
223 }
224
225
226 // Selectors
228 //- Return a pointer to a new point zone
229 // created on freestore from dictionary
231 (
232 const word& name,
233 const dictionary& dict,
234 const label index,
235 const pointZoneMesh& zm
236 );
237
238
239 //- Destructor
240 virtual ~pointZone() = default;
242
243 // Member Functions
244
245 //- The maximum index the zone may contain == mesh nPoints()
246 label max_index() const noexcept;
247
248 //- Return reference to the zone mesh
249 const pointZoneMesh& zoneMesh() const noexcept { return zoneMesh_; }
250
251 //- The addressing (point IDs) used for the zone
252 using zone::addressing;
253
254 //- The local index of the given mesh point, -1 if not in the zone
255 label whichPoint(const label meshPointID) const
256 {
257 return zone::localID(meshPointID);
258 }
259
260
261 // Checks
262
263 //- Check zone definition.
264 // \return True if any errors.
265 virtual bool checkDefinition(const bool report = false) const
266 {
267 return zone::checkDefinition(max_index(), report);
268 }
269
270 //- Check whether zone is synchronised across coupled boundaries.
271 // \return True if any errors.
272 virtual bool checkParallelSync(const bool report = false) const;
273
274
275 // Assign addressing
276
277 //- Move reset addressing from another zone.
278 virtual void resetAddressing(pointZone&& zn);
279
280 //- Copy reset addressing from another zone
281 virtual void resetAddressing(const pointZone& zn);
282
283 //- Copy assign addressing
284 virtual void resetAddressing(const labelUList& addr);
286 //- Move assign addressing
287 virtual void resetAddressing(labelList&& addr);
288
289 //- Assign addressing, clearing demand-driven data
290 void operator=(const pointZone& zn);
291
292 //- Assign addressing, clearing demand-driven data
293 void operator=(const labelUList& addr);
294
295 //- Assign addressing, clearing demand-driven data
296 void operator=(labelList&& addr);
297
298
299 // Mesh Changes
300
301 //- Nothing to correct after moving points
302 virtual void movePoints(const pointField&)
303 {}
304
305
306 // I-O
307
308 //- Write (dictionary entries)
309 virtual void write(Ostream& os) const;
310
311 //- Ostream Operator
312 friend Ostream& operator<<(Ostream& os, const pointZone& zn);
313
314
315 // Housekeeping
316
317 //- Deprecated(2025-09) Write dictionary
318 // \deprecated(2025-09) Write dictionary
319 FOAM_DEPRECATED_FOR(2025-09, "write() or operator<<")
320 void writeDict(Ostream& os) const
321 {
322 os.beginBlock(name()); write(os); os.endBlock();
323 }
324};
325
326
327// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328
329} // End namespace Foam
330
331// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332
333#endif
334
335// ************************************************************************* //
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 list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A subset of mesh points.
Definition pointZone.H:64
declareRunTimeSelectionTable(autoPtr, pointZone, dictionary,(const word &name, const dictionary &dict, const label index, const pointZoneMesh &zm),(name, dict, index, zm))
virtual bool checkDefinition(const bool report=false) const
Check zone definition.
Definition pointZone.H:308
static constexpr const char * labelsName()
The name associated with the zone-labels dictionary entry.
Definition pointZone.H:79
virtual void movePoints(const pointField &)
Nothing to correct after moving points.
Definition pointZone.H:364
label whichPoint(const label meshPointID) const
The local index of the given mesh point, -1 if not in the zone.
Definition pointZone.H:295
TypeName("pointZone")
Runtime type information.
const pointZoneMesh & zoneMesh() const noexcept
Return reference to the zone mesh.
Definition pointZone.H:285
virtual autoPtr< pointZone > clone(const pointZoneMesh &zm, const label index, const labelUList &addr) const
Construct and return a clone, resetting the point list and zone mesh.
Definition pointZone.H:242
virtual autoPtr< pointZone > clone(const pointZoneMesh &zm, const label newIndex=-1) const
Construct and return a clone, resetting the zone mesh.
Definition pointZone.H:228
label max_index() const noexcept
The maximum index the zone may contain == mesh nPoints().
Definition pointZone.C:166
void writeDict(Ostream &os) const
Deprecated(2025-09) Write dictionary.
Definition pointZone.H:389
static autoPtr< pointZone > New(const word &name, const dictionary &dict, const label index, const pointZoneMesh &zm)
Return a pointer to a new point zone.
void operator=(const pointZone &zn)
Assign addressing, clearing demand-driven data.
Definition pointZone.C:281
friend Ostream & operator<<(Ostream &os, const pointZone &zn)
Ostream Operator.
virtual void resetAddressing(pointZone &&zn)
Move reset addressing from another zone.
Definition pointZone.C:233
virtual bool checkParallelSync(const bool report=false) const
Check whether zone is synchronised across coupled boundaries.
Definition pointZone.C:179
virtual ~pointZone()=default
Destructor.
pointZone(const pointZone &)=delete
No copy construct.
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.
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with pointZone content on a polyMesh.
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).
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
vectorField pointField
pointField is a vectorField.
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