All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cellZone.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::cellZone
26 
27 Description
28  A subset of mesh cells.
29 
30  Currently set up as an indirect list but will be extended to use a
31  primitive mesh. For quick check whether a cell belongs to the zone use
32  the lookup mechanism in cellZoneMesh, where all the zoned cells are
33  registered with their zone number.
34 
35 SourceFiles
36  cellZone.C
37  cellZoneNew.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef cellZone_H
42 #define cellZone_H
43 
44 #include "zone.H"
45 #include "cellZoneMeshFwd.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward declaration of friend functions and operators
53 
54 class cellZone;
55 Ostream& operator<<(Ostream&, const cellZone&);
56 
57 
58 /*---------------------------------------------------------------------------*\
59  Class cellZone Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class cellZone
63 :
64  public zone
65 {
66 
67 protected:
68 
69  // Protected data
70 
71  //- Reference to zone list
72  const cellZoneMesh& zoneMesh_;
73 
74 
75 public:
76 
77  // Static Data Members
78 
79  //- The name associated with the zone-labels dictionary entry
80  static const char * const labelsName;
81 
82 
83  //- Runtime type information
84  TypeName("cellZone");
85 
86 
87  // Declare run-time constructor selection tables
88 
90  (
91  autoPtr,
92  cellZone,
93  dictionary,
94  (
95  const word& name,
96  const dictionary& dict,
97  const label index,
98  const cellZoneMesh& zm
99  ),
100  (name, dict, index, zm)
101  );
102 
103 
104  // Constructors
105 
106  //- Construct from components
107  cellZone
108  (
109  const word& name,
110  const labelUList& addr,
111  const label index,
112  const cellZoneMesh&
113  );
114 
115  //- Construct from components, transferring contents
116  cellZone
117  (
118  const word& name,
119  labelList&& addr,
120  const label index,
121  const cellZoneMesh&
122  );
123 
124  //- Construct from dictionary
125  cellZone
126  (
127  const word& name,
128  const dictionary&,
129  const label index,
130  const cellZoneMesh&
131  );
132 
133  //- Construct given the original zone and resetting the
134  // cell list and zone mesh information
135  cellZone
136  (
137  const cellZone&,
138  const labelUList& addr,
139  const label index,
140  const cellZoneMesh&
141  );
142 
143  //- Construct given the original zone, resetting the
144  // cell list and zone mesh information
145  cellZone
146  (
147  const cellZone&,
148  labelList&& addr,
149  const label index,
150  const cellZoneMesh&
151  );
152 
153  //- Disallow default bitwise copy construction
154  cellZone(const cellZone&) = delete;
155 
156 
157  //- Construct and return a clone, resetting the zone mesh
158  virtual autoPtr<cellZone> clone(const cellZoneMesh& zm) const
159  {
160  return autoPtr<cellZone>
161  (
162  new cellZone(*this, *this, index(), zm)
163  );
164  }
165 
166  //- Construct and return a clone, resetting the cell list
167  // and zone mesh
169  (
170  const labelUList& addr,
171  const label index,
172  const cellZoneMesh& zm
173  ) const
174  {
175  return autoPtr<cellZone>
176  (
177  new cellZone(*this, addr, index, zm)
178  );
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&,
190  const label index,
191  const cellZoneMesh&
192  );
193 
194 
195  //- Destructor
196  virtual ~cellZone();
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. Return
211  // true if in error.
212  virtual bool checkParallelSync(const bool report = false) const
213  {
214  return false;
215  }
216 
217  //- Write dictionary
218  virtual void writeDict(Ostream&) const;
219 
220 
221  // Member Operators
222 
223  //- Assignment to zone, clearing demand-driven data
224  void operator=(const cellZone&);
225 
226  //- Move assignment to zone, clearing demand-driven data
227  void operator=(cellZone&&);
228 
229  //- Assign addressing, clearing demand-driven data
230  void operator=(const labelUList&);
231 
232  //- Move addressing, clearing demand-driven data
233  void operator=(labelList&&);
234 
235 
236  // I-O
237 
238  //- Ostream Operator
239  friend Ostream& operator<<(Ostream&, const cellZone&);
240 };
241 
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 } // End namespace Foam
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 #endif
250 
251 // ************************************************************************* //
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: cellZone.C:138
label whichCell(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: cellZone.C:120
dictionary dict
TypeName("cellZone")
Runtime type information.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
const cellZoneMesh & zoneMesh() const
Return zoneMesh reference.
Definition: cellZone.C:126
void operator=(const cellZone &)
Assignment to zone, clearing demand-driven data.
Definition: cellZone.C:151
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual ~cellZone()
Destructor.
Definition: cellZone.C:114
cellZone(const word &name, const labelUList &addr, const label index, const cellZoneMesh &)
Construct from components.
Definition: cellZone.C:48
virtual bool checkParallelSync(const bool report=false) const
Check whether zone is synchronised across coupled boundaries. Return.
Definition: cellZone.H:211
friend Ostream & operator<<(Ostream &, const cellZone &)
Ostream Operator.
static autoPtr< cellZone > New(const word &name, const dictionary &, const label index, const cellZoneMesh &)
Return a pointer to a new cell zone.
Definition: cellZoneNew.C:32
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: cellZone.C:132
label index() const
Return the index of this zone in zone list.
Definition: zone.H:158
Base class for zones.
Definition: zone.H:57
A class for handling words, derived from string.
Definition: word.H:59
const word & name() const
Return name.
Definition: zone.H:147
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
declareRunTimeSelectionTable(autoPtr, cellZone, dictionary,(const word &name, const dictionary &dict, const label index, const cellZoneMesh &zm),(name, dict, index, zm))
A subset of mesh cells.
Definition: cellZone.H:61
Ostream & operator<<(Ostream &, const ensightPart &)
autoPtr< List< label > > clone() const
Clone.
Definition: ListI.H:109
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: cellZone.H:79
Namespace for OpenFOAM.
const cellZoneMesh & zoneMesh_
Reference to zone list.
Definition: cellZone.H:71