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