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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::cellZone
29
30Description
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
38SourceFiles
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
52namespace Foam
53{
54
55// Forward Declarations
56class cellZone;
57Ostream& operator<<(Ostream& os, const cellZone& zn);
58
59/*---------------------------------------------------------------------------*\
60 Class cellZone Declaration
61\*---------------------------------------------------------------------------*/
63class 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
79public:
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
95 (
96 autoPtr,
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
113 (
114 const word& name,
115 const label index,
116 const cellZoneMesh& zm
117 );
118
119 //- Construct from components
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
130 (
131 const word& name,
132 labelList&& addr,
133 const label index,
134 const cellZoneMesh& zm
135 );
136
137 //- Construct from dictionary
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
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.
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
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// ************************************************************************* //
autoPtr< List< label > > clone() const
Clone.
Definition: ListI.H:100
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A subset of mesh cells.
Definition: cellZone.H:65
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: cellZone.C:135
void operator=(const cellZone &zn)
Assign addressing, clearing demand-driven data.
Definition: cellZone.C:155
static autoPtr< cellZone > New(const word &name, const dictionary &dict, const label index, const cellZoneMesh &zm)
Definition: cellZoneNew.C:35
label whichCell(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: cellZone.C:129
virtual bool checkParallelSync(const bool report=false) const
Check whether zone is synchronised across coupled boundaries.
Definition: cellZone.H:219
declareRunTimeSelectionTable(autoPtr, cellZone, dictionary,(const word &name, const dictionary &dict, const label index, const cellZoneMesh &zm),(name, dict, index, zm))
virtual autoPtr< cellZone > clone(const labelUList &addr, const label index, const cellZoneMesh &zm) const
Definition: cellZone.H:175
virtual autoPtr< cellZone > clone(const cellZoneMesh &zm) const
Construct and return a clone, resetting the zone mesh.
Definition: cellZone.H:167
static const char *const labelsName
Definition: cellZone.H:84
friend Ostream & operator<<(Ostream &os, const cellZone &zn)
Ostream Operator.
const cellZoneMesh & zoneMesh() const noexcept
Return reference to the zone mesh.
Definition: cellZone.H:205
virtual void writeDict(Ostream &os) const
Write dictionary.
Definition: cellZone.C:141
TypeName("cellZone")
Runtime type information.
virtual ~cellZone()=default
Destructor.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling words, derived from Foam::string.
Definition: word.H:68
label index() const noexcept
The index of this zone in the zone list.
const word & name() const noexcept
The zone name.
Base class for mesh zones.
Definition: zone.H:67
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: List.H:66
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
const direction noexcept
Definition: Scalar.H:223
UList< label > labelUList
A UList of labels.
Definition: UList.H:85
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73