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-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::cellZone
29 
30 Description
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 
38 SourceFiles
39  cellZone.C
40  cellZoneNew.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef cellZone_H
45 #define cellZone_H
46 
47 #include "zone.H"
48 #include "cellZoneMeshFwd.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declarations
56 class cellZone;
57 Ostream& operator<<(Ostream& os, const cellZone& zn);
58 
59 /*---------------------------------------------------------------------------*\
60  Class cellZone Declaration
61 \*---------------------------------------------------------------------------*/
62 
63 class cellZone
64 :
65  public zone
66 {
67 protected:
68 
69  // Protected data
70 
71  //- Reference to zone list
72  const cellZoneMesh& zoneMesh_;
73 
74 
75  // Protected Member Functions
76 
77  //- No copy construct
78  cellZone(const cellZone&) = delete;
79 
80 
81 public:
82 
83  // Static Data Members
84 
85  //- The name associated with the zone-labels dictionary entry
86  static const char * const labelsName;
87 
88 
89  //- Runtime type information
90  TypeName("cellZone");
91 
92 
93  // Declare run-time constructor selection tables
94 
96  (
97  autoPtr,
98  cellZone,
99  dictionary,
100  (
101  const word& name,
102  const dictionary& dict,
103  const label index,
104  const cellZoneMesh& zm
105  ),
106  (name, dict, index, zm)
107  );
108 
109 
110  // Constructors
111 
112  //- Construct an empty zone
113  cellZone(const word& name, const label index, const cellZoneMesh& zm);
114 
115  //- Construct from components
116  cellZone
117  (
118  const word& name,
119  const labelUList& addr,
120  const label index,
121  const cellZoneMesh& zm
122  );
123 
124  //- Construct from components, transferring addressing
125  cellZone
126  (
127  const word& name,
128  labelList&& addr,
129  const label index,
130  const cellZoneMesh& zm
131  );
132 
133  //- Construct from dictionary
134  cellZone
135  (
136  const word& name,
137  const dictionary& dict,
138  const label index,
139  const cellZoneMesh& zm
140  );
141 
142  //- Construct given the original zone (name is used),
143  //- and resetting the cell list and zone mesh information
144  cellZone
145  (
146  const cellZone& origZone,
147  const labelUList& addr,
148  const label index,
149  const cellZoneMesh& zm
150  );
151 
152  //- Construct with a new index and zone mesh information, the name
153  //- of the original zone, resetting the cell addressing.
154  cellZone
155  (
156  const cellZone& origZone,
157  labelList&& addr,
158  const label index,
159  const cellZoneMesh& zm
160  );
161 
162 
163  //- Construct and return a clone, resetting the zone mesh
164  virtual autoPtr<cellZone> clone(const cellZoneMesh& zm) const
165  {
166  return autoPtr<cellZone>::New(*this, *this, index(), zm);
167  }
168 
169  //- Construct and return a clone,
170  //- resetting the cell list and zone mesh
172  (
173  const labelUList& addr,
174  const label index,
175  const cellZoneMesh& zm
176  ) const
177  {
178  return autoPtr<cellZone>::New(*this, addr, index, zm);
179  }
180 
181 
182  // Selectors
183 
184  //- Return a pointer to a new cell zone
185  //- created on freestore from dictionary
186  static autoPtr<cellZone> New
187  (
188  const word& name,
189  const dictionary& dict,
190  const label index,
191  const cellZoneMesh& zm
192  );
193 
194 
195  //- Destructor
196  virtual ~cellZone() = default;
197 
198 
199  // Member Functions
200 
201  //- Helper function to re-direct to zone::localID(...)
202  label whichCell(const label globalCellID) const;
203 
204  //- Return zoneMesh reference
205  const cellZoneMesh& zoneMesh() const;
206 
207  //- Check zone definition. Return true if in error.
208  virtual bool checkDefinition(const bool report = false) const;
209 
210  //- Check whether zone is synchronised across coupled boundaries.
211  // \return True if any errors.
212  virtual bool checkParallelSync(const bool report = false) const
213  {
214  return false;
215  }
216 
217  //- Write dictionary
218  virtual void writeDict(Ostream& os) const;
219 
220 
221  // Member Operators
222 
223  //- Assign to zone, clearing demand-driven data
224  void operator=(const cellZone& zn);
225 
226  //- Assign addressing, clearing demand-driven data
227  void operator=(const labelUList& addr);
228 
229  //- Move assign addressing, clearing demand-driven data
230  void operator=(labelList&& addr);
231 
232 
233  // I-O
234 
235  //- Ostream Operator
236  friend Ostream& operator<<(Ostream& os, const cellZone& zn);
237 };
238 
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 } // End namespace Foam
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 #endif
247 
248 // ************************************************************************* //
Foam::autoPtr::New
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
Foam::cellZone::New
static autoPtr< cellZone > New(const word &name, const dictionary &dict, const label index, const cellZoneMesh &zm)
Definition: cellZoneNew.C:35
Foam::cellZone::checkParallelSync
virtual bool checkParallelSync(const bool report=false) const
Check whether zone is synchronised across coupled boundaries.
Definition: cellZone.H:211
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::cellZone::writeDict
virtual void writeDict(Ostream &os) const
Write dictionary.
Definition: cellZone.C:148
Foam::cellZone::cellZone
cellZone(const cellZone &)=delete
No copy construct.
Foam::cellZone::clone
virtual autoPtr< cellZone > clone(const cellZoneMesh &zm) const
Construct and return a clone, resetting the zone mesh.
Definition: cellZone.H:163
zone.H
Foam::cellZone::labelsName
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: cellZone.H:85
Foam::zone
Base class for mesh zones.
Definition: zone.H:63
Foam::cellZone::operator<<
friend Ostream & operator<<(Ostream &os, const cellZone &zn)
Ostream Operator.
Foam::cellZone
A subset of mesh cells.
Definition: cellZone.H:62
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::cellZone::TypeName
TypeName("cellZone")
Runtime type information.
Foam::cellZone::zoneMesh
const cellZoneMesh & zoneMesh() const
Return zoneMesh reference.
Definition: cellZone.C:136
Foam::cellZone::operator=
void operator=(const cellZone &zn)
Assign to zone, clearing demand-driven data.
Definition: cellZone.C:161
Foam::cellZone::whichCell
label whichCell(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: cellZone.C:130
Foam::ZoneMesh< cellZone, polyMesh >
Foam::cellZone::zoneMesh_
const cellZoneMesh & zoneMesh_
Reference to zone list.
Definition: cellZone.H:71
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::cellZone::~cellZone
virtual ~cellZone()=default
Destructor.
Foam::List< label >
Foam::UList< label >
Foam::cellZone::checkDefinition
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: cellZone.C:142
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
cellZoneMeshFwd.H
Foam::List::clone
autoPtr< List< T > > clone() const
Clone.
Definition: ListI.H:99
Foam::labelUList
UList< label > labelUList
A UList of labels.
Definition: UList.H:80
Foam::zone::index
label index() const
Return the index of this zone in zone list.
Definition: zone.H:169
Foam::cellZone::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, cellZone, dictionary,(const word &name, const dictionary &dict, const label index, const cellZoneMesh &zm),(name, dict, index, zm))