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