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-2022 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  // The polyPatch geometry initialisation is called by polyBoundaryMesh
95  friend class polyBoundaryMesh;
96 
97  //- Initialise the calculation of the patch geometry
98  virtual void initCalcGeometry(PstreamBuffers&)
99  {}
100 
101  //- Calculate the patch geometry
102  virtual void calcGeometry(PstreamBuffers&)
103  {}
104 
105  //- Correct patches after moving points
106  virtual void movePoints(const pointField& p);
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 initTopoChange(PstreamBuffers&)
117  {}
118 
119  //- Update of the patch topology
120  virtual void topoChange(PstreamBuffers&);
121 
122  //- Clear geometry
123  virtual void clearGeom();
124 
125  //- Reset the patch name
126  virtual void rename(const wordList& newNames);
127 
128  //- Reset the patch index
129  virtual void reorder(const labelUList& newToOldIndex);
130 
131 
132 public:
133 
134  //- Runtime type information
135  TypeName("patch");
136 
137  //- Debug switch to disallow the use of genericPolyPatch
138  static int disallowGenericPolyPatch;
139 
140 
141  // Declare run-time constructor selection tables
142 
144  (
145  autoPtr,
146  polyPatch,
147  word,
148  (
149  const word& name,
150  const label size,
151  const label start,
152  const label index,
153  const polyBoundaryMesh& bm,
154  const word& patchType
155  ),
156  (name, size, start, index, bm, patchType)
157  );
158 
160  (
161  autoPtr,
162  polyPatch,
163  dictionary,
164  (
165  const word& name,
166  const dictionary& dict,
167  const label index,
168  const polyBoundaryMesh& bm,
169  const word& patchType
170  ),
171  (name, dict, index, bm, patchType)
172  );
173 
174 
175  // Constructors
176 
177  //- Construct from components
178  polyPatch
179  (
180  const word& name,
181  const label size,
182  const label start,
183  const label index,
184  const polyBoundaryMesh& bm,
185  const word& patchType
186  );
187 
188  //- Construct from dictionary
189  polyPatch
190  (
191  const word& name,
192  const dictionary& dict,
193  const label index,
194  const polyBoundaryMesh& bm,
195  const word& patchType
196  );
197 
198  //- Copy constructor, resetting the boundary mesh
199  polyPatch(const polyPatch&, const polyBoundaryMesh&);
200 
201  //- Construct given the original patch and resetting the
202  // face list and boundary mesh information
203  polyPatch
204  (
205  const polyPatch& pp,
206  const polyBoundaryMesh& bm,
207  const label index,
208  const label newSize,
209  const label newStart
210  );
211 
212  //- Construct given the original patch and a map
213  polyPatch
214  (
215  const polyPatch& pp,
216  const polyBoundaryMesh& bm,
217  const label index,
218  const labelUList& mapAddressing,
219  const label newStart
220  );
221 
222  //- Copy constructor
223  polyPatch(const polyPatch&);
224 
225  //- Construct and return a clone, resetting the boundary mesh
226  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
227  {
228  return autoPtr<polyPatch>(new polyPatch(*this, bm));
229  }
230 
231  //- Construct and return a clone, resetting the face list
232  // and boundary mesh
234  (
235  const polyBoundaryMesh& bm,
236  const label index,
237  const label newSize,
238  const label newStart
239  ) const
240  {
241  return autoPtr<polyPatch>
242  (
243  new polyPatch(*this, bm, index, newSize, newStart)
244  );
245  }
246 
247  //- Construct and return a clone, resetting the face list
248  // and boundary mesh
250  (
251  const polyBoundaryMesh& bm,
252  const label index,
253  const labelUList& mapAddressing,
254  const label newStart
255  ) const
256  {
257  return autoPtr<polyPatch>
258  (
259  new polyPatch(*this, bm, index, mapAddressing, newStart)
260  );
261  }
262 
263 
264  // Selectors
265 
266  //- Return a pointer to a new patch created on freestore from
267  // components
268  static autoPtr<polyPatch> New
269  (
270  const word& patchType,
271  const word& name,
272  const label size,
273  const label start,
274  const label index,
275  const polyBoundaryMesh& bm
276  );
277 
278  //- Return a pointer to a new patch created on freestore from
279  // dictionary
280  static autoPtr<polyPatch> New
281  (
282  const word& name,
283  const dictionary& dict,
284  const label index,
285  const polyBoundaryMesh& bm
286  );
287 
288  //- Return a pointer to a new patch created on freestore from
289  // dictionary
290  static autoPtr<polyPatch> New
291  (
292  const word& patchType,
293  const word& name,
294  const dictionary& dict,
295  const label index,
296  const polyBoundaryMesh& bm
297  );
298 
299 
300  //- Destructor
301  virtual ~polyPatch();
302 
303 
304  // Member Functions
305 
306  //- Return start label of this patch in the polyMesh face list
307  label start() const
308  {
309  return start_;
310  }
311 
312  //- Return boundaryMesh reference
313  const polyBoundaryMesh& boundaryMesh() const;
314 
315  //- Return true if this patch is geometrically coupled (i.e. faces and
316  // points correspondence)
317  virtual bool coupled() const
318  {
319  return false;
320  }
321 
322  //- Return true if the given type is a constraint type
323  static bool constraintType(const word& pt);
324 
325  //- Return a list of all the constraint patch types
326  static wordList constraintTypes();
327 
328  //- Extract face cell data
329  template<class T>
331  (
332  const UList<T>& internalValues
333  ) const
334  {
335  return UIndirectList<T>(internalValues, faceCells());
336  }
337 
338  //- Slice list to patch
339  template<class T>
340  const typename List<T>::subList patchSlice(const UList<T>& l) const
341  {
342  return typename List<T>::subList(l, this->size(), start_);
343  }
344 
345  //- Slice Field to patch
346  template<class T>
347  const typename Field<T>::subField patchSlice(const Field<T>& l) const
348  {
349  return typename Field<T>::subField(l, this->size(), start_);
350  }
351 
352 
353  //- Write the polyPatch data as a dictionary
354  virtual void write(Ostream&) const;
355 
356 
357  // Geometric data; point list required
358 
359  //- Return face centres
360  const vectorField::subField faceCentres() const;
361 
362  //- Return face areas
363  const vectorField::subField faceAreas() const;
364 
365  //- Return face area magnitudes
366  const scalarField::subField magFaceAreas() const;
367 
368  //- Return face cell centres
370 
371 
372  // Addressing into mesh
373 
374  //- Return face-cell addressing
375  const labelUList& faceCells() const;
376 
377  //- Return global edge index for local edges
378  const labelList& meshEdges() const;
379 
380  //- Clear addressing
381  virtual void clearAddressing();
382 
383 
384  // Other patch operations
385 
386  //- Return label of face in patch from global face label
387  inline label whichFace(const label l) const
388  {
389  return l - start_;
390  }
391 
392 
393  //- Initialise ordering for primitivePatch. Does not
394  // refer to *this (except for name() and type() etc.)
395  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
396 
397  //- Return new ordering for primitivePatch.
398  // Ordering is -faceMap: for every face
399  // index of the new face -rotation:for every new face the clockwise
400  // shift of the original face. Return false if nothing changes
401  // (faceMap is identity, rotation is 0), true otherwise.
402  virtual bool order
403  (
405  const primitivePatch&,
407  labelList& rotation
408  ) const;
409 
410 
411  // Member Operators
412 
413  //- Assignment
414  void operator=(const polyPatch&);
415 
416 
417  // Ostream Operator
418 
419  friend Ostream& operator<<(Ostream&, const polyPatch&);
420 };
421 
422 
423 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
424 
425 } // End namespace Foam
426 
427 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
428 
429 #endif
430 
431 // ************************************************************************* //
const UIndirectList< T > patchInternalList(const UList< T > &internalValues) const
Extract face cell data.
Definition: polyPatch.H:330
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
static int disallowGenericPolyPatch
Debug switch to disallow the use of genericPolyPatch.
Definition: polyPatch.H:137
Identifies patch by name, patch index and physical type.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:297
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:373
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
virtual void initTopoChange(PstreamBuffers &)
Initialise the update of the patch topology.
Definition: polyPatch.H:115
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual void clearGeom()
Clear geometry.
Definition: polyPatch.C:76
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: polyPatch.C:382
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
Definition: polyPatch.C:265
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:316
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:340
A class for handling words, derived from string.
Definition: word.H:59
virtual ~polyPatch()
Destructor.
Definition: polyPatch.C:257
virtual void rename(const wordList &newNames)
Reset the patch name.
Definition: polyPatch.C:82
virtual void reorder(const labelUList &newToOldIndex)
Reset the patch index.
Definition: polyPatch.C:88
tmp< vectorField > faceCellCentres() const
Return face cell centres.
Definition: polyPatch.C:321
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:97
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:410
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:309
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition: polyPatch.H:101
const labelList & meshEdges() const
Return global edge index for local edges.
Definition: polyPatch.C:354
Buffers for inter-processor communications streams (UOPstream, UIPstream).
virtual void topoChange(PstreamBuffers &)
Update of the patch topology.
Definition: polyPatch.C:69
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: polyPatch.C:271
autoPtr< PrimitivePatch< FaceList, PointField > > clone() const
Construct and return a clone.
virtual void movePoints(const pointField &p)
Correct patches after moving points.
Definition: polyPatch.C:57
const scalarField::subField magFaceAreas() const
Return face area magnitudes.
Definition: polyPatch.C:315
virtual void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: polyPatch.H:97
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: polyPatch.C:396
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:306
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
Initialise ordering for primitivePatch. Does not.
Definition: polyPatch.C:391
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:339
Namespace for OpenFOAM.
label whichFace(const label l) const
Return label of face in patch from global face label.
Definition: polyPatch.H:386
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:303