polyPatch.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 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 initCalcGeometry(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  //- Copy constructor, 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  //- Copy constructor
217  polyPatch(const polyPatch&);
218 
219  // To avoid irritating warnings from clang
220  using primitivePatch::clone;
221 
222  //- Construct and return a clone, resetting the boundary mesh
223  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
224  {
225  return autoPtr<polyPatch>(new polyPatch(*this, bm));
226  }
227 
228  //- Construct and return a clone, resetting the face list
229  // and boundary mesh
231  (
232  const polyBoundaryMesh& bm,
233  const label index,
234  const label newSize,
235  const label newStart
236  ) const
237  {
238  return autoPtr<polyPatch>
239  (
240  new polyPatch(*this, bm, index, newSize, newStart)
241  );
242  }
243 
244  //- Construct and return a clone, resetting the face list
245  // and boundary mesh
247  (
248  const polyBoundaryMesh& bm,
249  const label index,
250  const labelUList& mapAddressing,
251  const label newStart
252  ) const
253  {
254  return autoPtr<polyPatch>
255  (
256  new polyPatch(*this, bm, index, mapAddressing, newStart)
257  );
258  }
259 
260 
261  // Selectors
262 
263  //- Return a pointer to a new patch created on freestore from
264  // components
265  static autoPtr<polyPatch> New
266  (
267  const word& patchType,
268  const word& name,
269  const label size,
270  const label start,
271  const label index,
272  const polyBoundaryMesh& bm
273  );
274 
275  //- Return a pointer to a new patch created on freestore from
276  // dictionary
277  static autoPtr<polyPatch> New
278  (
279  const word& name,
280  const dictionary& dict,
281  const label index,
282  const polyBoundaryMesh& bm
283  );
284 
285  //- Return a pointer to a new patch created on freestore from
286  // dictionary
287  static autoPtr<polyPatch> New
288  (
289  const word& patchType,
290  const word& name,
291  const dictionary& dict,
292  const label index,
293  const polyBoundaryMesh& bm
294  );
295 
296 
297  //- Destructor
298  virtual ~polyPatch();
299 
300 
301  // Member Functions
302 
303  //- Return start label of this patch in the polyMesh face list
304  label start() const
305  {
306  return start_;
307  }
308 
309  //- Return boundaryMesh reference
310  const polyBoundaryMesh& boundaryMesh() const;
311 
312  //- Return true if this patch is geometrically coupled (i.e. faces and
313  // points correspondence)
314  virtual bool coupled() const
315  {
316  return false;
317  }
318 
319  //- Return true if the given type is a constraint type
320  static bool constraintType(const word& pt);
321 
322  //- Return a list of all the constraint patch types
323  static wordList constraintTypes();
324 
325  //- Extract face cell data
326  template<class T>
328  (
329  const UList<T>& internalValues
330  ) const
331  {
332  return UIndirectList<T>(internalValues, faceCells());
333  }
334 
335  //- Slice list to patch
336  template<class T>
337  const typename List<T>::subList patchSlice(const UList<T>& l) const
338  {
339  return typename List<T>::subList(l, this->size(), start_);
340  }
341 
342  //- Slice Field to patch
343  template<class T>
344  const typename Field<T>::subField patchSlice(const Field<T>& l) const
345  {
346  return typename Field<T>::subField(l, this->size(), start_);
347  }
348 
349 
350  //- Write the polyPatch data as a dictionary
351  virtual void write(Ostream&) const;
352 
353 
354  // Geometric data; point list required
355 
356  //- Return face centres
357  const vectorField::subField faceCentres() const;
358 
359  //- Return face areas
360  const vectorField::subField faceAreas() const;
361 
362  //- Return face area magnitudes
363  const scalarField::subField magFaceAreas() const;
364 
365  //- Return face cell centres
367 
368 
369  // Addressing into mesh
370 
371  //- Return face-cell addressing
372  const labelUList& faceCells() const;
373 
374  //- Return global edge index for local edges
375  const labelList& meshEdges() const;
376 
377  //- Clear addressing
378  virtual void clearAddressing();
379 
380 
381  // Other patch operations
382 
383  //- Return label of face in patch from global face label
384  inline label whichFace(const label l) const
385  {
386  return l - start_;
387  }
388 
389 
390  //- Initialize ordering for primitivePatch. Does not
391  // refer to *this (except for name() and type() etc.)
392  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
393 
394  //- Return new ordering for primitivePatch.
395  // Ordering is -faceMap: for every face
396  // index of the new face -rotation:for every new face the clockwise
397  // shift of the original face. Return false if nothing changes
398  // (faceMap is identity, rotation is 0), true otherwise.
399  virtual bool order
400  (
402  const primitivePatch&,
404  labelList& rotation
405  ) const;
406 
407 
408  // Member Operators
409 
410  //- Assignment
411  void operator=(const polyPatch&);
412 
413 
414  // Ostream Operator
415 
416  friend Ostream& operator<<(Ostream&, const polyPatch&);
417 };
418 
419 
420 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
421 
422 } // End namespace Foam
423 
424 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
425 
426 #endif
427 
428 // ************************************************************************* //
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:327
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
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:199
virtual void clearAddressing()
Clear addressing.
Definition: polyPatch.C:354
virtual autoPtr< PrimitivePatch< FaceList, PointField > > clone() const
Construct and return a clone.
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Definition: polyPatch.H:108
Pre-declare related SubField type.
Definition: Field.H:60
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:363
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
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:313
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:321
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:302
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:60
void operator=(const polyPatch &)
Assignment.
Definition: polyPatch.C:391
Foam::polyBoundaryMesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
const vectorField::subField faceAreas() const
Return face areas.
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:335
Buffers for inter-processor communications streams (UOPstream, UIPstream).
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: polyPatch.C:252
const scalarField::subField magFaceAreas() const
Return face area magnitudes.
Definition: polyPatch.C:296
virtual void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: polyPatch.H:100
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: polyPatch.C:377
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:303
Ostream & operator<<(Ostream &, const ensightPart &)
SubField< Type > subField
Declare type of subField.
Definition: Field.H:100
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:372
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:336
Namespace for OpenFOAM.
label whichFace(const label l) const
Return label of face in patch from global face label.
Definition: polyPatch.H:383
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:284