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-2018 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 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward declarations
56 class polyBoundaryMesh;
57 class polyPatch;
58 class polyTopoChange;
59 class PstreamBuffers;
60 
61 Ostream& operator<<(Ostream&, const polyPatch&);
62 
63 
64 /*---------------------------------------------------------------------------*\
65  Class polyPatch Declaration
66 \*---------------------------------------------------------------------------*/
67 
68 class polyPatch
69 :
70  public patchIdentifier,
71  public primitivePatch
72 {
73  // Private data
74 
75  //- Start label of this patch in the polyMesh face list
76  label start_;
77 
78  //- Reference to boundary mesh
79  const polyBoundaryMesh& boundaryMesh_;
80 
81 
82  // Demand-driven private data
83 
84  //- face-cell addressing
85  mutable labelList::subList* faceCellsPtr_;
86 
87  //- Global edge addressing
88  mutable labelList* mePtr_;
89 
90 
91 protected:
92 
93  // Protected Member Functions
94 
95  //- Inherit movePoints from primitivePatch
97 
98  // The polyPatch geometry initialisation is called by polyBoundaryMesh
99  friend class polyBoundaryMesh;
100 
101  //- Initialise the calculation of the patch geometry
102  virtual void initGeometry(PstreamBuffers&)
103  {}
104 
105  //- Calculate the patch geometry
106  virtual void calcGeometry(PstreamBuffers&)
107  {}
108 
109  //- Initialise the patches for moving points
110  virtual void initMovePoints(PstreamBuffers&, const pointField&)
111  {}
112 
113  //- Correct patches after moving points
114  virtual void movePoints(PstreamBuffers&, const pointField& p);
115 
116  //- Initialise the update of the patch topology
117  virtual void initUpdateMesh(PstreamBuffers&)
118  {}
119 
120  //- Update of the patch topology
121  virtual void updateMesh(PstreamBuffers&);
122 
123  //- Clear geometry
124  virtual void clearGeom();
125 
126 
127 public:
128 
129  //- Runtime type information
130  TypeName("patch");
131 
132  //- Debug switch to disallow the use of genericPolyPatch
133  static int disallowGenericPolyPatch;
134 
135 
136  // Declare run-time constructor selection tables
137 
139  (
140  autoPtr,
141  polyPatch,
142  word,
143  (
144  const word& name,
145  const label size,
146  const label start,
147  const label index,
148  const polyBoundaryMesh& bm,
149  const word& patchType
150  ),
151  (name, size, start, index, bm, patchType)
152  );
153 
155  (
156  autoPtr,
157  polyPatch,
158  dictionary,
159  (
160  const word& name,
161  const dictionary& dict,
162  const label index,
163  const polyBoundaryMesh& bm,
164  const word& patchType
165  ),
166  (name, dict, index, bm, patchType)
167  );
168 
169 
170  // Constructors
171 
172  //- Construct from components
173  polyPatch
174  (
175  const word& name,
176  const label size,
177  const label start,
178  const label index,
179  const polyBoundaryMesh& bm,
180  const word& patchType
181  );
182 
183  //- Construct from components
184  polyPatch
185  (
186  const word& name,
187  const label size,
188  const label start,
189  const label index,
190  const polyBoundaryMesh& bm,
191  const word& physicalType,
192  const wordList& inGroups
193  );
194 
195  //- Construct from dictionary
196  polyPatch
197  (
198  const word& name,
199  const dictionary& dict,
200  const label index,
201  const polyBoundaryMesh& bm,
202  const word& patchType
203  );
204 
205  //- Construct as copy, resetting the boundary mesh
206  polyPatch(const polyPatch&, const polyBoundaryMesh&);
207 
208  //- Construct given the original patch and resetting the
209  // face list and boundary mesh information
210  polyPatch
211  (
212  const polyPatch& pp,
213  const polyBoundaryMesh& bm,
214  const label index,
215  const label newSize,
216  const label newStart
217  );
218 
219  //- Construct given the original patch and a map
220  polyPatch
221  (
222  const polyPatch& pp,
223  const polyBoundaryMesh& bm,
224  const label index,
225  const labelUList& mapAddressing,
226  const label newStart
227  );
228 
229  //- Construct as copy
230  polyPatch(const polyPatch&);
231 
232  //- Construct and return a clone, resetting the boundary mesh
233  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
234  {
235  return autoPtr<polyPatch>::New(*this, bm);
236  }
237 
238  //- Construct and return a clone, resetting the face list
239  // and boundary mesh
241  (
242  const polyBoundaryMesh& bm,
243  const label index,
244  const label newSize,
245  const label newStart
246  ) const
247  {
248  return autoPtr<polyPatch>::New(*this, bm, index, newSize, newStart);
249  }
250 
251  //- Construct and return a clone, resetting the face list
252  // and boundary mesh
254  (
255  const polyBoundaryMesh& bm,
256  const label index,
257  const labelUList& mapAddressing,
258  const label newStart
259  ) const
260  {
262  (*this, bm, index, mapAddressing, newStart);
263  }
264 
265 
266  // Selectors
267 
268  //- Return a pointer to a new patch created on freestore from
269  // components
270  static autoPtr<polyPatch> New
271  (
272  const word& patchType,
273  const word& name,
274  const label size,
275  const label start,
276  const label index,
277  const polyBoundaryMesh& bm
278  );
279 
280  //- Return a pointer to a new patch created on freestore from
281  // dictionary
282  static autoPtr<polyPatch> New
283  (
284  const word& name,
285  const dictionary& dict,
286  const label index,
287  const polyBoundaryMesh& bm
288  );
289 
290  //- Return a pointer to a new patch created on freestore from
291  // dictionary
292  static autoPtr<polyPatch> New
293  (
294  const word& patchType,
295  const word& name,
296  const dictionary& dict,
297  const label index,
298  const polyBoundaryMesh& bm
299  );
300 
301 
302  //- Destructor
303  virtual ~polyPatch();
304 
305 
306  // Member Functions
307 
308  //- The offset where this patch starts in the boundary face list
309  // The value is the same as patch.start() - mesh.nInternalFaces()
310  label offset() const;
311 
312  //- Return start label of this patch in the polyMesh face list
313  label start() const
314  {
315  return start_;
316  }
317 
318  //- Return start/size range of this patch
319  labelRange range() const
320  {
321  return labelRange(start_, this->size());
322  }
323 
324  //- Return boundaryMesh reference
325  const polyBoundaryMesh& boundaryMesh() const;
326 
327  //- Return true if this patch is geometrically coupled (i.e. faces and
328  // points correspondence)
329  virtual bool coupled() const
330  {
331  return false;
332  }
333 
334  //- Return true if the given type is a constraint type
335  static bool constraintType(const word& pt);
336 
337  //- Return a list of all the constraint patch types
338  static wordList constraintTypes();
339 
340  //- Extract face cell data
341  template<class T>
343  (
344  const UList<T>& internalValues
345  ) const
346  {
347  return UIndirectList<T>(internalValues, faceCells());
348  }
349 
350  //- Slice list to patch
351  template<class T>
352  const typename List<T>::subList patchSlice(const UList<T>& l) const
353  {
354  return typename List<T>::subList(l, this->size(), start_);
355  }
356 
357  //- Slice Field to patch
358  template<class T>
359  const typename Field<T>::subField patchSlice(const Field<T>& l) const
360  {
361  return typename Field<T>::subField(l, this->size(), start_);
362  }
363 
364 
365  //- Write the polyPatch data as a dictionary
366  virtual void write(Ostream&) const;
367 
368 
369  // Geometric data; point list required
370 
371  //- Return face centres
372  const vectorField::subField faceCentres() const;
373 
374  //- Return face normals
375  const vectorField::subField faceAreas() const;
376 
377  //- Return face cell centres
379 
380  //- Return the area fraction as the ratio of the stored face area
381  //- and the area given by the face points
383 
384 
385  // Addressing into mesh
386 
387  //- Return face-cell addressing
388  const labelUList& faceCells() const;
389 
390  //- Return global edge index for local edges
391  const labelList& meshEdges() const;
392 
393  //- Clear addressing
394  virtual void clearAddressing();
395 
396 
397  // Other patch operations
398 
399  //- Return label of face in patch from global face label
400  inline label whichFace(const label l) const
401  {
402  return l - start_;
403  }
404 
405 
406  //- Initialize ordering for primitivePatch. Does not
407  // refer to *this (except for name() and type() etc.)
408  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
409 
410  //- Return new ordering for primitivePatch.
411  // Ordering is -faceMap: for every face
412  // index of the new face -rotation:for every new face the clockwise
413  // shift of the original face. Return false if nothing changes
414  // (faceMap is identity, rotation is 0), true otherwise.
415  virtual bool order
416  (
418  const primitivePatch&,
420  labelList& rotation
421  ) const;
422 
423  //- For dynamic mesh cases - return true if this patch will change the
424  //- topology
425  virtual bool changeTopology() const
426  {
427  return false;
428  }
429 
430  //- Collect topology changes in a polyTopoChange object
431  virtual bool setTopology(polyTopoChange&)
432  {
433  return false;
434  }
435 
436 
437  // Member operators
438 
439  //- Assignment
440  void operator=(const polyPatch&);
441 
442 
443  // Ostream Operator
444 
445  friend Ostream& operator<<(Ostream&, const polyPatch&);
446 };
447 
448 
449 // Global Functions
450 
451 //- The labelRange of a polyPatch
452 template<>
453 struct labelRangeOp<polyPatch>
454 {
455  labelRange operator()(const polyPatch& pp) const
456  {
457  return pp.range();
458  }
459 };
460 
461 
462 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
463 
464 } // End namespace Foam
465 
466 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
467 
468 #endif
469 
470 // ************************************************************************* //
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
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:59
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:88
Foam::polyPatch::changeTopology
virtual bool changeTopology() const
Definition: polyPatch.H:424
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:328
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:454
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:342
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:116
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:109
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:67
Foam::polyPatch::range
labelRange range() const
Return start/size range of this patch.
Definition: polyPatch.H:318
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:58
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:101
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:338
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:312
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:232
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:399
Foam::polyPatch::patchSlice
const List< T >::subList patchSlice(const UList< T > &l) const
Slice list to patch.
Definition: polyPatch.H:351
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:358
Foam::polyPatch::setTopology
virtual bool setTopology(polyTopoChange &)
Collect topology changes in a polyTopoChange object.
Definition: polyPatch.H:430
Foam::UIndirectList
A List with indirect addressing.
Definition: fvMatrix.H:109
Foam::Field::subField
SubField< Type > subField
Declare type of subField.
Definition: Field.H:90
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:105
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:132