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 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 fvPatch_H
40 #define fvPatch_H
41 
42 #include "polyPatch.H"
43 #include "labelList.H"
44 #include "SubList.H"
45 #include "typeInfo.H"
46 #include "tmp.H"
47 #include "primitiveFields.H"
48 #include "SubField.H"
49 #include "fvPatchFieldsFwd.H"
50 #include "autoPtr.H"
51 #include "runTimeSelectionTables.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 // Forward Declarations
59 class fvBoundaryMesh;
60 class surfaceInterpolation;
61 
62 /*---------------------------------------------------------------------------*\
63  Class fvPatch Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class fvPatch
67 {
68  // Private Data
69 
70  //- Reference to the underlying polyPatch
71  const polyPatch& polyPatch_;
72 
73  //- Reference to boundary mesh
74  const fvBoundaryMesh& boundaryMesh_;
75 
76 
77  // Private Member Functions
78 
79  //- No copy construct
80  fvPatch(const fvPatch&) = delete;
81 
82  //- No copy assignment
83  void operator=(const fvPatch&) = delete;
84 
85 
86 public:
87 
88  // Protected Member Functions
89 
90  //- Make patch weighting factors
91  virtual void makeWeights(scalarField&) const;
92 
93  //- Correct patch deltaCoeffs
94  virtual void makeDeltaCoeffs(scalarField&) const;
95 
96  //- Correct patch non-ortho deltaCoeffs
97  virtual void makeNonOrthoDeltaCoeffs(scalarField&) const;
98 
99  //- Correct patch non-ortho correction vectors
100  virtual void makeNonOrthoCorrVectors(vectorField&) const;
101 
102  //- Initialise the patches for moving points
103  virtual void initMovePoints();
104 
105  //- Correct patches after moving points
106  virtual void movePoints();
107 
108 
109 public:
110 
112 
113  friend class fvBoundaryMesh;
114  friend class surfaceInterpolation;
115 
116  //- Runtime type information
117  TypeName(polyPatch::typeName_());
118 
119 
120  // Declare run-time constructor selection tables
121 
123  (
124  autoPtr,
125  fvPatch,
126  polyPatch,
127  (const polyPatch& patch, const fvBoundaryMesh& bm),
128  (patch, bm)
129  );
130 
131 
132  // Constructors
133 
134  //- Construct from polyPatch and fvBoundaryMesh
135  fvPatch(const polyPatch&, const fvBoundaryMesh&);
136 
137 
138  // Selectors
139 
140  //- Return a pointer to a new patch created on freestore from polyPatch
141  static autoPtr<fvPatch> New
142  (
143  const polyPatch&,
144  const fvBoundaryMesh&
145  );
146 
147 
148  //- Destructor
149  virtual ~fvPatch();
150 
151 
152  // Member Functions
153 
154  //- Lookup the polyPatch index on corresponding fvMesh
155  // \note Fatal if the polyPatch is not associated with a fvMesh
156  static const fvPatch& lookupPatch(const polyPatch& p);
157 
158 
159  // Access
160 
161  //- Return the polyPatch
162  const polyPatch& patch() const
163  {
164  return polyPatch_;
165  }
166 
167  //- Return name
168  virtual const word& name() const
169  {
170  return polyPatch_.name();
171  }
172 
173  //- Return start label of this patch in the polyMesh face list
174  virtual label start() const
175  {
176  return polyPatch_.start();
177  }
178 
179  //- Return size
180  virtual label size() const
181  {
182  return polyPatch_.size();
183  }
184 
185  //- Return true if this patch is coupled
186  virtual bool coupled() const
187  {
188  return polyPatch_.coupled();
189  }
190 
191  //- Return true if the given type is a constraint type
192  static bool constraintType(const word& pt);
193 
194  //- Return a list of all the constraint patch types
195  static wordList constraintTypes();
196 
197  //- Return the index of this patch in the fvBoundaryMesh
198  label index() const
199  {
200  return polyPatch_.index();
201  }
202 
203  //- Return boundaryMesh reference
204  const fvBoundaryMesh& boundaryMesh() const
205  {
206  return boundaryMesh_;
207  }
208 
209  //- Slice list to patch
210  template<class T>
211  const typename List<T>::subList patchSlice(const List<T>& l) const
212  {
213  return typename List<T>::subList(l, size(), start());
214  }
215 
216  //- Return faceCells
217  virtual const labelUList& faceCells() const;
218 
219 
220  // Access functions for geometrical data
221 
222  //- Return face centres
223  const vectorField& Cf() const;
224 
225  //- Return neighbour cell centres
226  tmp<vectorField> Cn() const;
227 
228  //- Return face area vectors
229  const vectorField& Sf() const;
230 
231  //- Return face area magnitudes
232  const scalarField& magSf() const;
233 
234  //- Return face normals
235  tmp<vectorField> nf() const;
236 
237  //- Return cell-centre to face-centre vector
238  //- except for coupled patches for which the cell-centre
239  //- to coupled-cell-centre vector is returned
240  virtual tmp<vectorField> delta() const;
241 
242 
243  // Access functions for demand driven data
244 
245  //- Return patch weighting factors
246  const scalarField& weights() const;
247 
248  //- Return the face - cell distance coefficient
249  //- except for coupled patches for which the cell-centre
250  //- to coupled-cell-centre distance coefficient is returned
251  const scalarField& deltaCoeffs() const;
252 
253 
254  // Evaluation functions
255 
256  //- Return given internal field next to patch as patch field
257  template<class Type>
259 
260  //- Return given internal field next to patch as patch field
261  //- using faceCells mapping
262  template<class Type>
264  (
265  const UList<Type>&,
266  const labelUList& faceCells
267  ) const;
268 
269  //- Return given internal field next to patch as patch field
270  template<class Type>
271  void patchInternalField(const UList<Type>&, Field<Type>&) const;
272 
273  //- Return the corresponding patchField of the named field
274  template<class GeometricField, class Type>
275  const typename GeometricField::Patch& patchField
276  (
277  const GeometricField&
278  ) const;
279 
280  //- Lookup and return the patchField of the named field from the
281  //- local objectRegistry.
282  // N.B. The dummy pointer arguments are used if this function is
283  // instantiated within a templated function to avoid a bug in gcc.
284  // See inletOutletFvPatchField.C and outletInletFvPatchField.C
285  template<class GeometricField, class Type>
287  (
288  const word& name,
289  const GeometricField* = nullptr,
290  const Type* = nullptr
291  ) const;
292 };
293 
294 
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 
297 } // End namespace Foam
298 
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 
301 #ifdef NoRepository
302  #include "fvPatchTemplates.C"
303 #endif
304 
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 
307 #endif
308 
309 // ************************************************************************* //
Foam::fvPatch::Sf
const vectorField & Sf() const
Return face area vectors.
Definition: fvPatch.C:150
Foam::fvPatch::BoundaryMesh
fvBoundaryMesh BoundaryMesh
Definition: fvPatch.H:110
p
volScalarField & p
Definition: createFieldRefs.H:8
SubList.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
SubField.H
typeInfo.H
polyPatch.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::fvPatch::start
virtual label start() const
Return start label of this patch in the polyMesh face list.
Definition: fvPatch.H:173
Foam::fvPatch::coupled
virtual bool coupled() const
Return true if this patch is coupled.
Definition: fvPatch.H:185
Foam::fvPatch::~fvPatch
virtual ~fvPatch()
Destructor.
Definition: fvPatch.C:75
Foam::fvPatch::delta
virtual tmp< vectorField > delta() const
Definition: fvPatch.C:162
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:54
Foam::fvPatch::makeNonOrthoCorrVectors
virtual void makeNonOrthoCorrVectors(vectorField &) const
Correct patch non-ortho correction vectors.
Definition: fvPatch.C:184
Foam::polyPatch::coupled
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:377
Foam::fvPatch::makeDeltaCoeffs
virtual void makeDeltaCoeffs(scalarField &) const
Correct patch deltaCoeffs.
Definition: fvPatch.C:176
Foam::fvPatch::New
static autoPtr< fvPatch > New(const polyPatch &, const fvBoundaryMesh &)
Return a pointer to a new patch created on freestore from polyPatch.
Definition: fvPatchNew.C:35
fvPatchTemplates.C
fvPatchFieldsFwd.H
Foam::fvPatch::name
virtual const word & name() const
Return name.
Definition: fvPatch.H:167
Foam::fvPatch::patchInternalField
tmp< Field< Type > > patchInternalField(const UList< Type > &) const
Return given internal field next to patch as patch field.
Foam::fvPatch::movePoints
virtual void movePoints()
Correct patches after moving points.
Definition: fvPatch.C:192
primitiveFields.H
Specialisations of Field<T> for scalar, vector and tensor.
Foam::fvPatch::patchSlice
const List< T >::subList patchSlice(const List< T > &l) const
Slice list to patch.
Definition: fvPatch.H:210
Foam::fvPatch::boundaryMesh
const fvBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: fvPatch.H:203
Foam::fvBoundaryMesh
Foam::fvBoundaryMesh.
Definition: fvBoundaryMesh.H:57
Foam::fvPatch::lookupPatch
static const fvPatch & lookupPatch(const polyPatch &p)
Lookup the polyPatch index on corresponding fvMesh.
Definition: fvPatch.C:49
Foam::fvPatch::size
virtual label size() const
Return size.
Definition: fvPatch.H:179
Foam::fvPatch::nf
tmp< vectorField > nf() const
Return face normals.
Definition: fvPatch.C:144
labelList.H
Foam::Field< scalar >
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::fvPatch::initMovePoints
virtual void initMovePoints()
Initialise the patches for moving points.
Definition: fvPatch.C:188
Foam::fvPatch::constraintType
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
Definition: fvPatch.C:81
Foam::fvPatch::Cf
const vectorField & Cf() const
Return face centres.
Definition: fvPatch.C:119
Foam::fvPatch::makeNonOrthoDeltaCoeffs
virtual void makeNonOrthoDeltaCoeffs(scalarField &) const
Correct patch non-ortho deltaCoeffs.
Definition: fvPatch.C:180
Foam::fvPatch::lookupPatchField
const GeometricField::Patch & lookupPatchField(const word &name, const GeometricField *=nullptr, const Type *=nullptr) const
Definition: fvPatchFvMeshTemplates.C:34
Foam::List::subList
SubList< T > subList
Declare type of subList.
Definition: List.H:112
Foam::fvPatch::index
label index() const
Return the index of this patch in the fvBoundaryMesh.
Definition: fvPatch.H:197
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::patchIdentifier::index
label index() const noexcept
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:147
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:361
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
tmp.H
Foam::fvPatch::weights
const scalarField & weights() const
Return patch weighting factors.
Definition: fvPatch.C:202
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::List< word >
Foam::fvPatch::deltaCoeffs
const scalarField & deltaCoeffs() const
Definition: fvPatch.C:196
Foam::UList< label >
Foam::surfaceInterpolation
Cell to surface interpolation scheme. Included in fvMesh.
Definition: surfaceInterpolation.H:58
Foam::fvPatch::patchField
const GeometricField::Patch & patchField(const GeometricField &) const
Return the corresponding patchField of the named field.
Definition: fvPatchTemplates.C:82
Foam::fvPatch::faceCells
virtual const labelUList & faceCells() const
Return faceCells.
Definition: fvPatch.C:113
Foam::fvPatch::patch
const polyPatch & patch() const
Return the polyPatch.
Definition: fvPatch.H:161
Foam::patchIdentifier::name
const word & name() const noexcept
The patch name.
Definition: patchIdentifier.H:135
Foam::fvPatch::TypeName
TypeName(polyPatch::typeName_())
Runtime type information.
Foam::fvPatch::magSf
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:156
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::GeometricField::Patch
PatchField< Type > Patch
Definition: GeometricField.H:111
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56
Foam::fvPatch::makeWeights
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: fvPatch.C:170
Foam::fvPatch::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, fvPatch, polyPatch,(const polyPatch &patch, const fvBoundaryMesh &bm),(patch, bm))
Foam::fvPatch::constraintTypes
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: fvPatch.C:91
Foam::fvPatch::Cn
tmp< vectorField > Cn() const
Return neighbour cell centres.
Definition: fvPatch.C:125
autoPtr.H