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-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::pointZone
29 
30 Description
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 
40 SourceFiles
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 
54 namespace Foam
55 {
56 
57 // Forward Declarations
58 class pointZone;
59 Ostream& operator<<(Ostream& os, const pointZone& zn);
60 
61 
62 /*---------------------------------------------------------------------------*\
63  Class pointZone Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class pointZone
67 :
68  public zone
69 {
70  // Private Data
71 
72  //- Reference to zone list
73  const pointZoneMesh& zoneMesh_;
74 
75 public:
76 
77  // Static Data Members
78 
79  //- The name associated with the zone-labels dictionary entry
80  //- ("pointLabels")
81  static const char * const labelsName;
82 
83 
84  //- Runtime type information
85  TypeName("pointZone");
86 
87 
88  // Declare run-time constructor selection tables
89 
91  (
92  autoPtr,
93  pointZone,
94  dictionary,
95  (
96  const word& name,
97  const dictionary& dict,
98  const label index,
99  const pointZoneMesh& zm
100  ),
101  (name, dict, index, zm)
102  );
103 
104 
105  // Constructors
106 
107  //- No copy construct
108  pointZone(const pointZone&) = delete;
109 
110  //- Construct an empty zone - name="", index=0
111  explicit pointZone(const pointZoneMesh& zm);
112 
113  //- Construct an empty zone with specified name and index
114  pointZone
115  (
116  const word& name,
117  const label index,
118  const pointZoneMesh& zm
119  );
120 
121  //- Construct from components
122  pointZone
123  (
124  const word& name,
125  const labelUList& addr,
126  const label index,
127  const pointZoneMesh& zm
128  );
129 
130  //- Construct from components, transferring addressing
131  pointZone
132  (
133  const word& name,
134  labelList&& addr,
135  const label index,
136  const pointZoneMesh& zm
137  );
138 
139  //- Construct from dictionary
140  pointZone
141  (
142  const word& name,
143  const dictionary& dict,
144  const label index,
145  const pointZoneMesh& zm
146  );
147 
148  //- Construct empty with original zone information (name, index, groups)
149  //- and mesh reference. Optionally specify a new index.
150  pointZone
151  (
152  const pointZone& originalZone,
153  const Foam::zero,
154  const pointZoneMesh& zm,
155  const label newIndex = -1
156  );
157 
158  //- Construct empty with original zone information (name, groups),
159  //- resetting the index and zone mesh reference.
160  pointZone
161  (
162  const pointZone& originalZone,
163  const Foam::zero,
164  const label index,
165  const pointZoneMesh& zm
166  );
167 
168  //- Construct with original zone information (name, groups),
169  //- resetting the point addressing, the index and zone mesh reference.
170  pointZone
171  (
172  const pointZone& originalZone,
173  const labelUList& addr,
174  const label index,
175  const pointZoneMesh& zm
176  );
177 
178  //- Construct with a new index and zone mesh information, the name
179  //- of the original zone, (move) resetting the point addressing.
180  pointZone
181  (
182  const pointZone& originalZone,
183  labelList&& addr,
184  const label index,
185  const pointZoneMesh& zm
186  );
187 
188 
189  //- Construct and return a clone, resetting the zone mesh
190  virtual autoPtr<pointZone> clone(const pointZoneMesh& zm) const
191  {
192  return autoPtr<pointZone>::New(*this, *this, index(), zm);
193  }
194 
195  //- Construct and return a clone, resetting the point list
196  //- and zone mesh
197  virtual autoPtr<pointZone> clone
198  (
199  const pointZoneMesh& zm,
200  const label index,
201  const labelUList& addr
202  ) const
203  {
204  return autoPtr<pointZone>::New(*this, addr, index, zm);
205  }
206 
207 
208  // Selectors
209 
210  //- Return a pointer to a new point zone
211  // created on freestore from dictionary
212  static autoPtr<pointZone> New
213  (
214  const word& name,
215  const dictionary& dict,
216  const label index,
217  const pointZoneMesh& zm
218  );
219 
220 
221  //- Destructor
222  virtual ~pointZone() = default;
224 
225  // Member Functions
226 
227  //- Return reference to the zone mesh
228  const pointZoneMesh& zoneMesh() const noexcept { return zoneMesh_; }
229 
230  //- The addressing (point IDs) used for the zone
231  const labelList& addressing() const noexcept
232  {
233  return static_cast<const labelList&>(*this);
234  }
235 
236  //- Helper function to re-direct to zone::localID(...)
237  label whichPoint(const label globalPointID) const;
238 
239 
240  //- Check zone definition. Return true if in error.
241  virtual bool checkDefinition(const bool report = false) const;
242 
243  //- Check whether zone is synchronised across coupled boundaries.
244  // \return True if any errors.
245  virtual bool checkParallelSync(const bool report = false) const;
246 
247  //- Correct patch after moving points
248  virtual void movePoints(const pointField&)
249  {}
250 
251  //- Write dictionary
252  virtual void writeDict(Ostream& os) const;
253 
254 
255  // Assign addressing
256 
257  //- Move reset addressing from another zone.
258  virtual void resetAddressing(pointZone&& zn);
259 
260  //- Copy reset addressing from another zone
261  virtual void resetAddressing(const pointZone& zn);
262 
263  //- Copy assign addressing
264  virtual void resetAddressing(const labelUList& addr);
266  //- Move assign addressing
267  virtual void resetAddressing(labelList&& addr);
268 
269  //- Assign addressing, clearing demand-driven data
270  void operator=(const pointZone& zn);
271 
272  //- Assign addressing, clearing demand-driven data
273  void operator=(const labelUList& addr);
274 
275  //- Assign addressing, clearing demand-driven data
276  void operator=(labelList&& addr);
277 
278 
279  // I-O
280 
281  //- Ostream Operator
282  friend Ostream& operator<<(Ostream& os, const pointZone& zn);
283 };
284 
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 } // End namespace Foam
289 
290 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 #endif
293 
294 // ************************************************************************* //
static autoPtr< pointZone > New(const word &name, const dictionary &dict, const label index, const pointZoneMesh &zm)
Return a pointer to a new point zone.
Definition: pointZoneNew.C:28
dictionary dict
void operator=(const pointZone &zn)
Assign addressing, clearing demand-driven data.
Definition: pointZone.C:275
virtual void movePoints(const pointField &)
Correct patch after moving points.
Definition: pointZone.H:291
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
friend Ostream & operator<<(Ostream &os, const pointZone &zn)
Ostream Operator.
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: pointZone.C:162
pointZone(const pointZone &)=delete
No copy construct.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
Base class for mesh zones.
Definition: zone.H:59
virtual ~pointZone()=default
Destructor.
A class for handling words, derived from Foam::string.
Definition: word.H:63
const labelList & addressing() const noexcept
The addressing (point IDs) used for the zone.
Definition: pointZone.H:265
virtual bool checkParallelSync(const bool report=false) const
Check whether zone is synchronised across coupled boundaries.
Definition: pointZone.C:168
label whichPoint(const label globalPointID) const
Helper function to re-direct to zone::localID(...)
Definition: pointZone.C:156
virtual void resetAddressing(pointZone &&zn)
Move reset addressing from another zone.
Definition: pointZone.C:234
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
label index() const noexcept
The index of this zone in the zone list.
TypeName("pointZone")
Runtime type information.
OBJstream os(runTime.globalPath()/outputName)
const pointZoneMesh & zoneMesh() const noexcept
Return reference to the zone mesh.
Definition: pointZone.H:260
declareRunTimeSelectionTable(autoPtr, pointZone, dictionary,(const word &name, const dictionary &dict, const label index, const pointZoneMesh &zm),(name, dict, index, zm))
static const char *const labelsName
The name associated with the zone-labels dictionary entry ("pointLabels")
Definition: pointZone.H:80
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
virtual void writeDict(Ostream &os) const
Write dictionary.
Definition: pointZone.C:222
A subset of mesh points.
Definition: pointZone.H:61
const word & name() const noexcept
The zone name.
autoPtr< List< label > > clone() const
Clone.
Definition: ListI.H:121
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition: autoPtr.H:178
Namespace for OpenFOAM.