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 |
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
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 dictionary
183  polyPatch
184  (
185  const word& name,
186  const dictionary& dict,
187  const label index,
188  const polyBoundaryMesh& bm,
189  const word& patchType
190  );
191 
192  //- Construct as copy, resetting the boundary mesh
193  polyPatch(const polyPatch&, const polyBoundaryMesh&);
194 
195  //- Construct given the original patch and resetting the
196  // face list and boundary mesh information
197  polyPatch
198  (
199  const polyPatch& pp,
200  const polyBoundaryMesh& bm,
201  const label index,
202  const label newSize,
203  const label newStart
204  );
205 
206  //- Construct given the original patch and a map
207  polyPatch
208  (
209  const polyPatch& pp,
210  const polyBoundaryMesh& bm,
211  const label index,
212  const labelUList& mapAddressing,
213  const label newStart
214  );
215 
216  //- Construct as copy
217  polyPatch(const polyPatch&);
218 
219  //- Construct and return a clone, resetting the boundary mesh
220  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
221  {
222  return autoPtr<polyPatch>(new polyPatch(*this, bm));
223  }
224 
225  //- Construct and return a clone, resetting the face list
226  // and boundary mesh
228  (
229  const polyBoundaryMesh& bm,
230  const label index,
231  const label newSize,
232  const label newStart
233  ) const
234  {
235  return autoPtr<polyPatch>
236  (
237  new polyPatch(*this, bm, index, newSize, newStart)
238  );
239  }
240 
241  //- Construct and return a clone, resetting the face list
242  // and boundary mesh
244  (
245  const polyBoundaryMesh& bm,
246  const label index,
247  const labelUList& mapAddressing,
248  const label newStart
249  ) const
250  {
251  return autoPtr<polyPatch>
252  (
253  new polyPatch(*this, bm, index, mapAddressing, newStart)
254  );
255  }
256 
257 
258  // Selectors
259 
260  //- Return a pointer to a new patch created on freestore from
261  // components
262  static autoPtr<polyPatch> New
263  (
264  const word& patchType,
265  const word& name,
266  const label size,
267  const label start,
268  const label index,
269  const polyBoundaryMesh& bm
270  );
271 
272  //- Return a pointer to a new patch created on freestore from
273  // dictionary
274  static autoPtr<polyPatch> New
275  (
276  const word& name,
277  const dictionary& dict,
278  const label index,
279  const polyBoundaryMesh& bm
280  );
281 
282  //- Return a pointer to a new patch created on freestore from
283  // dictionary
284  static autoPtr<polyPatch> New
285  (
286  const word& patchType,
287  const word& name,
288  const dictionary& dict,
289  const label index,
290  const polyBoundaryMesh& bm
291  );
292 
293 
294  //- Destructor
295  virtual ~polyPatch();
296 
297 
298  // Member Functions
299 
300  //- Return start label of this patch in the polyMesh face list
301  label start() const
302  {
303  return start_;
304  }
305 
306  //- Return boundaryMesh reference
307  const polyBoundaryMesh& boundaryMesh() const;
308 
309  //- Return true if this patch is geometrically coupled (i.e. faces and
310  // points correspondence)
311  virtual bool coupled() const
312  {
313  return false;
314  }
315 
316  //- Return true if the given type is a constraint type
317  static bool constraintType(const word& pt);
318 
319  //- Return a list of all the constraint patch types
320  static wordList constraintTypes();
321 
322  //- Extract face cell data
323  template<class T>
325  (
326  const UList<T>& internalValues
327  ) const
328  {
329  return UIndirectList<T>(internalValues, faceCells());
330  }
331 
332  //- Slice list to patch
333  template<class T>
334  const typename List<T>::subList patchSlice(const UList<T>& l) const
335  {
336  return typename List<T>::subList(l, this->size(), start_);
337  }
338 
339  //- Slice Field to patch
340  template<class T>
341  const typename Field<T>::subField patchSlice(const Field<T>& l) const
342  {
343  return typename Field<T>::subField(l, this->size(), start_);
344  }
345 
346 
347  //- Write the polyPatch data as a dictionary
348  virtual void write(Ostream&) const;
349 
350 
351  // Geometric data; point list required
352 
353  //- Return face centres
354  const vectorField::subField faceCentres() const;
355 
356  //- Return face normals
357  const vectorField::subField faceAreas() const;
358 
359  //- Return face cell centres
361 
362 
363  // Addressing into mesh
364 
365  //- Return face-cell addressing
366  const labelUList& faceCells() const;
367 
368  //- Return global edge index for local edges
369  const labelList& meshEdges() const;
370 
371  //- Clear addressing
372  virtual void clearAddressing();
373 
374 
375  // Other patch operations
376 
377  //- Return label of face in patch from global face label
378  inline label whichFace(const label l) const
379  {
380  return l - start_;
381  }
382 
383 
384  //- Initialize ordering for primitivePatch. Does not
385  // refer to *this (except for name() and type() etc.)
386  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
387 
388  //- Return new ordering for primitivePatch.
389  // Ordering is -faceMap: for every face
390  // index of the new face -rotation:for every new face the clockwise
391  // shift of the original face. Return false if nothing changes
392  // (faceMap is identity, rotation is 0), true otherwise.
393  virtual bool order
394  (
396  const primitivePatch&,
398  labelList& rotation
399  ) const;
400 
401 
402  // Member operators
403 
404  //- Assignment
405  void operator=(const polyPatch&);
406 
407 
408  // Ostream Operator
409 
410  friend Ostream& operator<<(Ostream&, const polyPatch&);
411 };
412 
413 
414 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
415 
416 } // End namespace Foam
417 
418 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
419 
420 #endif
421 
422 // ************************************************************************* //
virtual void movePoints(const Field< PointType > &)
Correct patch after moving points.
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
const UIndirectList< T > patchInternalList(const UList< T > &internalValues) const
Extract face cell data.
Definition: polyPatch.H:324
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
static int disallowGenericPolyPatch
Debug switch to disallow the use of genericPolyPatch.
Definition: polyPatch.H:131
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition: polyPatch.H:115
Identifies patch by name, patch index and physical type.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:278
friend Ostream & operator<<(Ostream &, const polyPatch &)
SubList< T > subList
Declare type of subList.
Definition: List.H:192
virtual void clearAddressing()
Clear addressing.
Definition: polyPatch.C:348
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Definition: polyPatch.H:108
Pre-declare related SubField type.
Definition: Field.H:61
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual void clearGeom()
Clear geometry.
Definition: polyPatch.C:69
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: polyPatch.C:357
virtual void movePoints(PstreamBuffers &, const pointField &p)
Correct patches after moving points.
Definition: polyPatch.C:57
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
Definition: polyPatch.C:246
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
Definition: polyPatch.H:219
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))
A list of faces which address into the list of points.
A List obtained as a section of another List.
Definition: SubList.H:53
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:310
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:315
A class for handling words, derived from string.
Definition: word.H:59
virtual ~polyPatch()
Destructor.
Definition: polyPatch.C:238
tmp< vectorField > faceCellCentres() const
Return face cell centres.
Definition: polyPatch.C:296
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: polyPatch.C:62
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
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:61
void operator=(const polyPatch &)
Assignment.
Definition: polyPatch.C:385
Foam::polyBoundaryMesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:290
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition: polyPatch.H:104
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: polyPatch.C:329
Buffers for inter-processor communications streams (UOPstream, UIPstream).
virtual void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: polyPatch.H:100
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: polyPatch.C:252
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: polyPatch.C:371
A List with indirect addressing.
Definition: fvMatrix.H:106
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:300
Ostream & operator<<(Ostream &, const ensightPart &)
SubField< Type > subField
Declare type of subField.
Definition: Field.H:89
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
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
TypeName("patch")
Runtime type information.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: polyPatch.C:366
Macros to ease declaration of run-time selection tables.
A class for managing temporary objects.
Definition: PtrList.H:53
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
const List< T >::subList patchSlice(const UList< T > &l) const
Slice list to patch.
Definition: polyPatch.H:333
Namespace for OpenFOAM.
label whichFace(const label l) const
Return label of face in patch from global face label.
Definition: polyPatch.H:377
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:284