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 
83  // Demand-driven private data
84 
85  //- face-cell addressing
86  mutable labelList::subList* faceCellsPtr_;
87 
88  //- Global edge addressing
89  mutable labelList* mePtr_;
90 
91 
92 protected:
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 
128 public:
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
138 
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  );
154 
156  (
157  autoPtr,
158  polyPatch,
159  dictionary,
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
174  polyPatch
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
185  polyPatch
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
197  polyPatch
198  (
199  const word& name,
200  const dictionary& dict,
201  const label index,
202  const polyBoundaryMesh& bm,
203  const word& patchType
204  );
205 
206  //- Construct as copy, 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
211  polyPatch
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
221  polyPatch
222  (
223  const polyPatch& pp,
224  const polyBoundaryMesh& bm,
225  const label index,
226  const labelUList& mapAddressing,
227  const label newStart
228  );
229 
230  //- Construct as copy
231  polyPatch(const polyPatch&);
232 
233  //- Construct and return a clone, resetting the boundary mesh
234  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
235  {
236  return autoPtr<polyPatch>::New(*this, bm);
237  }
238 
239  //- Construct and return a clone, resetting the face list
240  // and boundary mesh
242  (
243  const polyBoundaryMesh& bm,
244  const label index,
245  const label newSize,
246  const label newStart
247  ) const
248  {
249  return autoPtr<polyPatch>::New(*this, bm, index, newSize, newStart);
250  }
251 
252  //- Construct and return a clone, resetting the face list
253  // and boundary mesh
255  (
256  const polyBoundaryMesh& bm,
257  const label index,
258  const labelUList& mapAddressing,
259  const label newStart
260  ) const
261  {
263  (*this, bm, index, mapAddressing, newStart);
264  }
265 
266 
267  // Selectors
268 
269  //- Return a pointer to a new patch created on freestore from
270  // components
271  static autoPtr<polyPatch> New
272  (
273  const word& patchType,
274  const word& name,
275  const label size,
276  const label start,
277  const label index,
278  const polyBoundaryMesh& bm
279  );
280 
281  //- Return a pointer to a new patch created on freestore from
282  // dictionary
283  static autoPtr<polyPatch> New
284  (
285  const word& name,
286  const dictionary& dict,
287  const label index,
288  const polyBoundaryMesh& bm
289  );
290 
291  //- Return a pointer to a new patch created on freestore from
292  // dictionary
293  static autoPtr<polyPatch> New
294  (
295  const word& patchType,
296  const word& name,
297  const dictionary& dict,
298  const label index,
299  const polyBoundaryMesh& bm
300  );
301 
302 
303  //- Destructor
304  virtual ~polyPatch();
305 
306 
307  // Member Functions
308 
309  //- The offset where this patch starts in the boundary face list
310  // The value is the same as patch.start() - mesh.nInternalFaces()
311  label offset() const;
312 
313  //- Return start label of this patch in the polyMesh face list
314  label start() const
315  {
316  return start_;
317  }
318 
319  //- Return start/size range of this patch
320  labelRange range() const
321  {
322  return labelRange(start_, this->size());
323  }
324 
325  //- Return boundaryMesh reference
326  const polyBoundaryMesh& boundaryMesh() const;
327 
328  //- Return true if this patch is geometrically coupled (i.e. faces and
329  // points correspondence)
330  virtual bool coupled() const
331  {
332  return false;
333  }
334 
335  //- Return true if the given type is a constraint type
336  static bool constraintType(const word& pt);
337 
338  //- Return a list of all the constraint patch types
339  static wordList constraintTypes();
340 
341  //- Extract face cell data
342  template<class T>
344  (
345  const UList<T>& internalValues
346  ) const
347  {
348  return UIndirectList<T>(internalValues, faceCells());
349  }
350 
351  //- Slice list to patch
352  template<class T>
353  const typename List<T>::subList patchSlice(const UList<T>& l) const
354  {
355  return typename List<T>::subList(l, this->size(), start_);
356  }
357 
358  //- Slice Field to patch
359  template<class T>
360  const typename Field<T>::subField patchSlice(const Field<T>& l) const
361  {
362  return typename Field<T>::subField(l, this->size(), start_);
363  }
364 
365 
366  //- Write the polyPatch data as a dictionary
367  virtual void write(Ostream&) const;
368 
369 
370  // Geometric data; point list required
371 
372  //- Return face centres
373  const vectorField::subField faceCentres() const;
374 
375  //- Return face normals
376  const vectorField::subField faceAreas() const;
377 
378  //- Return face cell centres
380 
381  //- Return the area fraction as the ratio of the stored face area
382  //- and the area given by the face points
384 
385 
386  // Addressing into mesh
387 
388  //- Return face-cell addressing
389  const labelUList& faceCells() const;
390 
391  //- Return global edge index for local edges
392  const labelList& meshEdges() const;
393 
394  //- Clear addressing
395  virtual void clearAddressing();
396 
397 
398  // Other patch operations
399 
400  //- Return label of face in patch from global face label
401  inline label whichFace(const label l) const
402  {
403  return l - start_;
404  }
405 
406 
407  //- Initialize ordering for primitivePatch. Does not
408  // refer to *this (except for name() and type() etc.)
409  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
410 
411  //- Return new ordering for primitivePatch.
412  // Ordering is -faceMap: for every face
413  // index of the new face -rotation:for every new face the clockwise
414  // shift of the original face. Return false if nothing changes
415  // (faceMap is identity, rotation is 0), true otherwise.
416  virtual bool order
417  (
419  const primitivePatch&,
421  labelList& rotation
422  ) const;
423 
424  //- For dynamic mesh cases - return true if this patch will change the
425  //- topology
426  virtual bool changeTopology() const
427  {
428  return false;
429  }
430 
431  //- Collect topology changes in a polyTopoChange object
432  virtual bool setTopology(polyTopoChange&)
433  {
434  return false;
435  }
436 
437 
438  // Member operators
439 
440  //- Assignment
441  void operator=(const polyPatch&);
442 
443 
444  // Ostream Operator
445 
446  friend Ostream& operator<<(Ostream&, const polyPatch&);
447 };
448 
449 
450 // Global Functions
451 
452 //- The labelRange of a polyPatch
453 template<>
454 struct labelRangeOp<polyPatch>
455 {
456  labelRange operator()(const polyPatch& pp) const
457  {
458  return pp.range();
459  }
460 };
461 
462 
463 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
464 
465 } // End namespace Foam
466 
467 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
468 
469 #endif
470 
471 // ************************************************************************* //
Foam::polyPatch::TypeName
TypeName("patch")
Runtime type information.
Foam::autoPtr::New
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
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:62
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:62
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:396
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:53
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:87
Foam::polyPatch::changeTopology
virtual bool changeTopology() const
Definition: polyPatch.H:425
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:329
Foam::polyPatch::write
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: polyPatch.C:405
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:301
Foam::polyPatch::areaFraction
tmp< scalarField > areaFraction() const
Definition: polyPatch.C:344
Foam::labelRangeOp< polyPatch >::operator()
labelRange operator()(const polyPatch &pp) const
Definition: polyPatch.H:455
Foam::polyPatch::updateMesh
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: polyPatch.C:67
Foam::polyPatch::patchInternalList
const UIndirectList< T > patchInternalList(const UList< T > &internalValues) const
Extract face cell data.
Definition: polyPatch.H:343
Foam::SubField
SubField is a Field obtained as a section of another Field.
Definition: Field.H:64
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::polyPatch::initUpdateMesh
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition: polyPatch.H:117
Foam::patchIdentifier
Identifies a patch by name, patch index and physical type.
Definition: patchIdentifier.H:54
Foam::Field< vector >
Foam::polyPatch::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:307
Foam::polyPatch::initMovePoints
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Definition: polyPatch.H:110
Foam::patchIdentifier::inGroups
const wordList & inGroups() const
The (optional) groups that the patch belongs to.
Definition: patchIdentifier.H:170
Foam::polyPatch::operator=
void operator=(const polyPatch &)
Assignment.
Definition: polyPatch.C:433
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:319
Foam::patchIdentifier::physicalType
const word & physicalType() const
The (optional) physical type of the patch.
Definition: patchIdentifier.H:146
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:419
Foam::polyPatch::initGeometry
virtual void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: polyPatch.H:102
Foam::polyPatch::constraintTypes
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: polyPatch.C:281
Foam::polyPatch::constraintType
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
Definition: polyPatch.C:275
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::List::subList
SubList< T > subList
Declare type of subList.
Definition: List.H:114
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:121
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 a pointer to a new patch created on freestore from.
Definition: polyPatchNew.C:35
Foam::polyPatch::initOrder
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: polyPatch.C:414
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::polyPatch::faceCells
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:363
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:313
Foam::polyPatch::~polyPatch
virtual ~polyPatch()
Destructor.
Definition: polyPatch.C:267
Foam::polyPatch::clone
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Definition: polyPatch.H:233
Foam::polyPatch::faceCellCentres
tmp< vectorField > faceCellCentres() const
Return face cell centres.
Definition: polyPatch.C:325
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:400
Foam::polyPatch::patchSlice
const List< T >::subList patchSlice(const UList< T > &l) const
Slice list to patch.
Definition: polyPatch.H:352
Foam::polyPatch::faceCentres
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:313
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:319
Foam::UList< label >
Foam::polyPatch::patchSlice
const Field< T >::subField patchSlice(const Field< T > &l) const
Slice Field to patch.
Definition: polyPatch.H:359
Foam::polyPatch::setTopology
virtual bool setTopology(polyTopoChange &)
Collect topology changes in a polyTopoChange object.
Definition: polyPatch.H:431
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:172
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:106
Foam::polyPatch::meshEdges
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: polyPatch.C:377
primitivePatch.H
Foam::patchIdentifier::name
const word & name() const
The patch name.
Definition: patchIdentifier.H:134
Foam::patchIdentifier::index
label index() const
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:158
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:85
Foam::polyPatch::disallowGenericPolyPatch
static int disallowGenericPolyPatch
Debug switch to disallow the use of genericPolyPatch.
Definition: polyPatch.H:133