faceZone.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::faceZone
29
30Description
31 A subset of mesh faces organised as a primitive patch.
32
33 For quick check whether a face belongs to the zone use the lookup
34 mechanism in faceZoneMesh, where all the zoned faces are registered
35 with their zone number.
36
37SourceFiles
38 faceZone.C
39 faceZoneNew.C
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef Foam_faceZone_H
44#define Foam_faceZone_H
45
46#include "zone.H"
47#include "faceZoneMeshFwd.H"
48#include "primitivePatch.H"
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52namespace Foam
53{
54
55// Forward Declarations
56class mapPolyMesh;
57class faceZone;
58Ostream& operator<<(Ostream& os, const faceZone& zn);
59
60
61/*---------------------------------------------------------------------------*\
62 Class faceZone Declaration
63\*---------------------------------------------------------------------------*/
65class faceZone
66:
67 public zone
68{
69 // Private Data
70
71 //- Flip map for all faces in the zone.
72 // True if the face needs flipping for the correct orientation.
73 boolList flipMap_;
74
75 //- Reference to zone list
76 const faceZoneMesh& zoneMesh_;
77
78 //- Demand-driven: Primitive patch of correctly flipped faces
79 mutable primitiveFacePatch* patchPtr_;
80
81 //- Demand-driven: Master cell layer
82 mutable labelList* masterCellsPtr_;
83
84 //- Demand-driven: Slave cell layer
85 mutable labelList* slaveCellsPtr_;
86
87 //- Demand-driven: Global edge addressing
88 mutable labelList* mePtr_;
89
90
91 // Private Member Functions
92
93 //- Set flip-map to uniform value
94 void setFlipMap(const bool val);
95
96 //- Build primitive patch
97 void calcFaceZonePatch() const;
98
99 //- Calculate master and slave face layer
100 void calcCellLayers() const;
101
102 //- Check addressing
103 void checkAddressing() const;
104
105
106 //- No copy construct
107 faceZone(const faceZone&) = delete;
108
109 //- No copy assignment
110 void operator=(const faceZone&) = delete;
111
112
113public:
114
115 // Static Data Members
116
117 //- The name associated with the zone-labels dictionary entry
118 //- ("faceLabels")
119 static const char * const labelsName;
120
121
122 //- Runtime type information
123 TypeName("faceZone");
124
125
126 // Declare run-time constructor selection tables
129 (
130 autoPtr,
131 faceZone,
133 (
134 const word& name,
135 const dictionary& dict,
136 const label index,
137 const faceZoneMesh& zm
138 ),
139 (name, dict, index, zm)
140 );
141
142
143 // Constructors
144
145 //- Construct an empty zone
147 (
148 const word& name,
149 const label index,
150 const faceZoneMesh& zm
151 );
152
153 //- Construct from components with uniform flip map value
155 (
156 const word& name,
157 const labelUList& addr,
158 const bool flipMapValue,
159 const label index,
160 const faceZoneMesh& zm
161 );
162
163 //- Construct from components with uniform flip map value,
164 //- transferring addressing.
166 (
167 const word& name,
168 labelList&& addr,
169 const bool flipMapValue,
170 const label index,
171 const faceZoneMesh& zm
172 );
173
174 //- Construct from components
176 (
177 const word& name,
178 const labelUList& addr,
179 const boolUList& fm,
180 const label index,
181 const faceZoneMesh& zm
182 );
183
184 //- Construct from components, transferring addressing
186 (
187 const word& name,
188 labelList&& addr,
189 boolList&& fm,
190 const label index,
191 const faceZoneMesh& zm
192 );
193
194 //- Construct from dictionary
196 (
197 const word& name,
198 const dictionary& dict,
199 const label index,
200 const faceZoneMesh& zm
201 );
202
203 //- Construct with a new index and zone mesh information, the name
204 //- of the original zone, resetting the face addressing
205 //- and flip-map.
207 (
208 const faceZone& origZone,
209 const labelUList& addr,
210 const boolUList& fm,
211 const label index,
212 const faceZoneMesh& zm
213 );
214
215 //- Construct with a new index and zone mesh information, the name
216 //- of the original zone, (move) resetting the face addressing
217 //- and flip-map.
219 (
220 const faceZone& origZone,
221 labelList&& addr,
222 boolList&& fm,
223 const label index,
224 const faceZoneMesh& zm
225 );
226
227 //- Construct and return a clone, resetting the zone mesh
228 virtual autoPtr<faceZone> clone(const faceZoneMesh& zm) const
229 {
230 return autoPtr<faceZone>::New(*this, *this, flipMap(), index(), zm);
231 }
232
233 //- Construct and return a clone,
234 //- resetting the face list and zone mesh
236 (
237 const labelUList& addr,
238 const boolUList& fm,
239 const label index,
240 const faceZoneMesh& zm
241 ) const
242 {
243 return autoPtr<faceZone>::New(*this, addr, fm, index, zm);
244 }
245
246
247 // Selectors
248
249 //- Return a pointer to a new face zone
250 //- created on freestore from dictionary
252 (
253 const word& name,
254 const dictionary& dict,
255 const label index,
256 const faceZoneMesh& zm
257 );
258
259
260 //- Destructor
261 virtual ~faceZone();
262
263
264 // Member Functions
265
266 //- Return reference to the zone mesh
267 const faceZoneMesh& zoneMesh() const noexcept
268 {
269 return zoneMesh_;
270 }
271
272 //- Return face flip map
273 const boolList& flipMap() const noexcept
274 {
275 return flipMap_;
276 }
277
278 //- Helper function to re-direct to zone::localID(...)
279 label whichFace(const label globalCellID) const;
280
281 //- Return reference to primitive patch
282 const primitiveFacePatch& operator()() const;
283
284
285 // Addressing into mesh
286
287 //- Return labels of master cells (cells next to the master face
288 //- zone in the prescribed direction)
289 const labelList& masterCells() const;
290
291 //- Return labels of slave cells
292 const labelList& slaveCells() const;
293
294 //- Return global edge index for local edges
295 const labelList& meshEdges() const;
296
297
298 //- Clear addressing
299 virtual void clearAddressing();
300
301 //- Reset addressing - use uniform flip map value
302 // Clears demand-driven data.
303 virtual void resetAddressing
304 (
305 const labelUList& addr,
306 const bool flipMapValue
307 );
308
309 //- Reset addressing and flip map.
310 // Clears demand-driven data.
311 virtual void resetAddressing
312 (
313 const labelUList& addr,
314 const boolUList& flipMap
315 );
316
317 //- Move reset addressing - use uniform flip map value
318 // Clears demand-driven data.
319 virtual void resetAddressing
320 (
321 labelList&& addr,
322 const bool flipMapValue
323 );
324
325
326 //- Check zone definition. Return true if in error.
327 virtual bool checkDefinition(const bool report = false) const;
328
329 //- Check whether all procs have faces synchronised.
330 // \return True if any errors.
331 virtual bool checkParallelSync(const bool report = false) const;
332
333 //- Correct patch after moving points
334 virtual void movePoints(const pointField& pts);
335
336 //- Update for changes in topology
337 virtual void updateMesh(const mapPolyMesh& mpm);
338
339 //- Write
340 virtual void write(Ostream& os) const;
341
342 //- Write dictionary
343 virtual void writeDict(Ostream& os) const;
344
345
346 // I-O
347
348 //- Ostream Operator
349 friend Ostream& operator<<(Ostream& os, const faceZone& zn);
350};
351
352
353// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
354
355} // End namespace Foam
356
357// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
358
359#endif
360
361// ************************************************************************* //
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
A list of faces which address into the list of points.
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 list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:67
virtual bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: faceZone.C:510
virtual void resetAddressing(const labelUList &addr, const bool flipMapValue)
Reset addressing - use uniform flip map value.
Definition: faceZone.C:444
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
Definition: faceZone.C:372
const labelList & masterCells() const
Definition: faceZone.C:389
const boolList & flipMap() const noexcept
Return face flip map.
Definition: faceZone.H:272
const primitiveFacePatch & operator()() const
Return reference to primitive patch.
Definition: faceZone.C:378
virtual autoPtr< faceZone > clone(const labelUList &addr, const boolUList &fm, const label index, const faceZoneMesh &zm) const
Definition: faceZone.H:235
static const char *const labelsName
Definition: faceZone.H:118
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes in topology.
Definition: faceZone.C:479
virtual void clearAddressing()
Clear addressing.
Definition: faceZone.C:430
declareRunTimeSelectionTable(autoPtr, faceZone, dictionary,(const word &name, const dictionary &dict, const label index, const faceZoneMesh &zm),(name, dict, index, zm))
virtual ~faceZone()
Destructor.
Definition: faceZone.C:364
static autoPtr< faceZone > New(const word &name, const dictionary &dict, const label index, const faceZoneMesh &zm)
Definition: faceZoneNew.C:35
virtual void writeDict(Ostream &os) const
Write dictionary.
Definition: faceZone.C:624
virtual autoPtr< faceZone > clone(const faceZoneMesh &zm) const
Construct and return a clone, resetting the zone mesh.
Definition: faceZone.H:227
virtual void movePoints(const pointField &pts)
Correct patch after moving points.
Definition: faceZone.C:608
friend Ostream & operator<<(Ostream &os, const faceZone &zn)
Ostream Operator.
const faceZoneMesh & zoneMesh() const noexcept
Return reference to the zone mesh.
Definition: faceZone.H:266
virtual bool checkParallelSync(const bool report=false) const
Check whether all procs have faces synchronised.
Definition: faceZone.C:516
TypeName("faceZone")
Runtime type information.
const labelList & slaveCells() const
Return labels of slave cells.
Definition: faceZone.C:400
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: faceZone.C:411
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
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.
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
runTime write()
#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