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-2021 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  // Private Data
68 
69  //- Reference to zone list
70  const cellZoneMesh& zoneMesh_;
71 
72 
73  // Private Member Functions
74 
75  //- No copy construct
76  cellZone(const cellZone&) = delete;
77 
78 
79 public:
80 
81  // Static Data Members
82 
83  //- The name associated with the zone-labels dictionary entry
84  //- ("cellLabels")
85  static const char * const labelsName;
86 
87 
88  //- Runtime type information
89  TypeName("cellZone");
90 
91 
92  // Declare run-time constructor selection tables
93 
95  (
96  autoPtr,
97  cellZone,
98  dictionary,
99  (
100  const word& name,
101  const dictionary& dict,
102  const label index,
103  const cellZoneMesh& zm
104  ),
105  (name, dict, index, zm)
106  );
107 
108 
109  // Constructors
110 
111  //- Construct an empty zone
112  cellZone
113  (
114  const word& name,
115  const label index,
116  const cellZoneMesh& zm
117  );
118 
119  //- Construct from components
120  cellZone
121  (
122  const word& name,
123  const labelUList& addr,
124  const label index,
125  const cellZoneMesh& zm
126  );
127 
128  //- Construct from components, transferring addressing
129  cellZone
130  (
131  const word& name,
132  labelList&& addr,
133  const label index,
134  const cellZoneMesh& zm
135  );
136 
137  //- Construct from dictionary
138  cellZone
139  (
140  const word& name,
141  const dictionary& dict,
142  const label index,
143  const cellZoneMesh& zm
144  );
145 
146  //- Construct given the original zone (name is used),
147  //- and resetting the cell list and zone mesh information
148  cellZone
149  (
150  const cellZone& origZone,
151  const labelUList& addr,
152  const label index,
153  const cellZoneMesh& zm
154  );
155 
156  //- Construct with a new index and zone mesh information, the name
157  //- of the original zone, resetting the cell addressing.
158  cellZone
159  (
160  const cellZone& origZone,
161  labelList&& addr,
162  const label index,
163  const cellZoneMesh& zm
164  );
165 
166 
167  //- Construct and return a clone, resetting the zone mesh
168  virtual autoPtr<cellZone> clone(const cellZoneMesh& zm) const
169  {
170  return autoPtr<cellZone>::New(*this, *this, index(), zm);
171  }
172 
173  //- Construct and return a clone,
174  //- resetting the cell list and zone mesh
176  (
177  const labelUList& addr,
178  const label index,
179  const cellZoneMesh& zm
180  ) const
181  {
182  return autoPtr<cellZone>::New(*this, addr, index, zm);
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& dict,
194  const label index,
195  const cellZoneMesh& zm
196  );
197 
198 
199  //- Destructor
200  virtual ~cellZone() = default;
201 
202 
203  // Member Functions
204 
205  //- Return reference to the zone mesh
206  const cellZoneMesh& zoneMesh() const noexcept
207  {
208  return zoneMesh_;
209  }
210 
211  //- Helper function to re-direct to zone::localID(...)
212  label whichCell(const label globalCellID) const;
213 
214 
215  //- Check zone definition. Return true if in error.
216  virtual bool checkDefinition(const bool report = false) const;
217 
218  //- Check whether zone is synchronised across coupled boundaries.
219  // \return True if any errors.
220  virtual bool checkParallelSync(const bool report = false) const
221  {
222  return false;
223  }
224 
225  //- Write dictionary
226  virtual void writeDict(Ostream& os) const;
227 
228 
229  // Member Operators
230 
231  //- Assign addressing, clearing demand-driven data
232  void operator=(const cellZone& zn);
233 
234  //- Assign addressing, clearing demand-driven data
235  void operator=(const labelUList& addr);
236 
237  //- Move assign addressing, clearing demand-driven data
238  void operator=(labelList&& addr);
239 
240 
241  // I-O
242 
243  //- Ostream Operator
244  friend Ostream& operator<<(Ostream& os, const cellZone& zn);
245 };
246 
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 } // End namespace Foam
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 #endif
255 
256 // ************************************************************************* //
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:67
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:219
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::cellZone::writeDict
virtual void writeDict(Ostream &os) const
Write dictionary.
Definition: cellZone.C:141
Foam::cellZone::zoneMesh
const cellZoneMesh & zoneMesh() const noexcept
Return reference to the zone mesh.
Definition: cellZone.H:205
Foam::cellZone::clone
virtual autoPtr< cellZone > clone(const cellZoneMesh &zm) const
Construct and return a clone, resetting the zone mesh.
Definition: cellZone.H:167
zone.H
Foam::cellZone::labelsName
static const char *const labelsName
Definition: cellZone.H:84
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::operator=
void operator=(const cellZone &zn)
Assign addressing, clearing demand-driven data.
Definition: cellZone.C:155
Foam::cellZone::whichCell
label whichCell(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: cellZone.C:129
Foam::ZoneMesh< cellZone, polyMesh >
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:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::zoneIdentifier::index
label index() const noexcept
The index of this zone in the zone list.
Definition: zoneIdentifier.H:135
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::zoneIdentifier::name
const word & name() const noexcept
The zone name.
Definition: zoneIdentifier.H:123
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:135
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< label >::clone
autoPtr< List< label > > clone() const
Clone.
Definition: ListI.H:100
Foam::labelUList
UList< label > labelUList
A UList of labels.
Definition: UList.H:85
Foam::cellZone::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, cellZone, dictionary,(const word &name, const dictionary &dict, const label index, const cellZoneMesh &zm),(name, dict, index, zm))