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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::polyPatch
26 
27 Description
28  A patch is a list of labels that address the faces in the global face list.
29 
30  The patch can calculate its own edges based on the global faces.
31  Patch also contains all addressing between the faces.
32 
33 SourceFiles
34  polyPatch.C
35  polyPatchNew.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef polyPatch_H
40 #define polyPatch_H
41 
42 #include "patchIdentifier.H"
43 #include "primitivePatch.H"
44 #include "typeInfo.H"
45 #include "runTimeSelectionTables.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 // Forward declaration of friend functions and operators
55 
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
79 
80 
81  // Demand-driven private data
82 
83  //- face-cell addressing
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 polyPatch(*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>
248  (
249  new polyPatch(*this, bm, index, newSize, newStart)
250  );
251  }
252 
253  //- Construct and return a clone, resetting the face list
254  // and boundary mesh
256  (
257  const polyBoundaryMesh& bm,
258  const label index,
259  const labelUList& mapAddressing,
260  const label newStart
261  ) const
262  {
263  return autoPtr<polyPatch>
264  (
265  new polyPatch(*this, bm, index, mapAddressing, newStart)
266  );
267  }
268 
269 
270  // Selectors
271 
272  //- Return a pointer to a new patch created on freestore from
273  // components
274  static autoPtr<polyPatch> New
275  (
276  const word& patchType,
277  const word& name,
278  const label size,
279  const label start,
280  const label index,
281  const polyBoundaryMesh& bm
282  );
283 
284  //- Return a pointer to a new patch created on freestore from
285  // dictionary
286  static autoPtr<polyPatch> New
287  (
288  const word& name,
289  const dictionary& dict,
290  const label index,
291  const polyBoundaryMesh& bm
292  );
293 
294  //- Return a pointer to a new patch created on freestore from
295  // dictionary
296  static autoPtr<polyPatch> New
297  (
298  const word& patchType,
299  const word& name,
300  const dictionary& dict,
301  const label index,
302  const polyBoundaryMesh& bm
303  );
304 
305 
306  //- Destructor
307  virtual ~polyPatch();
308 
309 
310  // Member Functions
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 boundaryMesh reference
319  const polyBoundaryMesh& boundaryMesh() const;
320 
321  //- Return true if this patch is geometrically coupled (i.e. faces and
322  // points correspondence)
323  virtual bool coupled() const
324  {
325  return false;
326  }
327 
328  //- Return true if the given type is a constraint type
329  static bool constraintType(const word& pt);
330 
331  //- Return a list of all the constraint patch types
332  static wordList constraintTypes();
333 
334  //- Extract face cell data
335  template<class T>
337  (
338  const UList<T>& internalValues
339  ) const
340  {
341  return UIndirectList<T>(internalValues, faceCells());
342  }
343 
344  //- Slice list to patch
345  template<class T>
346  const typename List<T>::subList patchSlice(const UList<T>& l) const
347  {
348  return typename List<T>::subList(l, this->size(), start_);
349  }
350 
351  //- Slice Field to patch
352  template<class T>
353  const typename Field<T>::subField patchSlice(const Field<T>& l) const
354  {
355  return typename Field<T>::subField(l, this->size(), start_);
356  }
357 
358 
359  //- Write the polyPatch data as a dictionary
360  virtual void write(Ostream&) const;
361 
362 
363  // Geometric data; point list required
364 
365  //- Return face centres
366  const vectorField::subField faceCentres() const;
367 
368  //- Return face normals
369  const vectorField::subField faceAreas() const;
370 
371  //- Return face cell centres
373 
374 
375  // Addressing into mesh
376 
377  //- Return face-cell addressing
378  const labelUList& faceCells() const;
379 
380  //- Return global edge index for local edges
381  const labelList& meshEdges() const;
382 
383  //- Clear addressing
384  virtual void clearAddressing();
385 
386 
387  // Other patch operations
388 
389  //- Return label of face in patch from global face label
390  inline label whichFace(const label l) const
391  {
392  return l - start_;
393  }
394 
395 
396  //- Initialize ordering for primitivePatch. Does not
397  // refer to *this (except for name() and type() etc.)
398  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
399 
400  //- Return new ordering for primitivePatch.
401  // Ordering is -faceMap: for every face
402  // index of the new face -rotation:for every new face the clockwise
403  // shift of the original face. Return false if nothing changes
404  // (faceMap is identity, rotation is 0), true otherwise.
405  virtual bool order
406  (
408  const primitivePatch&,
410  labelList& rotation
411  ) const;
412 
413 
414  // Member operators
415 
416  //- Assignment
417  void operator=(const polyPatch&);
418 
419 
420  // Ostream Operator
421 
422  friend Ostream& operator<<(Ostream&, const polyPatch&);
423 };
424 
425 
426 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
427 
428 } // End namespace Foam
429 
430 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
431 
432 #endif
433 
434 // ************************************************************************* //
Foam::polyPatch::TypeName
TypeName("patch")
Runtime type information.
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:90
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::polyPatch::movePoints
virtual void movePoints(PstreamBuffers &, const pointField &p)
Correct patches after moving points.
Definition: polyPatch.C:57
typeInfo.H
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
Foam::polyPatch::operator<<
friend Ostream & operator<<(Ostream &, const polyPatch &)
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::polyPatch::clearAddressing
virtual void clearAddressing()
Clear addressing.
Definition: polyPatch.C:373
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:85
Foam::polyPatch::clearGeom
virtual void clearGeom()
Clear geometry.
Definition: polyPatch.C:69
Foam::polyPatch::coupled
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:322
Foam::polyPatch::write
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: polyPatch.C:382
Foam::polyPatch::start_
label start_
Start label of this patch in the polyMesh face list.
Definition: polyPatch.H:74
Foam::polyPatch::updateMesh
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: polyPatch.C:62
Foam::polyPatch::boundaryMesh_
const polyBoundaryMesh & boundaryMesh_
Reference to boundary mesh.
Definition: polyPatch.H:77
Foam::polyPatch::patchInternalList
const UIndirectList< T > patchInternalList(const UList< T > &internalValues) const
Extract face cell data.
Definition: polyPatch.H:336
Foam::SubField
Pre-declare related SubField type.
Definition: Field.H:61
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:54
Foam::polyPatch::initUpdateMesh
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition: polyPatch.H:115
Foam::patchIdentifier
Identifies 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:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::polyPatch::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:302
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
Return the optional groups patch belongs to.
Definition: patchIdentifier.H:145
Foam::polyPatch::operator=
void operator=(const polyPatch &)
Assignment.
Definition: polyPatch.C:410
Foam::polyPatch::faceCellsPtr_
labelList::subList * faceCellsPtr_
face-cell addressing
Definition: polyPatch.H:83
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::patchIdentifier::physicalType
const word & physicalType() const
Return the optional physical type of the patch.
Definition: patchIdentifier.H:121
Foam::polyPatch::order
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: polyPatch.C:396
Foam::PrimitivePatch::movePoints
virtual void movePoints(const Field< PointType > &)
Correct patch after moving points.
Definition: PrimitivePatchTemplate.C:187
Foam::polyPatch::initGeometry
virtual void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: polyPatch.H:100
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
Foam::polyPatch::constraintTypes
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: polyPatch.C:276
Foam::polyPatch::constraintType
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
Definition: polyPatch.C:270
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::List::subList
SubList< T > subList
Declare type of subList.
Definition: List.H:153
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
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:32
Foam::polyPatch::initOrder
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: polyPatch.C:391
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::polyPatch::faceCells
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:340
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:262
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:321
patchIdentifier.H
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
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:78
Foam::polyPatch::whichFace
label whichFace(const label l) const
Return label of face in patch from global face label.
Definition: polyPatch.H:389
Foam::polyPatch::patchSlice
const List< T >::subList patchSlice(const UList< T > &l) const
Slice list to patch.
Definition: polyPatch.H:345
Foam::polyPatch::faceCentres
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:308
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::polyPatch::faceAreas
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:314
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
Foam::polyPatch::mePtr_
labelList * mePtr_
Global edge addressing.
Definition: polyPatch.H:86
Foam::polyPatch::patchSlice
const Field< T >::subField patchSlice(const Field< T > &l) const
Slice Field to patch.
Definition: polyPatch.H:352
Foam::UIndirectList< T >
Foam::Field::subField
SubField< Type > subField
Declare type of subField.
Definition: Field.H:89
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
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:354
Foam::patchIdentifier::name
const word & name() const
Return name.
Definition: patchIdentifier.H:109
Foam::patchIdentifier::index
label index() const
Return the index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:133
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88
Foam::polyPatch::disallowGenericPolyPatch
static int disallowGenericPolyPatch
Debug switch to disallow the use of genericPolyPatch.
Definition: polyPatch.H:131