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