Loading...
Searching...
No Matches
polyPatch.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-2015 OpenFOAM Foundation
9 Copyright (C) 2015-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::polyPatch
29
30Description
31 A patch is a list of labels that address the faces in the global face list.
32
33 The patch can calculate its own edges based on the global faces.
34 Patch also contains all addressing between the faces.
35
36SourceFiles
37 polyPatch.C
38 polyPatchNew.C
39
40\*---------------------------------------------------------------------------*/
41
42#ifndef Foam_polyPatch_H
43#define Foam_polyPatch_H
44
45#include "patchIdentifier.H"
46#include "primitivePatch.H"
47#include "typeInfo.H"
49#include "SubField.H"
50#include "PtrList.H"
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54namespace Foam
55{
56
57// Forward Declarations
59class polyPatch;
60class polyTopoChange;
62
63//- Store lists of polyPatch as a PtrList
65
67
68/*---------------------------------------------------------------------------*\
69 Class polyPatch Declaration
70\*---------------------------------------------------------------------------*/
71
72class polyPatch
73:
74 public patchIdentifier,
75 public primitivePatch
76{
77 // Private Data
78
79 //- Start label of this patch in the polyMesh face list
80 label start_;
81
82 //- Reference to boundary mesh
83 const polyBoundaryMesh& boundaryMesh_;
84
85 //- Demand-driven: face-cell addressing
86 mutable std::unique_ptr<labelList::subList> faceCellsPtr_;
87
88 //- Demand-driven: global edge addressing
89 mutable std::unique_ptr<labelList> mePtr_;
90
91 //- Cached area fraction
92 std::unique_ptr<scalarField> areaFractionPtr_;
93
94
95protected:
96
97 // Protected Member Functions
98
99 //- Inherit movePoints from primitivePatch
101
102 // The polyPatch geometry initialisation is called by polyBoundaryMesh
103 friend class polyBoundaryMesh;
104
105 //- Initialise the calculation of the patch geometry
106 virtual void initGeometry(PstreamBuffers&)
107 {}
108
109 //- Calculate the patch geometry
110 virtual void calcGeometry(PstreamBuffers&)
111 {}
113 //- Initialise the patches for moving points
114 virtual void initMovePoints(PstreamBuffers&, const pointField&)
115 {}
116
117 //- Correct patches after moving points
118 virtual void movePoints(PstreamBuffers&, const pointField& p);
119
120 //- Initialise the update of the patch topology
121 virtual void initUpdateMesh(PstreamBuffers&)
122 {}
124 //- Update of the patch topology
125 virtual void updateMesh(PstreamBuffers&);
126
127 //- Clear geometry
128 virtual void clearGeom();
130
131public:
132
133 //- Runtime type information
134 TypeName("patch");
135
136 //- Debug switch to disallow the use of genericPolyPatch
137 static int disallowGenericPolyPatch;
138
139
140 // Declare run-time constructor selection tables
141
143 (
144 autoPtr,
145 polyPatch,
146 word,
147 (
148 const word& name,
149 const label size,
150 const label start,
151 const label index,
152 const polyBoundaryMesh& bm,
153 const word& patchType
154 ),
155 (name, size, start, index, bm, patchType)
156 );
157
160 autoPtr,
161 polyPatch,
163 (
164 const word& name,
165 const dictionary& dict,
166 const label index,
167 const polyBoundaryMesh& bm,
168 const word& patchType
169 ),
170 (name, dict, index, bm, patchType)
171 );
172
173
174 // Constructors
175
176 //- Construct from components
178 (
179 const word& name,
180 const label size,
181 const label start,
182 const label index,
183 const polyBoundaryMesh& bm,
184 const word& patchType
185 );
186
187 //- Construct from components
189 (
190 const word& name,
191 const label size,
192 const label start,
193 const label index,
194 const polyBoundaryMesh& bm,
195 const word& physicalType,
196 const wordList& inGroups
197 );
198
199 //- Construct from dictionary
201 (
202 const word& name,
203 const dictionary& dict,
204 const label index,
205 const polyBoundaryMesh& bm,
206 const word& patchType
207 );
208
209 //- Copy construct, resetting the boundary mesh
210 polyPatch(const polyPatch&, const polyBoundaryMesh&);
211
212 //- Construct given the original patch and resetting the
213 //- face list and boundary mesh information
215 (
216 const polyPatch& pp,
217 const polyBoundaryMesh& bm,
218 const label index,
219 const label newSize,
220 const label newStart
221 );
222
223 //- Construct given the original patch and a map
225 (
226 const polyPatch& pp,
227 const polyBoundaryMesh& bm,
228 const label index,
229 const labelUList& mapAddressing,
230 const label newStart
231 );
232
233 //- Copy construct
234 polyPatch(const polyPatch& p);
235
236 //- Copy construct, setting faceCells
237 // \note The faceCells are held by the caller
238 polyPatch(const polyPatch& p, const labelList& faceCells);
239
240 //- Construct and return a clone, setting faceCells
241 // \note The faceCells are held by the caller
242 virtual autoPtr<polyPatch> clone(const labelList& faceCells) const
243 {
244 return autoPtr<polyPatch>::New(*this, faceCells);
245 }
246
247 //- Construct and return a clone, resetting the boundary mesh
248 virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
249 {
250 return autoPtr<polyPatch>::New(*this, bm);
251 }
252
253 //- Construct and return a clone,
254 //- resetting the face list and boundary mesh
255 virtual autoPtr<polyPatch> clone
256 (
257 const polyBoundaryMesh& bm,
258 const label index,
259 const label newSize,
260 const label newStart
261 ) const
262 {
263 return autoPtr<polyPatch>::New(*this, bm, index, newSize, newStart);
264 }
265
266 //- Construct and return a clone,
267 //- resetting the face list and boundary mesh
268 virtual autoPtr<polyPatch> clone
269 (
270 const polyBoundaryMesh& bm,
271 const label index,
272 const labelUList& mapAddressing,
273 const label newStart
274 ) const
275 {
277 (*this, bm, index, mapAddressing, newStart);
278 }
279
280
281 // Selectors
282
283 //- Return pointer to a new patch created on freestore from components
284 static autoPtr<polyPatch> New
285 (
286 const word& patchType,
287 const word& name,
288 const label size,
289 const label start,
290 const label index,
291 const polyBoundaryMesh& bm
292 );
293
294 //- Return pointer to a new patch created on freestore from dictionary
296 (
297 const word& name,
298 const dictionary& dict,
299 const label index,
300 const polyBoundaryMesh& bm
301 );
302
303 //- Return pointer to a new patch created on freestore from dictionary
305 (
306 const word& patchType,
307 const word& name,
308 const dictionary& dict,
309 const label index,
310 const polyBoundaryMesh& bm
311 );
312
313
314 //- Destructor
315 virtual ~polyPatch();
316
317
318 // Member Functions
319
320 // Implicit treatment functions
322 //- Return number of new internal of this polyPatch faces
323 virtual void newInternalProcFaces(label&, label&) const
324 {
326 }
327
328 //- Return nbrCells
329 virtual const labelUList& nbrCells() const
330 {
332 return labelUList::null();
333 }
334
335 //- Return nbr patchID
336 virtual label neighbPolyPatchID() const
337 {
339 return -1;
340 }
341
342 //- Return mapped collocated faces
343 virtual refPtr<labelListList> mapCollocatedFaces() const
344 {
346 return nullptr;
347 }
348
349 //- Return implicit master
350 virtual bool masterImplicit() const
351 {
353 return false;
354 }
355
356 //- Return neighbour region name
357 virtual word neighbRegionID() const
358 {
359 return word("none");
360 }
361
362
363 //- The offset where this patch starts in the boundary face list
364 // The value is the same as patch.start() - mesh.nInternalFaces()
365 label offset() const noexcept;
366
367 //- Return start label of this patch in the polyMesh face list
368 label start() const noexcept
369 {
370 return start_;
371 }
372
373 //- Return start/size range of this patch
374 labelRange range() const
375 {
376 return labelRange(start_, this->size());
377 }
378
379 //- Return boundaryMesh reference
381
382 //- Return true if this patch is geometrically coupled (i.e. faces and
383 // points correspondence)
384 virtual bool coupled() const
385 {
386 return false;
387 }
388
389 //- Return true if the given type is a constraint type
390 static bool constraintType(const word& patchType);
391
392 //- Return a list of all the constraint patch types
393 static wordList constraintTypes();
395 //- Extract face cell data
396 template<class T>
398 (
399 const UList<T>& internalValues
400 ) const
401 {
402 return UIndirectList<T>(internalValues, faceCells());
404
405 //- This patch slice from the complete list, which has size
406 //- mesh::nFaces(), using the number of patch faces.
407 template<class T>
408 const typename List<T>::subList
409 patchSlice(const UList<T>& values) const
410 {
411 return typename List<T>::subList(values, this->size(), start_);
413
414 //- Slice Field to patch, using the number of patch faces.
415 template<class T>
416 const typename Field<T>::subField
417 patchSlice(const Field<T>& values) const
418 {
419 return typename Field<T>::subField(values, this->size(), start_);
420 }
422 //- This patch slice from the list of boundary values, which has size
423 //- mesh::nBoundaryFaces(), using the number of patch faces.
424 template<class T>
425 const typename List<T>::subList
426 boundarySlice(const UList<T>& values) const
427 {
428 return typename List<T>::subList(values, this->size(), offset());
429 }
431
432 //- Write the polyPatch data as a dictionary
433 virtual void write(Ostream& os) const;
434
435
436 // Geometric data; point list required
437
438 //- Return mesh faces for the patch
439 const faceList::subList faces() const;
440
441 //- Return face owner for the patch
442 const labelList::subList faceOwner() const;
443
444 //- Return face centres
447 //- Return face normals
448 const vectorField::subField faceAreas() const;
449
450 //- Return face cell centres
452
453 //- Calculate the area fraction as the ratio of the stored face
454 //- area and the area given by the face points.
456
457 //- Return the cached area fraction.
458 //- Usually only set for the non-overlap patches on ACMI.
460
461 //- Set uniform cached area fraction
462 void areaFraction(const scalar fraction);
463
464 //- Set cached area fraction (non-uniform)
465 void areaFraction(const tmp<scalarField>& fraction);
466
467
468 // Addressing into mesh
470 //- Return face-cell addressing
471 const labelUList& faceCells() const;
472
473 //- Return global edge index for local edges
474 const labelList& meshEdges() const;
475
476 //- Clear addressing
477 virtual void clearAddressing();
478
479
480 // Other patch operations
481
482 //- Return label of face in patch from global face label
483 label whichFace(const label facei) const noexcept
484 {
485 return facei - start_;
486 }
487
489 //- Initialize ordering for primitivePatch. Does not
490 // refer to *this (except for name() and type() etc.)
491 virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
492
493 //- Return new ordering for primitivePatch.
494 // Ordering is -faceMap: for every face
495 // index of the new face -rotation:for every new face the clockwise
496 // shift of the original face. Return false if nothing changes
497 // (faceMap is identity, rotation is 0), true otherwise.
498 virtual bool order
499 (
501 const primitivePatch&,
503 labelList& rotation
504 ) const;
505
506 //- For dynamic mesh cases - return true if this patch will change the
507 //- topology
508 virtual bool changeTopology() const
509 {
510 return false;
511 }
513 //- Collect topology changes in a polyTopoChange object
514 virtual bool setTopology(polyTopoChange&)
515 {
516 return false;
517 }
518
519
520 // Member Operators
521
522 //- Copy assignment
523 void operator=(const polyPatch& p);
524
525
526 // Ostream Operator
527
528 friend Ostream& operator<<(Ostream&, const polyPatch&);
529};
530
531
532// Global Functions
533
534//- The labelRange of a polyPatch
535template<>
537{
538 labelRange operator()(const polyPatch& pp) const
539 {
540 return pp.range();
541 }
542};
543
544
545// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
546
547} // End namespace Foam
548
549// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
550
551#endif
552
553// ************************************************************************* //
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
SubField< Type > subField
Declare type of subField.
Definition Field.H:183
SubList< T > subList
Declare type of subList.
Definition List.H:129
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
const Field< point_type > & points() const noexcept
virtual void movePoints(const Field< point_type > &)
Buffers for inter-processor communications streams (UOPstream, UIPstream).
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
A List with indirect addressing. Like IndirectList but does not store addressing.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
static const UList< label > & null() noexcept
Definition UList.H:225
label size() const noexcept
Definition UList.H:706
void size(const label n)
Definition UList.H:118
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 range or interval of labels defined by a start and a size.
Definition labelRange.H:66
const word & physicalType() const noexcept
The (optional) physical type of the patch.
const wordList & inGroups() const noexcept
The (optional) groups that the patch belongs to.
label index() const noexcept
The index of this patch in the boundaryMesh.
const word & name() const noexcept
The patch name.
patchIdentifier(const patchIdentifier &)=default
Copy construct.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Definition polyPatch.H:297
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition polyPatch.C:266
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition polyPatch.C:59
const vectorField::subField faceAreas() const
Return face normals.
Definition polyPatch.C:326
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return pointer to a new patch created on freestore from components.
virtual void newInternalProcFaces(label &, label &) const
Return number of new internal of this polyPatch faces.
Definition polyPatch.H:386
label whichFace(const label facei) const noexcept
Return label of face in patch from global face label.
Definition polyPatch.H:608
TypeName("patch")
Runtime type information.
friend class polyBoundaryMesh
Definition polyPatch.H:112
virtual label neighbPolyPatchID() const
Return nbr patchID.
Definition polyPatch.H:403
declareRunTimeSelectionTable(autoPtr, polyPatch, word,(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType),(name, size, start, index, bm, patchType))
const UIndirectList< T > patchInternalList(const UList< T > &internalValues) const
Extract face cell data.
Definition polyPatch.H:489
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition polyPatch.H:469
friend Ostream & operator<<(Ostream &, const polyPatch &)
virtual bool masterImplicit() const
Return implicit master.
Definition polyPatch.H:421
virtual void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition polyPatch.H:117
virtual autoPtr< polyPatch > clone(const labelList &faceCells) const
Construct and return a clone, setting faceCells.
Definition polyPatch.H:289
virtual void clearGeom()
Clear geometry.
Definition polyPatch.C:66
void operator=(const polyPatch &p)
Copy assignment.
Definition polyPatch.C:477
label offset() const noexcept
The offset where this patch starts in the boundary face list.
Definition polyPatch.C:288
const faceList::subList faces() const
Return mesh faces for the patch.
Definition polyPatch.C:301
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition polyPatch.C:458
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm, const label index, const label newSize, const label newStart) const
Construct and return a clone, resetting the face list and boundary mesh.
Definition polyPatch.H:307
virtual const labelUList & nbrCells() const
Return nbrCells.
Definition polyPatch.H:394
const vectorField::subField faceCentres() const
Return face centres.
Definition polyPatch.C:320
virtual void movePoints(PstreamBuffers &, const pointField &p)
Correct patches after moving points.
Definition polyPatch.C:53
virtual ~polyPatch()
Destructor.
Definition polyPatch.C:247
virtual bool setTopology(polyTopoChange &)
Collect topology changes in a polyTopoChange object.
Definition polyPatch.H:649
virtual bool changeTopology() const
For dynamic mesh cases - return true if this patch will change the topology.
Definition polyPatch.H:641
virtual refPtr< labelListList > mapCollocatedFaces() const
Return mapped collocated faces.
Definition polyPatch.H:412
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundaryMesh reference.
Definition polyPatch.C:295
labelRange range() const
Return start/size range of this patch.
Definition polyPatch.H:454
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm, const label index, const labelUList &mapAddressing, const label newStart) const
Construct and return a clone, resetting the face list and boundary mesh.
Definition polyPatch.H:322
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition polyPatch.H:140
const Field< T >::subField patchSlice(const Field< T > &values) const
Slice Field to patch, using the number of patch faces.
Definition polyPatch.H:512
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition polyPatch.C:463
virtual void clearAddressing()
Clear addressing.
Definition polyPatch.C:439
polyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
Definition polyPatch.C:75
static int disallowGenericPolyPatch
Debug switch to disallow the use of genericPolyPatch.
Definition polyPatch.H:164
label start() const noexcept
Return start label of this patch in the polyMesh face list.
Definition polyPatch.H:446
const List< T >::subList patchSlice(const UList< T > &values) const
This patch slice from the complete list, which has size mesh::nFaces(), using the number of patch fac...
Definition polyPatch.H:502
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition polyPatch.H:123
tmp< vectorField > faceCellCentres() const
Return face cell centres.
Definition polyPatch.C:332
const List< T >::subList boundarySlice(const UList< T > &values) const
This patch slice from the list of boundary values, which has size mesh::nBoundaryFaces(),...
Definition polyPatch.H:523
const labelList::subList faceOwner() const
Return face owner for the patch.
Definition polyPatch.C:307
virtual word neighbRegionID() const
Return neighbour region name.
Definition polyPatch.H:430
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Definition polyPatch.H:129
declareRunTimeSelectionTable(autoPtr, polyPatch, dictionary,(const word &name, const dictionary &dict, const label index, const polyBoundaryMesh &bm, const word &patchType),(name, dict, index, bm, patchType))
static bool constraintType(const word &patchType)
Return true if the given type is a constraint type.
Definition polyPatch.C:255
const labelUList & faceCells() const
Return face-cell addressing.
Definition polyPatch.C:401
const labelList & meshEdges() const
Return global edge index for local edges.
Definition polyPatch.C:418
tmp< scalarField > areaFraction() const
Return the cached area fraction. Usually only set for the non-overlap patches on ACMI.
Definition polyPatch.C:371
Direct mesh changes based on v1.3 polyTopoChange syntax.
A class for managing references or pointers (no reference counting).
Definition refPtr.H:54
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition error.H:688
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
Namespace for OpenFOAM.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
PtrList< polyPatch > polyPatchList
Store lists of polyPatch as a PtrList.
Definition polyPatch.H:61
List< word > wordList
List of word.
Definition fileName.H:60
List< label > labelList
A List of labels.
Definition List.H:62
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
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()
Macros to ease declaration of run-time selection tables.
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes).
dictionary dict
labelRange operator()(const polyPatch &pp) const
Definition polyPatch.H:677
Conversion/extraction to labelRange operation (functor).
Definition labelRange.H:300
Basic run-time type information using word as the type's name. Used to enhance the standard RTTI to c...
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68