Loading...
Searching...
No Matches
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-2025 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;
59
61/*---------------------------------------------------------------------------*\
62 Class faceZone Declaration
63\*---------------------------------------------------------------------------*/
64
65class faceZone
66:
67 public zone
68{
69 // // Public Data Types
70 //
71 // //- Side of the face zone
72 // enum side
73 // {
74 // FRONT = 1, //!< The front (positive normal) side of the face
75 // BACK = -1, //!< The back (negative normal) side of the face
76 // };
77
78
79 // Private Data
80
81 //- Reference to zone list
82 const faceZoneMesh& zoneMesh_;
83
84 //- Flip map for all faces in the zone.
85 // True if the face needs flipping for the correct orientation.
86 boolList flipMap_;
87
88 //- Demand-driven: Primitive patch of correctly flipped faces
89 mutable std::unique_ptr<primitiveFacePatch> patchPtr_;
90
91 //- Demand-driven: front cell layer (positive normal) side of faces
92 mutable std::unique_ptr<labelList> frontCellsPtr_;
93
94 //- Demand-driven: back cell layer (negative normal) side of faces
95 mutable std::unique_ptr<labelList> backCellsPtr_;
96
97 //- Demand-driven: Global edge addressing
98 mutable std::unique_ptr<labelList> mePtr_;
99
100
101 // Private Member Functions
102
103 //- Set flip-map to uniform value
104 void setFlipMap(const bool val);
105
106 //- Build primitive patch
107 void calcFaceZonePatch() const;
108
109 //- Calculate front/back cell layers
110 void calcCellLayers() const;
111
112 //- Check addressing
113 void checkAddressing() const;
114
115 //- Clear out geometry and demand-driven data
116 void clearGeom();
117
118public:
119
120 // Static Data Members
121
122 //- The name associated with the zone-labels dictionary entry
123 static constexpr const char* labelsName() { return "faceLabels"; }
124
125
126 //- Runtime type information
127 TypeName("faceZone");
128
129
130 // Declare run-time constructor selection tables
131
133 (
134 autoPtr,
135 faceZone,
137 (
138 const word& name,
139 const dictionary& dict,
140 const label index,
141 const faceZoneMesh& zm
142 ),
144 );
145
146
147 // Constructors
148
149 //- No copy construct
150 faceZone(const faceZone&) = delete;
151
152 //- Construct an empty zone - name="", index=0
153 explicit faceZone(const faceZoneMesh& zm);
155 //- Construct an empty zone with specified name and index
157 (
158 const word& name,
159 const label index,
160 const faceZoneMesh& zm
161 );
162
163 //- Construct from components with uniform flip map value
165 (
166 const word& name,
167 const labelUList& addr,
168 const bool flipMapValue,
169 const label index,
170 const faceZoneMesh& zm
171 );
172
173 //- Construct from components with uniform flip map value,
174 //- transferring addressing.
176 (
177 const word& name,
178 labelList&& addr,
179 const bool flipMapValue,
180 const label index,
181 const faceZoneMesh& zm
182 );
183
184 //- Construct from components, copying addressing
186 (
187 const word& name,
188 const labelUList& addr,
189 const boolUList& fm,
190 const label index,
191 const faceZoneMesh& zm
192 );
193
194 //- Construct from components, transferring addressing
196 (
197 const word& name,
198 labelList&& addr,
199 boolList&& fm,
200 const label index,
201 const faceZoneMesh& zm
202 );
203
204 //- Construct from dictionary
206 (
207 const word& name,
208 const dictionary& dict,
209 const label index,
210 const faceZoneMesh& zm
211 );
212
213 //- Copy construct with new mesh reference.
215 (
216 const faceZone& originalZone,
217 const faceZoneMesh& zm,
219 const label newIndex = -1
220 );
221
222 //- Construct empty with original zone information (name, index, groups)
223 //- and mesh reference.
225 (
226 const faceZone& originalZone,
228 const faceZoneMesh& zm,
230 const label newIndex = -1
231 );
232
233 //- Construct empty with original zone information (name, groups),
234 //- resetting the index and zone mesh reference.
236 (
237 const faceZone& originalZone,
240 const label index,
241 const faceZoneMesh& zm
242 );
243
244 //- Construct with a new index and zone mesh information, the name
245 //- of the original zone, resetting the face addressing
246 //- and flip-map.
248 (
249 const faceZone& originalZone,
250 const labelUList& addr,
251 const boolUList& fm,
253 const label index,
254 const faceZoneMesh& zm
255 );
256
257 //- Construct with a new index and zone mesh information, the name
258 //- of the original zone, (move) resetting the face addressing
259 //- and flip-map.
261 (
262 const faceZone& originalZone,
263 labelList&& addr,
264 boolList&& fm,
266 const label index,
267 const faceZoneMesh& zm
268 );
269
270 //- Construct and return a clone, resetting the zone mesh
272 (
273 const faceZoneMesh& zm,
275 const label newIndex = -1
276 ) const
277 {
278 return autoPtr<faceZone>::New(*this, zm, newIndex);
279 }
280
281 //- Construct and return a clone,
282 //- resetting the face list and zone mesh
284 (
285 const labelUList& addr,
286 const boolUList& fm,
288 const label index,
289 const faceZoneMesh& zm
290 ) const
291 {
292 return autoPtr<faceZone>::New(*this, addr, fm, index, zm);
293 }
294
295
296 // Selectors
297
298 //- Return a pointer to a new face zone
299 //- created on freestore from dictionary
300 static autoPtr<faceZone> New
301 (
302 const word& name,
303 const dictionary& dict,
304 const label index,
305 const faceZoneMesh& zm
306 );
307
308
309 //- Destructor
310 virtual ~faceZone() = default;
311
312
313 // Member Functions
314
315 //- The maximum index the zone may contain == mesh nFaces()
316 label max_index() const noexcept;
317
318 //- Return reference to the zone mesh
319 const faceZoneMesh& zoneMesh() const noexcept { return zoneMesh_; }
320
321 //- The addressing (face IDs) used for the zone
322 using zone::addressing;
323
324 //- Return face flip map
325 const boolList& flipMap() const noexcept { return flipMap_; }
326
327 //- The local index of the given mesh face, -1 if not in the zone
328 label whichFace(const label meshFaceID) const
329 {
330 return zone::localID(meshFaceID);
331 }
332
333 //- Return [demand-driven] reference to an equivalent primitive patch,
334 //- with faces oriented according to flipMap()
335 const primitiveFacePatch& patch() const;
336
337
338 // Checks
339
340 //- Check zone definition.
341 // \return True if any errors.
342 virtual bool checkDefinition(const bool report = false) const
343 {
344 return zone::checkDefinition(max_index(), report);
345 }
346
347 //- Check whether all procs have faces synchronised.
348 // \return True if any errors.
349 virtual bool checkParallelSync(const bool report = false) const;
350
351
352 // Addressing into mesh
353
354 //- The front cells layer.
355 //- Cells on the positive normal side of faces.
356 // \warning may contain negative indices for boundary faces!
357 const labelList& frontCells() const;
358
359 //- The back cells layer.
360 //- Cells on the negative normal side of faces.
361 // \warning may contain negative indices for boundary faces!
362 const labelList& backCells() const;
363
364 //- Return global edge index for local edges
365 const labelList& meshEdges() const;
367
368 // Assign addressing
369
370 //- Clear addressing
371 //- (remove lookup maps, patch/geometric information)
372 virtual void clearAddressing();
373
374 //- Clear primitive addressing
375 virtual void clearPrimitives();
376
377 //- Move reset addressing and flip map from another zone
378 virtual void resetAddressing(faceZone&& zn);
380 //- Copy reset addressing and flip map from another zone
381 virtual void resetAddressing(const faceZone& zn);
382
383 //- Reset addressing - use uniform flip map value
384 // Clears demand-driven data.
385 virtual void resetAddressing
386 (
387 const labelUList& addr,
388 const bool flipMapValue
389 );
390
391 //- Move reset addressing - use uniform flip map value
392 // Clears demand-driven data.
393 virtual void resetAddressing
395 labelList&& addr,
396 const bool flipMapValue
397 );
398
399 //- Copy reset addressing and flip map.
400 // Clears demand-driven data.
401 virtual void resetAddressing
402 (
403 const labelUList& addr,
404 const boolUList& flipMap
405 );
406
407 //- Assign addressing, clearing demand-driven data
408 void operator=(const faceZone& zn);
409
410
411 // Mesh Changes
412
413 //- Correct patch after moving points
414 virtual void movePoints(const pointField& pts);
415
416 //- Update for changes in topology
417 virtual void updateMesh(const mapPolyMesh& mpm);
418
419
420 // I-O
421
422 //- Write (dictionary entries)
423 virtual void write(Ostream& os) const;
424
425 //- Ostream Operator
426 friend Ostream& operator<<(Ostream& os, const faceZone& zn);
427
428
429 // Housekeeping
430
431 //- Deprecated(2023-09) same as patch()
432 // \deprecated(2023-09) same as patch()
433 const primitiveFacePatch& operator()() const { return this->patch(); }
434
435 //- Deprecated(2023-09) same as frontCells
436 // \deprecated(2023-09) same as frontCells #1832
437 const labelList& masterCells() const { return frontCells(); }
438
439 //- Deprecated(2023-09) same as backCells
440 // \deprecated(2023-09) same as backCells #1832
441 const labelList& slaveCells() const { return backCells(); }
442
443 //- Deprecated(2025-09) Write dictionary
444 // \deprecated(2025-09) Write dictionary
445 FOAM_DEPRECATED_FOR(2025-09, "write() or operator<<")
446 void writeDict(Ostream& os) const
447 {
448 os.beginBlock(name()); write(os); os.endBlock();
449 }
450};
451
452
453// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
454
455} // End namespace Foam
456
457// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
458
459#endif
460
461// ************************************************************************* //
autoPtr< List< label > > clone() const
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition autoPtr.H:178
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A subset of mesh faces organised as a primitive patch.
Definition faceZone.H:63
label whichFace(const label meshFaceID) const
The local index of the given mesh face, -1 if not in the zone.
Definition faceZone.H:394
const primitiveFacePatch & operator()() const
Deprecated(2023-09) same as patch().
Definition faceZone.H:545
virtual ~faceZone()=default
Destructor.
const labelList & slaveCells() const
Deprecated(2023-09) same as backCells.
Definition faceZone.H:559
virtual bool checkDefinition(const bool report=false) const
Check zone definition.
Definition faceZone.H:413
static constexpr const char * labelsName()
The name associated with the zone-labels dictionary entry.
Definition faceZone.H:143
const primitiveFacePatch & patch() const
Return [demand-driven] reference to an equivalent primitive patch, with faces oriented according to f...
Definition faceZone.C:426
virtual autoPtr< faceZone > clone(const faceZoneMesh &zm, const label newIndex=-1) const
Construct and return a clone, resetting the zone mesh.
Definition faceZone.H:322
const boolList & flipMap() const noexcept
Return face flip map.
Definition faceZone.H:389
virtual void clearPrimitives()
Clear primitive addressing.
Definition faceZone.C:493
virtual void resetAddressing(faceZone &&zn)
Move reset addressing and flip map from another zone.
Definition faceZone.C:500
virtual autoPtr< faceZone > clone(const labelUList &addr, const boolUList &fm, const label index, const faceZoneMesh &zm) const
Construct and return a clone, resetting the face list and zone mesh.
Definition faceZone.H:336
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes in topology.
Definition faceZone.C:563
label max_index() const noexcept
The maximum index the zone may contain == mesh nFaces().
Definition faceZone.C:409
virtual void clearAddressing()
Clear addressing (remove lookup maps, patch/geometric information).
Definition faceZone.C:486
declareRunTimeSelectionTable(autoPtr, faceZone, dictionary,(const word &name, const dictionary &dict, const label index, const faceZoneMesh &zm),(name, dict, index, zm))
static autoPtr< faceZone > New(const word &name, const dictionary &dict, const label index, const faceZoneMesh &zm)
Return a pointer to a new face zone created on freestore from dictionary.
Definition faceZoneNew.C:28
void writeDict(Ostream &os) const
Deprecated(2025-09) Write dictionary.
Definition faceZone.H:567
const labelList & backCells() const
The back cells layer. Cells on the negative normal side of faces.
Definition faceZone.C:446
const labelList & frontCells() const
The front cells layer. Cells on the positive normal side of faces.
Definition faceZone.C:436
virtual void movePoints(const pointField &pts)
Correct patch after moving points.
Definition faceZone.C:686
friend Ostream & operator<<(Ostream &os, const faceZone &zn)
Ostream Operator.
const faceZoneMesh & zoneMesh() const noexcept
Return reference to the zone mesh.
Definition faceZone.H:379
faceZone(const faceZone &)=delete
No copy construct.
virtual bool checkParallelSync(const bool report=false) const
Check whether all procs have faces synchronised.
Definition faceZone.C:595
void operator=(const faceZone &zn)
Assign addressing, clearing demand-driven data.
Definition faceZone.C:705
TypeName("faceZone")
Runtime type information.
const labelList & masterCells() const
Deprecated(2023-09) same as frontCells.
Definition faceZone.H:552
const labelList & meshEdges() const
Return global edge index for local edges.
Definition faceZone.C:456
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from Foam::string.
Definition word.H:66
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
label index() const noexcept
The index of this zone in the zone list.
const word & name() const noexcept
The zone name.
virtual bool checkDefinition(const bool report=false) const =0
Check zone definition. Return true if in error.
label localID(const label globalID) const
Lookup local address in zone for given global index.
Definition zone.C:149
zone()
Default construct: empty zone with name="", index=0.
Definition zone.C:37
const labelList & addressing() const noexcept
The addressing used by the zone.
Definition zone.H:182
OBJstream os(runTime.globalPath()/outputName)
auto & name
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with faceZone content on a polyMesh.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
A PrimitivePatch with List storage for the faces, const reference for the point field.
List< bool > boolList
A List of bools.
Definition List.H:60
UList< bool > boolUList
A UList of bools.
Definition UList.H:73
const direction noexcept
Definition scalarImpl.H:265
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Definition UList.H:75
runTime write()
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
dictionary dict
const pointField & pts
#define FOAM_DEPRECATED_FOR(since, replacement)
Definition stdFoam.H:43
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68