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-2021 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  //- 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  // To avoid irritating warnings from clang
226  using primitivePatch::clone;
227 
228  //- Construct and return a clone, resetting the boundary mesh
229  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
230  {
231  return autoPtr<polyPatch>(new polyPatch(*this, bm));
232  }
233 
234  //- Construct and return a clone, resetting the face list
235  // and boundary mesh
237  (
238  const polyBoundaryMesh& bm,
239  const label index,
240  const label newSize,
241  const label newStart
242  ) const
243  {
244  return autoPtr<polyPatch>
245  (
246  new polyPatch(*this, bm, index, newSize, newStart)
247  );
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  {
260  return autoPtr<polyPatch>
261  (
262  new polyPatch(*this, bm, index, mapAddressing, newStart)
263  );
264  }
265 
266 
267  // Selectors
268 
269  //- Return a pointer to a new patch created on freestore from
270  // components
271  static autoPtr<polyPatch> New
272  (
273  const word& patchType,
274  const word& name,
275  const label size,
276  const label start,
277  const label index,
278  const polyBoundaryMesh& bm
279  );
280 
281  //- Return a pointer to a new patch created on freestore from
282  // dictionary
283  static autoPtr<polyPatch> New
284  (
285  const word& name,
286  const dictionary& dict,
287  const label index,
288  const polyBoundaryMesh& bm
289  );
290 
291  //- Return a pointer to a new patch created on freestore from
292  // dictionary
293  static autoPtr<polyPatch> New
294  (
295  const word& patchType,
296  const word& name,
297  const dictionary& dict,
298  const label index,
299  const polyBoundaryMesh& bm
300  );
301 
302 
303  //- Destructor
304  virtual ~polyPatch();
305 
306 
307  // Member Functions
308 
309  //- Return start label of this patch in the polyMesh face list
310  label start() const
311  {
312  return start_;
313  }
314 
315  //- Return boundaryMesh reference
316  const polyBoundaryMesh& boundaryMesh() const;
317 
318  //- Return true if this patch is geometrically coupled (i.e. faces and
319  // points correspondence)
320  virtual bool coupled() const
321  {
322  return false;
323  }
324 
325  //- Return true if the given type is a constraint type
326  static bool constraintType(const word& pt);
327 
328  //- Return a list of all the constraint patch types
329  static wordList constraintTypes();
330 
331  //- Extract face cell data
332  template<class T>
334  (
335  const UList<T>& internalValues
336  ) const
337  {
338  return UIndirectList<T>(internalValues, faceCells());
339  }
340 
341  //- Slice list to patch
342  template<class T>
343  const typename List<T>::subList patchSlice(const UList<T>& l) const
344  {
345  return typename List<T>::subList(l, this->size(), start_);
346  }
347 
348  //- Slice Field to patch
349  template<class T>
350  const typename Field<T>::subField patchSlice(const Field<T>& l) const
351  {
352  return typename Field<T>::subField(l, this->size(), start_);
353  }
354 
355 
356  //- Write the polyPatch data as a dictionary
357  virtual void write(Ostream&) const;
358 
359 
360  // Geometric data; point list required
361 
362  //- Return face centres
363  const vectorField::subField faceCentres() const;
364 
365  //- Return face areas
366  const vectorField::subField faceAreas() const;
367 
368  //- Return face area magnitudes
369  const scalarField::subField magFaceAreas() 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  //- Initialise 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 // ************************************************************************* //
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:333
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
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:291
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:367
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:70
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: polyPatch.C:376
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:259
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:319
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:334
A class for handling words, derived from string.
Definition: word.H:59
virtual ~polyPatch()
Destructor.
Definition: polyPatch.C:251
virtual void rename(const wordList &newNames)
Reset the patch name.
Definition: polyPatch.C:76
virtual void reorder(const labelUList &newToOldIndex)
Reset the patch index.
Definition: polyPatch.C:82
tmp< vectorField > faceCellCentres() const
Return face cell centres.
Definition: polyPatch.C:315
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: polyPatch.C:63
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:91
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:404
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:303
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:348
Buffers for inter-processor communications streams (UOPstream, UIPstream).
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: polyPatch.C:265
const scalarField::subField magFaceAreas() const
Return face area magnitudes.
Definition: polyPatch.C:309
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:390
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:309
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:385
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:342
Namespace for OpenFOAM.
label whichFace(const label l) const
Return label of face in patch from global face label.
Definition: polyPatch.H:389
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:297