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