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 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 Member Functions
76 
77  //- Disallow default bitwise copy construct
78  cellZone(const cellZone&);
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 from components
113  cellZone
114  (
115  const word& name,
116  const labelUList& addr,
117  const label index,
118  const cellZoneMesh&
119  );
120 
121  //- Construct from components, transferring contents
122  cellZone
123  (
124  const word& name,
125  const Xfer<labelList>& addr,
126  const label index,
127  const cellZoneMesh&
128  );
129 
130  //- Construct from dictionary
131  cellZone
132  (
133  const word& name,
134  const dictionary&,
135  const label index,
136  const cellZoneMesh&
137  );
138 
139  //- Construct given the original zone and resetting the
140  // cell list and zone mesh information
141  cellZone
142  (
143  const cellZone&,
144  const labelUList& addr,
145  const label index,
146  const cellZoneMesh&
147  );
148 
149  //- Construct given the original zone, resetting the
150  // cell list and zone mesh information
151  cellZone
152  (
153  const cellZone&,
154  const Xfer<labelList>& addr,
155  const label index,
156  const cellZoneMesh&
157  );
158 
159  //- Construct and return a clone, resetting the zone mesh
160  virtual autoPtr<cellZone> clone(const cellZoneMesh& zm) const
161  {
162  return autoPtr<cellZone>
163  (
164  new cellZone(*this, *this, index(), zm)
165  );
166  }
167 
168  //- Construct and return a clone, resetting the cell list
169  // and zone mesh
171  (
172  const labelUList& addr,
173  const label index,
174  const cellZoneMesh& zm
175  ) const
176  {
177  return autoPtr<cellZone>
178  (
179  new cellZone(*this, addr, index, zm)
180  );
181  }
182 
183 
184  // Selectors
185 
186  //- Return a pointer to a new cell zone
187  // created on freestore from dictionary
188  static autoPtr<cellZone> New
189  (
190  const word& name,
191  const dictionary&,
192  const label index,
193  const cellZoneMesh&
194  );
195 
196 
197  //- Destructor
198  virtual ~cellZone();
199 
200 
201  // Member Functions
202 
203  //- Helper function to re-direct to zone::localID(...)
204  label whichCell(const label globalCellID) const;
205 
206  //- Return zoneMesh reference
207  const cellZoneMesh& zoneMesh() const;
208 
209  //- Check zone definition. Return true if in error.
210  virtual bool checkDefinition(const bool report = false) const;
211 
212  //- Check whether zone is synchronised across coupled boundaries. Return
213  // true if in error.
214  virtual bool checkParallelSync(const bool report = false) const
215  {
216  return false;
217  }
218 
219  //- Write dictionary
220  virtual void writeDict(Ostream&) const;
221 
222 
223  // Member Operators
224 
225  //- Assign to zone, clearing demand-driven data
226  void operator=(const cellZone&);
227 
228  //- Assign addressing, clearing demand-driven data
229  void operator=(const labelUList&);
230 
231  //- Assign addressing, clearing demand-driven data
232  void operator=(const Xfer<labelList>&);
233 
234 
235  // I-O
236 
237  //- Ostream Operator
238  friend Ostream& operator<<(Ostream&, const cellZone&);
239 };
240 
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 } // End namespace Foam
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 #endif
249 
250 // ************************************************************************* //
Foam::cellZone::checkParallelSync
virtual bool checkParallelSync(const bool report=false) const
Check whether zone is synchronised across coupled boundaries. Return.
Definition: cellZone.H:213
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::cellZone::clone
virtual autoPtr< cellZone > clone(const cellZoneMesh &zm) const
Construct and return a clone, resetting the zone mesh.
Definition: cellZone.H:159
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 zones.
Definition: zone.H:57
Foam::Xfer
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
Foam::cellZone::operator=
void operator=(const cellZone &)
Assign to zone, clearing demand-driven data.
Definition: cellZone.C:150
Foam::cellZone
A subset of mesh cells.
Definition: cellZone.H:61
Foam::cellZone::operator<<
friend Ostream & operator<<(Ostream &, const cellZone &)
Ostream Operator.
Foam::cellZone::TypeName
TypeName("cellZone")
Runtime type information.
Foam::cellZone::zoneMesh
const cellZoneMesh & zoneMesh() const
Return zoneMesh reference.
Definition: cellZone.C:125
Foam::label
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
Foam::cellZone::~cellZone
virtual ~cellZone()
Destructor.
Definition: cellZone.C:113
Foam::cellZone::cellZone
cellZone(const cellZone &)
Disallow default bitwise copy construct.
Foam::cellZone::whichCell
label whichCell(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: cellZone.C:119
Foam::ZoneMesh< cellZone, polyMesh >
Foam::cellZone::zoneMesh_
const cellZoneMesh & zoneMesh_
Reference to zone list.
Definition: cellZone.H:71
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::cellZone::New
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
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::zone::name
const word & name() const
Return name.
Definition: zone.H:150
Foam::cellZone::writeDict
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: cellZone.C:137
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::UList
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
Foam::cellZone::checkDefinition
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: cellZone.C:131
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
cellZoneMeshFwd.H
Foam::List::clone
autoPtr< List< T > > clone() const
Clone.
Definition: ListI.H:34
Foam::labelUList
UList< label > labelUList
Definition: UList.H:63
Foam::zone::index
label index() const
Return the index of this zone in zone list.
Definition: zone.H:161
Foam::cellZone::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, cellZone, dictionary,(const word &name, const dictionary &dict, const label index, const cellZoneMesh &zm),(name, dict, index, zm))