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-2020 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
58class polyBoundaryMesh;
59class polyPatch;
60class polyTopoChange;
61class PstreamBuffers;
62
63//- Store lists of polyPatch as a PtrList
65
67
68/*---------------------------------------------------------------------------*\
69 Class polyPatch Declaration
70\*---------------------------------------------------------------------------*/
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 labelList::subList* faceCellsPtr_;
87
88 //- Demand-driven: global edge addressing
89 mutable labelList* mePtr_;
90
91
92protected:
93
94 // Protected Member Functions
95
96 //- Inherit movePoints from primitivePatch
98
99 // The polyPatch geometry initialisation is called by polyBoundaryMesh
100 friend class polyBoundaryMesh;
101
102 //- Initialise the calculation of the patch geometry
103 virtual void initGeometry(PstreamBuffers&)
104 {}
105
106 //- Calculate the patch geometry
107 virtual void calcGeometry(PstreamBuffers&)
108 {}
109
110 //- Initialise the patches for moving points
111 virtual void initMovePoints(PstreamBuffers&, const pointField&)
112 {}
113
114 //- Correct patches after moving points
115 virtual void movePoints(PstreamBuffers&, const pointField& p);
116
117 //- Initialise the update of the patch topology
118 virtual void initUpdateMesh(PstreamBuffers&)
119 {}
120
121 //- Update of the patch topology
122 virtual void updateMesh(PstreamBuffers&);
123
124 //- Clear geometry
125 virtual void clearGeom();
126
127
128public:
129
130 //- Runtime type information
131 TypeName("patch");
132
133 //- Debug switch to disallow the use of genericPolyPatch
134 static int disallowGenericPolyPatch;
135
136
137 // Declare run-time constructor selection tables
140 (
141 autoPtr,
142 polyPatch,
143 word,
144 (
145 const word& name,
146 const label size,
147 const label start,
148 const label index,
149 const polyBoundaryMesh& bm,
150 const word& patchType
151 ),
152 (name, size, start, index, bm, patchType)
153 );
156 (
157 autoPtr,
158 polyPatch,
160 (
161 const word& name,
162 const dictionary& dict,
163 const label index,
164 const polyBoundaryMesh& bm,
165 const word& patchType
166 ),
167 (name, dict, index, bm, patchType)
168 );
169
170
171 // Constructors
172
173 //- Construct from components
175 (
176 const word& name,
177 const label size,
178 const label start,
179 const label index,
180 const polyBoundaryMesh& bm,
181 const word& patchType
182 );
183
184 //- Construct from components
186 (
187 const word& name,
188 const label size,
189 const label start,
190 const label index,
191 const polyBoundaryMesh& bm,
192 const word& physicalType,
193 const wordList& inGroups
194 );
195
196 //- Construct from dictionary
198 (
199 const word& name,
200 const dictionary& dict,
201 const label index,
202 const polyBoundaryMesh& bm,
203 const word& patchType
204 );
205
206 //- Copy construct, resetting the boundary mesh
207 polyPatch(const polyPatch&, const polyBoundaryMesh&);
208
209 //- Construct given the original patch and resetting the
210 //- face list and boundary mesh information
212 (
213 const polyPatch& pp,
214 const polyBoundaryMesh& bm,
215 const label index,
216 const label newSize,
217 const label newStart
218 );
219
220 //- Construct given the original patch and a map
222 (
223 const polyPatch& pp,
224 const polyBoundaryMesh& bm,
225 const label index,
226 const labelUList& mapAddressing,
227 const label newStart
228 );
229
230 //- Copy construct
231 polyPatch(const polyPatch& p);
232
233 //- Copy construct, setting faceCells
234 // \note The faceCells are held by the caller
235 polyPatch(const polyPatch& p, const labelList& faceCells);
236
237 //- Construct and return a clone, setting faceCells
238 // \note The faceCells are held by the caller
239 virtual autoPtr<polyPatch> clone(const labelList& faceCells) const
240 {
241 return autoPtr<polyPatch>::New(*this, faceCells);
242 }
243
244 //- Construct and return a clone, resetting the boundary mesh
245 virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
246 {
247 return autoPtr<polyPatch>::New(*this, bm);
248 }
249
250 //- Construct and return a clone,
251 //- resetting the face list and boundary mesh
253 (
254 const polyBoundaryMesh& bm,
255 const label index,
256 const label newSize,
257 const label newStart
258 ) const
259 {
260 return autoPtr<polyPatch>::New(*this, bm, index, newSize, newStart);
261 }
262
263 //- Construct and return a clone,
264 //- resetting the face list and boundary mesh
266 (
267 const polyBoundaryMesh& bm,
268 const label index,
269 const labelUList& mapAddressing,
270 const label newStart
271 ) const
272 {
274 (*this, bm, index, mapAddressing, newStart);
275 }
276
277
278 // Selectors
279
280 //- Return pointer to a new patch created on freestore from components
282 (
283 const word& patchType,
284 const word& name,
285 const label size,
286 const label start,
287 const label index,
288 const polyBoundaryMesh& bm
289 );
290
291 //- Return pointer to a new patch created on freestore from dictionary
293 (
294 const word& name,
295 const dictionary& dict,
296 const label index,
297 const polyBoundaryMesh& bm
298 );
299
300 //- Return pointer to a new patch created on freestore from dictionary
302 (
303 const word& patchType,
304 const word& name,
305 const dictionary& dict,
306 const label index,
307 const polyBoundaryMesh& bm
308 );
309
310
311 //- Destructor
312 virtual ~polyPatch();
313
314
315 // Member Functions
316
317 // Implicit treatment functions
318
319 //- Return number of new internal of this polyPatch faces
320 virtual void newInternalProcFaces(label&, label&) const
321 {
323 }
324
325 //- Return nbrCells
326 virtual const labelUList& nbrCells() const
327 {
329 return labelUList::null();
330 }
331
332 //- Return nbr patchID
333 virtual label neighbPolyPatchID() const
334 {
336 return -1;
337 }
338
339 //- Return mapped collocated faces
341 {
343 return nullptr;
344 }
345
346 //- Return implicit master
347 virtual bool masterImplicit() const
348 {
350 return false;
351 }
352
353 //- Return neighbour region name
354 virtual word neighbRegionID() const
355 {
356 return word("none");
357 }
358
359
360 //- The offset where this patch starts in the boundary face list
361 // The value is the same as patch.start() - mesh.nInternalFaces()
362 label offset() const;
363
364 //- Return start label of this patch in the polyMesh face list
365 label start() const
366 {
367 return start_;
368 }
369
370 //- Return start/size range of this patch
371 labelRange range() const
372 {
373 return labelRange(start_, this->size());
374 }
375
376 //- Return boundaryMesh reference
377 const polyBoundaryMesh& boundaryMesh() const;
378
379 //- Return true if this patch is geometrically coupled (i.e. faces and
380 // points correspondence)
381 virtual bool coupled() const
382 {
383 return false;
384 }
385
386 //- Return true if the given type is a constraint type
387 static bool constraintType(const word& pt);
388
389 //- Return a list of all the constraint patch types
390 static wordList constraintTypes();
391
392 //- Extract face cell data
393 template<class T>
395 (
396 const UList<T>& internalValues
397 ) const
398 {
399 return UIndirectList<T>(internalValues, faceCells());
400 }
401
402 //- Slice list to patch
403 template<class T>
404 const typename List<T>::subList patchSlice(const UList<T>& l) const
405 {
406 return typename List<T>::subList(l, this->size(), start_);
407 }
408
409 //- Slice Field to patch
410 template<class T>
411 const typename Field<T>::subField patchSlice(const Field<T>& l) const
412 {
413 return typename Field<T>::subField(l, this->size(), start_);
414 }
415
416
417 //- Write the polyPatch data as a dictionary
418 virtual void write(Ostream& os) const;
419
420
421 // Geometric data; point list required
422
423 //- Return face centres
425
426 //- Return face normals
427 const vectorField::subField faceAreas() const;
428
429 //- Return face cell centres
431
432 //- Return the area fraction as the ratio of the stored face area
433 //- and the area given by the face points
435
436
437 // Addressing into mesh
438
439 //- Return face-cell addressing
440 const labelUList& faceCells() const;
441
442 //- Return global edge index for local edges
443 const labelList& meshEdges() const;
444
445 //- Clear addressing
446 virtual void clearAddressing();
447
448
449 // Other patch operations
450
451 //- Return label of face in patch from global face label
452 inline label whichFace(const label l) const
453 {
454 return l - start_;
455 }
456
457
458 //- Initialize ordering for primitivePatch. Does not
459 // refer to *this (except for name() and type() etc.)
460 virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
461
462 //- Return new ordering for primitivePatch.
463 // Ordering is -faceMap: for every face
464 // index of the new face -rotation:for every new face the clockwise
465 // shift of the original face. Return false if nothing changes
466 // (faceMap is identity, rotation is 0), true otherwise.
467 virtual bool order
468 (
470 const primitivePatch&,
472 labelList& rotation
473 ) const;
474
475 //- For dynamic mesh cases - return true if this patch will change the
476 //- topology
477 virtual bool changeTopology() const
478 {
479 return false;
480 }
481
482 //- Collect topology changes in a polyTopoChange object
483 virtual bool setTopology(polyTopoChange&)
484 {
485 return false;
486 }
487
488
489 // Member Operators
490
491 //- Assignment
492 void operator=(const polyPatch&);
493
494
495 // Ostream Operator
497 friend Ostream& operator<<(Ostream&, const polyPatch&);
498};
499
500
501// Global Functions
502
503//- The labelRange of a polyPatch
504template<>
507 labelRange operator()(const polyPatch& pp) const
508 {
509 return pp.range();
510 }
511};
512
513
514// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
515
516} // End namespace Foam
517
518// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
519
520#endif
521
522// ************************************************************************* //
SubField< Type > subField
Declare type of subField.
Definition: Field.H:89
SubList< T > subList
Declare type of subList.
Definition: List.H:111
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.
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:73
SubField is a Field obtained as a section of another Field, without its own allocation....
Definition: SubField.H:62
A List obtained as a section of another List.
Definition: SubList.H:70
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
A List with indirect addressing. Like IndirectList but does not store addressing.
Definition: IndirectList.H:79
static const UList< label > & null()
Return a UList reference to a nullObject.
Definition: UListI.H:53
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
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:59
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:58
void movePoints()
Update for new mesh geometry.
Identifies a patch by name and index, with optional physical type and group information.
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.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Definition: polyPatch.H:244
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: polyPatch.C:287
const List< T >::subList patchSlice(const UList< T > &l) const
Slice list to patch.
Definition: polyPatch.H:403
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: polyPatch.C:67
label whichFace(const label l) const
Return label of face in patch from global face label.
Definition: polyPatch.H:451
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:327
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.
Definition: polyPatchNew.C:35
virtual void newInternalProcFaces(label &, label &) const
Return number of new internal of this polyPatch faces.
Definition: polyPatch.H:319
label offset() const
The offset where this patch starts in the boundary face list.
Definition: polyPatch.C:309
TypeName("patch")
Runtime type information.
virtual label neighbPolyPatchID() const
Return nbr patchID.
Definition: polyPatch.H:332
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:394
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:380
friend Ostream & operator<<(Ostream &, const polyPatch &)
virtual bool masterImplicit() const
Return implicit master.
Definition: polyPatch.H:346
virtual void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: polyPatch.H:102
virtual autoPtr< polyPatch > clone(const labelList &faceCells) const
Construct and return a clone, setting faceCells.
Definition: polyPatch.H:238
virtual void clearGeom()
Clear geometry.
Definition: polyPatch.C:74
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: polyPatch.C:422
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:364
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:315
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm, const label index, const label newSize, const label newStart) const
Definition: polyPatch.H:252
virtual const labelUList & nbrCells() const
Return nbrCells.
Definition: polyPatch.H:325
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:321
virtual void movePoints(PstreamBuffers &, const pointField &p)
Correct patches after moving points.
Definition: polyPatch.C:61
virtual ~polyPatch()
Destructor.
Definition: polyPatch.C:269
virtual bool setTopology(polyTopoChange &)
Collect topology changes in a polyTopoChange object.
Definition: polyPatch.H:482
const Field< T >::subField patchSlice(const Field< T > &l) const
Slice Field to patch.
Definition: polyPatch.H:410
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
Definition: polyPatch.C:277
virtual bool changeTopology() const
Definition: polyPatch.H:476
virtual refPtr< labelListList > mapCollocatedFaces() const
Return mapped collocated faces.
Definition: polyPatch.H:339
void operator=(const polyPatch &)
Assignment.
Definition: polyPatch.C:441
labelRange range() const
Return start/size range of this patch.
Definition: polyPatch.H:370
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm, const label index, const labelUList &mapAddressing, const label newStart) const
Definition: polyPatch.H:265
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition: polyPatch.H:117
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: polyPatch.C:427
virtual void clearAddressing()
Clear addressing.
Definition: polyPatch.C:404
static int disallowGenericPolyPatch
Debug switch to disallow the use of genericPolyPatch.
Definition: polyPatch.H:133
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition: polyPatch.H:106
tmp< vectorField > faceCellCentres() const
Return face cell centres.
Definition: polyPatch.C:333
virtual word neighbRegionID() const
Return neighbour region name.
Definition: polyPatch.H:353
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Definition: polyPatch.H:110
declareRunTimeSelectionTable(autoPtr, polyPatch, dictionary,(const word &name, const dictionary &dict, const label index, const polyBoundaryMesh &bm, const word &patchType),(name, dict, index, bm, patchType))
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:371
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: polyPatch.C:385
tmp< scalarField > areaFraction() const
Definition: polyPatch.C:352
Direct mesh changes based on v1.3 polyTopoChange syntax.
A class for managing references or pointers (no reference counting)
Definition: refPtr.H:58
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
OBJstream os(runTime.globalPath()/outputName)
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:63
List< word > wordList
A List of words.
Definition: fileName.H:63
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
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:506
Conversion/extraction to labelRange operation (functor).
Definition: labelRange.H:202
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73