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-2021 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 pointZone_H
47 #define 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 
76  // Private Member Functions
77 
78  //- No copy construct
79  pointZone(const pointZone&) = delete;
80 
81 
82 public:
83 
84  // Static Data Members
85 
86  //- The name associated with the zone-labels dictionary entry
87  //- ("pointLabels")
88  static const char * const labelsName;
89 
90 
91  //- Runtime type information
92  TypeName("pointZone");
93 
94 
95  // Declare run-time constructor selection tables
96 
98  (
99  autoPtr,
100  pointZone,
101  dictionary,
102  (
103  const word& name,
104  const dictionary& dict,
105  const label index,
106  const pointZoneMesh& zm
107  ),
108  (name, dict, index, zm)
109  );
110 
111 
112  // Constructors
113 
114  //- Construct an empty zone
115  pointZone
116  (
117  const word& name,
118  const label index,
119  const pointZoneMesh& zm
120  );
121 
122  //- Construct from components
123  pointZone
124  (
125  const word& name,
126  const labelUList& addr,
127  const label index,
128  const pointZoneMesh& zm
129  );
130 
131  //- Construct from components, transferring addressing
132  pointZone
133  (
134  const word& name,
135  labelList&& addr,
136  const label index,
137  const pointZoneMesh& zm
138  );
139 
140  //- Construct from dictionary
141  pointZone
142  (
143  const word& name,
144  const dictionary& dict,
145  const label index,
146  const pointZoneMesh& zm
147  );
148 
149  //- Construct with a new index and zone mesh information, the name
150  //- of the original zone, resetting the point addressing.
151  pointZone
152  (
153  const pointZone& origZone,
154  const labelUList& addr,
155  const label index,
156  const pointZoneMesh& zm
157  );
158 
159  //- Construct with a new index and zone mesh information, the name
160  //- of the original zone, (move) resetting the point addressing.
161  pointZone
162  (
163  const pointZone& origZone,
164  labelList&& addr,
165  const label index,
166  const pointZoneMesh& zm
167  );
168 
169 
170  //- Construct and return a clone, resetting the zone mesh
171  virtual autoPtr<pointZone> clone(const pointZoneMesh& zm) const
172  {
173  return autoPtr<pointZone>::New(*this, *this, index(), zm);
174  }
175 
176  //- Construct and return a clone, resetting the point list
177  //- and zone mesh
179  (
180  const pointZoneMesh& zm,
181  const label index,
182  const labelUList& addr
183  ) const
184  {
185  return autoPtr<pointZone>::New(*this, addr, index, zm);
186  }
187 
188 
189  // Selectors
190 
191  //- Return a pointer to a new point zone
192  // created on freestore from dictionary
193  static autoPtr<pointZone> New
194  (
195  const word& name,
196  const dictionary& dict,
197  const label index,
198  const pointZoneMesh& zm
199  );
200 
201 
202  //- Destructor
203  virtual ~pointZone() = default;
204 
205 
206  // Member Functions
207 
208  //- Return reference to the zone mesh
209  const pointZoneMesh& zoneMesh() const noexcept
210  {
211  return zoneMesh_;
212  }
213 
214  //- Helper function to re-direct to zone::localID(...)
215  label whichPoint(const label globalPointID) const;
216 
217 
218  //- Check zone definition. Return true if in error.
219  virtual bool checkDefinition(const bool report = false) const;
220 
221  //- Check whether zone is synchronised across coupled boundaries.
222  // \return True if any errors.
223  virtual bool checkParallelSync(const bool report = false) const;
224 
225  //- Correct patch after moving points
226  virtual void movePoints(const pointField&)
227  {}
228 
229  //- Write dictionary
230  virtual void writeDict(Ostream& os) const;
231 
232 
233  // Member Operators
234 
235  //- Assign addressing, clearing demand-driven data
236  void operator=(const pointZone& zn);
237 
238  //- Assign addressing, clearing demand-driven data
239  void operator=(const labelUList& addr);
240 
241  //- Assign addressing, clearing demand-driven data
242  void operator=(labelList&& addr);
243 
244 
245  // I-O
246 
247  //- Ostream Operator
248  friend Ostream& operator<<(Ostream& os, const pointZone& zn);
249 };
250 
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 } // End namespace Foam
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 #endif
259 
260 // ************************************************************************* //
Foam::autoPtr::New
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
zone.H
Foam::pointZone::clone
virtual autoPtr< pointZone > clone(const pointZoneMesh &zm) const
Construct and return a clone, resetting the zone mesh.
Definition: pointZone.H:170
Foam::pointZone
A subset of mesh points.
Definition: pointZone.H:65
Foam::zone
Base class for mesh zones.
Definition: zone.H:63
Foam::pointZone::operator=
void operator=(const pointZone &zn)
Assign addressing, clearing demand-driven data.
Definition: pointZone.C:209
Foam::pointZone::checkParallelSync
virtual bool checkParallelSync(const bool report=false) const
Check whether zone is synchronised across coupled boundaries.
Definition: pointZone.C:141
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::Field< vector >
Foam::pointZone::zoneMesh
const pointZoneMesh & zoneMesh() const noexcept
Return reference to the zone mesh.
Definition: pointZone.H:208
Foam::ZoneMesh< pointZone, polyMesh >
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::zoneIdentifier::index
label index() const noexcept
The index of this zone in the zone list.
Definition: zoneIdentifier.H:135
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::pointZone::whichPoint
label whichPoint(const label globalPointID) const
Helper function to re-direct to zone::localID(...)
Definition: pointZone.C:129
Foam::pointZone::~pointZone
virtual ~pointZone()=default
Destructor.
Foam::zoneIdentifier::name
const word & name() const noexcept
The zone name.
Definition: zoneIdentifier.H:123
Foam::List< label >
Foam::UList< label >
Foam::pointZone::New
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:35
Foam::pointZone::labelsName
static const char *const labelsName
Definition: pointZone.H:87
Foam::pointZone::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, pointZone, dictionary,(const word &name, const dictionary &dict, const label index, const pointZoneMesh &zm),(name, dict, index, zm))
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::List< label >::clone
autoPtr< List< label > > clone() const
Clone.
Definition: ListI.H:100
Foam::pointZone::movePoints
virtual void movePoints(const pointField &)
Correct patch after moving points.
Definition: pointZone.H:225
Foam::pointZone::TypeName
TypeName("pointZone")
Runtime type information.
pointZoneMeshFwd.H
Foam::pointZone::checkDefinition
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: pointZone.C:135
Foam::pointZone::writeDict
virtual void writeDict(Ostream &os) const
Write dictionary.
Definition: pointZone.C:195
Foam::pointZone::operator<<
friend Ostream & operator<<(Ostream &os, const pointZone &zn)
Ostream Operator.