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 | Copyright (C) 2011-2016 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 private:
76 
77  // Private Member Functions
78 
79  //- Disallow default bitwise copy construct
80  cellZone(const cellZone&);
81 
82 
83 public:
84 
85  // Static data members
86 
87  //- The name associated with the zone-labels dictionary entry
88  static const char * const labelsName;
89 
90 
91  //- Runtime type information
92  TypeName("cellZone");
93 
94 
95  // Declare run-time constructor selection tables
96 
98  (
99  autoPtr,
100  cellZone,
101  dictionary,
102  (
103  const word& name,
104  const dictionary& dict,
105  const label index,
106  const cellZoneMesh& zm
107  ),
108  (name, dict, index, zm)
109  );
110 
111 
112  // Constructors
113 
114  //- Construct from components
115  cellZone
116  (
117  const word& name,
118  const labelUList& addr,
119  const label index,
120  const cellZoneMesh&
121  );
122 
123  //- Construct from components, transferring contents
124  cellZone
125  (
126  const word& name,
127  const Xfer<labelList>& addr,
128  const label index,
129  const cellZoneMesh&
130  );
131 
132  //- Construct from dictionary
133  cellZone
134  (
135  const word& name,
136  const dictionary&,
137  const label index,
138  const cellZoneMesh&
139  );
140 
141  //- Construct given the original zone and resetting the
142  // cell list and zone mesh information
143  cellZone
144  (
145  const cellZone&,
146  const labelUList& addr,
147  const label index,
148  const cellZoneMesh&
149  );
150 
151  //- Construct given the original zone, resetting the
152  // cell list and zone mesh information
153  cellZone
154  (
155  const cellZone&,
156  const Xfer<labelList>& addr,
157  const label index,
158  const cellZoneMesh&
159  );
160 
161  //- Construct and return a clone, resetting the zone mesh
162  virtual autoPtr<cellZone> clone(const cellZoneMesh& zm) const
163  {
164  return autoPtr<cellZone>
165  (
166  new cellZone(*this, *this, index(), zm)
167  );
168  }
169 
170  //- Construct and return a clone, resetting the cell list
171  // and zone mesh
173  (
174  const labelUList& addr,
175  const label index,
176  const cellZoneMesh& zm
177  ) const
178  {
179  return autoPtr<cellZone>
180  (
181  new cellZone(*this, addr, index, zm)
182  );
183  }
184 
185 
186  // Selectors
187 
188  //- Return a pointer to a new cell zone
189  // created on freestore from dictionary
190  static autoPtr<cellZone> New
191  (
192  const word& name,
193  const dictionary&,
194  const label index,
195  const cellZoneMesh&
196  );
197 
198 
199  //- Destructor
200  virtual ~cellZone();
201 
202 
203  // Member Functions
204 
205  //- Helper function to re-direct to zone::localID(...)
206  label whichCell(const label globalCellID) const;
207 
208  //- Return zoneMesh reference
209  const cellZoneMesh& zoneMesh() const;
210 
211  //- Check zone definition. Return true if in error.
212  virtual bool checkDefinition(const bool report = false) const;
213 
214  //- Check whether zone is synchronised across coupled boundaries. Return
215  // true if in error.
216  virtual bool checkParallelSync(const bool report = false) const
217  {
218  return false;
219  }
220 
221  //- Write dictionary
222  virtual void writeDict(Ostream&) const;
223 
224 
225  // Member Operators
226 
227  //- Assign to zone, clearing demand-driven data
228  void operator=(const cellZone&);
229 
230  //- Assign addressing, clearing demand-driven data
231  void operator=(const labelUList&);
232 
233  //- Assign addressing, clearing demand-driven data
234  void operator=(const Xfer<labelList>&);
235 
236 
237  // I-O
238 
239  //- Ostream Operator
240  friend Ostream& operator<<(Ostream&, const cellZone&);
241 };
242 
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 } // End namespace Foam
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 #endif
251 
252 // ************************************************************************* //
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
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:125
void operator=(const cellZone &)
Assign to zone, clearing demand-driven data.
Definition: cellZone.C:150
label index() const
Return the index of this zone in zone list.
Definition: zone.H:161
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual ~cellZone()
Destructor.
Definition: cellZone.C:113
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
label whichCell(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: cellZone.C:119
const word & name() const
Return name.
Definition: zone.H:150
Base class for zones.
Definition: zone.H:57
A class for handling words, derived from string.
Definition: word.H:59
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: cellZone.C:131
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:53
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
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: cellZone.C:137
Ostream & operator<<(Ostream &, const ensightPart &)
virtual bool checkParallelSync(const bool report=false) const
Check whether zone is synchronised across coupled boundaries. Return.
Definition: cellZone.H:215
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: cellZone.H:87
autoPtr< List< label > > clone() const
Clone.
Namespace for OpenFOAM.
const cellZoneMesh & zoneMesh_
Reference to zone list.
Definition: cellZone.H:71