fvPatch.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2018 OpenFOAM Foundation
9  Copyright (C) 2020-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::fvPatch
29 
30 Description
31  A finiteVolume patch using a polyPatch and a fvBoundaryMesh
32 
33 SourceFiles
34  fvPatch.C
35  fvPatchNew.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_fvPatch_H
40 #define Foam_fvPatch_H
41 
42 #include "polyPatch.H"
43 #include "labelList.H"
44 #include "SubList.H"
45 #include "SubField.H"
46 #include "PtrList.H"
47 #include "typeInfo.H"
48 #include "autoPtr.H"
49 #include "tmp.H"
50 #include "primitiveFields.H"
51 #include "fvPatchFieldsFwd.H"
52 #include "runTimeSelectionTables.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 // Forward Declarations
60 class fvBoundaryMesh;
61 class fvPatch;
63 
64 //- Store lists of fvPatch as a PtrList
66 
67 /*---------------------------------------------------------------------------*\
68  Class fvPatch Declaration
69 \*---------------------------------------------------------------------------*/
70 
71 class fvPatch
72 {
73  // Private Data
74 
75  //- Reference to the underlying polyPatch
76  const polyPatch& polyPatch_;
77 
78  //- Reference to boundary mesh
79  const fvBoundaryMesh& boundaryMesh_;
80 
81 
82  // Private Member Functions
83 
84  //- No copy construct
85  fvPatch(const fvPatch&) = delete;
86 
87  //- No copy assignment
88  void operator=(const fvPatch&) = delete;
89 
90 
91 public:
92 
93  // Protected Member Functions
94 
95  //- Make patch weighting factors
96  virtual void makeWeights(scalarField&) const;
97 
98  //- Correct patch deltaCoeffs
99  virtual void makeDeltaCoeffs(scalarField&) const;
100 
101  //- Correct patch non-ortho deltaCoeffs
102  virtual void makeNonOrthoDeltaCoeffs(scalarField&) const;
103 
104  //- Correct patch non-ortho correction vectors
105  virtual void makeNonOrthoCorrVectors(vectorField&) const;
106 
107  //- Initialise the patches for moving points
108  virtual void initMovePoints();
109 
110  //- Correct patches after moving points
111  virtual void movePoints();
112 
113 
114 public:
115 
116  //- The boundary type associated with the patch
118 
119  friend class fvBoundaryMesh;
120  friend class surfaceInterpolation;
121 
122  //- Runtime type information
123  TypeName(polyPatch::typeName_());
124 
125 
126  // Declare run-time constructor selection tables
127 
129  (
130  autoPtr,
131  fvPatch,
132  polyPatch,
133  (const polyPatch& patch, const fvBoundaryMesh& bm),
134  (patch, bm)
135  );
137 
138  // Constructors
140  //- Construct from polyPatch and fvBoundaryMesh
141  fvPatch(const polyPatch&, const fvBoundaryMesh&);
142 
143 
144  // Selectors
145 
146  //- Return a pointer to a new patch created on freestore from polyPatch
147  static autoPtr<fvPatch> New
148  (
149  const polyPatch&,
150  const fvBoundaryMesh&
151  );
152 
153 
154  //- Destructor
155  virtual ~fvPatch();
156 
157 
158  // Member Functions
159 
160  //- Lookup the polyPatch index on corresponding fvMesh
161  // \note Fatal if the polyPatch is not associated with a fvMesh
162  static const fvPatch& lookupPatch(const polyPatch& p);
163 
164 
165  // Access
166 
167  //- Return the polyPatch
168  const polyPatch& patch() const noexcept
169  {
170  return polyPatch_;
171  }
172 
173  //- Return name
174  virtual const word& name() const
175  {
176  return polyPatch_.name();
177  }
178 
179  //- Return start label of this patch in the polyMesh face list
180  virtual label start() const
181  {
182  return polyPatch_.start();
183  }
184 
185  //- Return size
186  virtual label size() const
187  {
188  return polyPatch_.size();
189  }
190 
191  //- Return true if this patch is coupled
192  virtual bool coupled() const
193  {
194  return polyPatch_.coupled();
195  }
196 
197  //- Return true if the given type is a constraint type
198  static bool constraintType(const word& patchType);
199 
200  //- Return a list of all the constraint patch types
201  static wordList constraintTypes();
202 
203  //- Return the index of this patch in the fvBoundaryMesh
204  label index() const noexcept
205  {
206  return polyPatch_.index();
207  }
209  //- Return boundaryMesh reference
210  const fvBoundaryMesh& boundaryMesh() const noexcept
211  {
212  return boundaryMesh_;
213  }
214 
215  //- Slice List to patch, using the virtual patch size
216  template<class T>
217  const typename List<T>::subList patchSlice(const List<T>& l) const
218  {
219  return typename List<T>::subList(l, size(), start());
220  }
221 
222  //- Slice List to patch, using the underlying polyPatch information
223  template<class T>
225  (
226  const List<T>& l
227  ) const
228  {
229  return typename List<T>::subList
230  (
231  l,
232  polyPatch_.size(),
233  polyPatch_.start()
234  );
235  }
236 
237  //- Return faceCells
238  virtual const labelUList& faceCells() const;
239 
240 
241  // Access functions for geometrical data
242 
243  //- Return face centres
244  const vectorField& Cf() const;
245 
246  //- Return neighbour cell centres
247  tmp<vectorField> Cn() const;
248 
249  //- Return face area vectors
250  const vectorField& Sf() const;
251 
252  //- Return face area magnitudes
253  const scalarField& magSf() const;
254 
255  //- Return face normals
256  tmp<vectorField> nf() const;
257 
258  //- Return cell-centre to face-centre vector
259  //- except for coupled patches for which the cell-centre
260  //- to coupled-cell-centre vector is returned
261  virtual tmp<vectorField> delta() const;
262 
263 
264  // Access functions for demand driven data
265 
266  //- Return patch weighting factors
267  const scalarField& weights() const;
268 
269  //- Return the face - cell distance coefficient
270  //- except for coupled patches for which the cell-centre
271  //- to coupled-cell-centre distance coefficient is returned
272  const scalarField& deltaCoeffs() const;
273 
274 
275  // Evaluation Functions
276 
277  //- Extract internal field next to patch using faceCells mapping
278  template<class Type>
279  inline void patchInternalField
280  (
281  const UList<Type>& f,
282  const labelUList& faceCells,
283  Field<Type>& pfld
284  ) const;
285 
286  //- Return given internal field next to patch as patch field
287  template<class Type>
289 
290  //- Return given internal field next to patch as patch field
291  //- using provided addressing
292  template<class Type>
294  (
295  const UList<Type>& f,
296  const labelUList& faceCells
297  ) const;
298 
299  //- Return given internal field next to patch as patch field
300  template<class Type>
301  void patchInternalField(const UList<Type>&, Field<Type>&) const;
302 
303  //- Return the patch field of the GeometricField
304  //- corresponding to this patch.
305  template<class GeometricField, class AnyType = bool>
306  const typename GeometricField::Patch& patchField
307  (
308  const GeometricField& gf
309  ) const;
310 
311  //- Lookup the named field from the local registry and
312  //- return the patch field corresponding to this patch.
313  // N.B. The dummy pointer arguments are used if this function is
314  // instantiated within a templated function to avoid a bug in gcc.
315  template<class GeometricField, class AnyType = bool>
317  (
318  const word& name,
319  const GeometricField* = nullptr,
320  const AnyType* = nullptr
321  ) const;
322 };
323 
324 
325 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
326 
327 } // End namespace Foam
328 
329 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 
331 #ifdef NoRepository
332  #include "fvPatchTemplates.C"
333 #endif
334 
335 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
336 
337 #endif
338 
339 // ************************************************************************* //
const GeometricField::Patch & patchField(const GeometricField &gf) const
Return the patch field of the GeometricField corresponding to this patch.
virtual void initMovePoints()
Initialise the patches for moving points.
Definition: fvPatch.C:169
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:137
virtual label start() const
Return start label of this patch in the polyMesh face list.
Definition: fvPatch.H:216
static const fvPatch & lookupPatch(const polyPatch &p)
Lookup the polyPatch index on corresponding fvMesh.
Definition: fvPatch.C:42
tmp< vectorField > nf() const
Return face normals.
Definition: fvPatch.C:125
virtual ~fvPatch()
Destructor.
Definition: fvPatch.C:68
virtual void makeNonOrthoCorrVectors(vectorField &) const
Correct patch non-ortho correction vectors.
Definition: fvPatch.C:165
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:68
void patchInternalField(const UList< Type > &f, const labelUList &faceCells, Field< Type > &pfld) const
Extract internal field next to patch using faceCells mapping.
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
SubList< T > subList
Declare type of subList.
Definition: List.H:122
Cell to surface interpolation scheme. Included in fvMesh.
const GeometricField::Patch & lookupPatchField(const word &name, const GeometricField *=nullptr, const AnyType *=nullptr) const
Lookup the named field from the local registry and return the patch field corresponding to this patch...
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:52
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:56
declareRunTimeSelectionTable(autoPtr, fvPatch, polyPatch,(const polyPatch &patch, const fvBoundaryMesh &bm),(patch, bm))
virtual void makeNonOrthoDeltaCoeffs(scalarField &) const
Correct patch non-ortho deltaCoeffs.
Definition: fvPatch.C:161
A List obtained as a section of another List.
Definition: SubList.H:50
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:464
fvBoundaryMesh BoundaryMesh
The boundary type associated with the patch.
Definition: fvPatch.H:136
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual const labelUList & faceCells() const
Return faceCells.
Definition: fvPatch.C:107
const scalarField & weights() const
Return patch weighting factors.
Definition: fvPatch.C:183
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: fvPatch.C:151
const vectorField & Cf() const
Return face centres.
Definition: fvPatch.C:113
const List< T >::subList patchRawSlice(const List< T > &l) const
Slice List to patch, using the underlying polyPatch information.
Definition: fvPatch.H:277
const fvBoundaryMesh & boundaryMesh() const noexcept
Return boundaryMesh reference.
Definition: fvPatch.H:258
virtual label size() const
Return size.
Definition: fvPatch.H:224
const word & name() const noexcept
The patch name.
const direction noexcept
Definition: Scalar.H:258
labelList f(nPoints)
TypeName(polyPatch::typeName_())
Runtime type information.
static bool constraintType(const word &patchType)
Return true if the given type is a constraint type.
Definition: fvPatch.C:74
const vectorField & Sf() const
Return face area vectors.
Definition: fvPatch.C:131
const List< T >::subList patchSlice(const List< T > &l) const
Slice List to patch, using the virtual patch size.
Definition: fvPatch.H:267
Specialisations of Field<T> for scalar, vector and tensor.
const scalarField & deltaCoeffs() const
Return the face - cell distance coefficient except for coupled patches for which the cell-centre to c...
Definition: fvPatch.C:177
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
Foam::fvBoundaryMesh.
tmp< vectorField > Cn() const
Return neighbour cell centres.
Definition: fvPatch.C:119
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:441
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
virtual const word & name() const
Return name.
Definition: fvPatch.H:208
static autoPtr< fvPatch > New(const polyPatch &, const fvBoundaryMesh &)
Return a pointer to a new patch created on freestore from polyPatch.
Definition: fvPatchNew.C:28
Macros to ease declaration of run-time selection tables.
label index() const noexcept
The index of this patch in the boundaryMesh.
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
const polyPatch & patch() const noexcept
Return the polyPatch.
Definition: fvPatch.H:200
label index() const noexcept
Return the index of this patch in the fvBoundaryMesh.
Definition: fvPatch.H:250
virtual bool coupled() const
Return true if this patch is coupled.
Definition: fvPatch.H:232
virtual tmp< vectorField > delta() const
Return cell-centre to face-centre vector except for coupled patches for which the cell-centre to coup...
Definition: fvPatch.C:143
virtual void movePoints()
Correct patches after moving points.
Definition: fvPatch.C:173
Namespace for OpenFOAM.
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: fvPatch.C:85
PtrList< fvPatch > fvPatchList
Store lists of fvPatch as a PtrList.
Definition: fvPatch.H:57
virtual void makeDeltaCoeffs(scalarField &) const
Correct patch deltaCoeffs.
Definition: fvPatch.C:157