CentredFitScheme.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-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::CentredFitScheme
28
29Group
30 grpFvSurfaceInterpolationSchemes
31
32Description
33 Centred fit surface interpolation scheme which applies an explicit
34 correction to linear.
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef CentredFitScheme_H
39#define CentredFitScheme_H
40
41#include "CentredFitData.H"
42#include "linear.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49/*---------------------------------------------------------------------------*\
50 Class CentredFitScheme Declaration
51\*---------------------------------------------------------------------------*/
52
53template<class Type, class Polynomial, class Stencil>
55:
56 public linear<Type>
57{
58 // Private Data
59
60 //- Factor the fit is allowed to deviate from linear.
61 // This limits the amount of high-order correction and increases
62 // stability on bad meshes
63 const scalar linearLimitFactor_;
64
65 //- Weights for central stencil
66 const scalar centralWeight_;
67
68
69 // Private Member Functions
70
71 //- No copy construct
72 CentredFitScheme(const CentredFitScheme&) = delete;
73
74 //- No copy assignment
75 void operator=(const CentredFitScheme&) = delete;
76
77
78public:
79
80 //- Runtime type information
81 TypeName("CentredFitScheme");
82
83
84 // Constructors
85
86 //- Construct from mesh and Istream
88 :
89 linear<Type>(mesh),
90 linearLimitFactor_(readScalar(is)),
91 centralWeight_(1000)
92 {}
93
94
95 //- Construct from mesh, faceFlux and Istream
97 (
98 const fvMesh& mesh,
99 const surfaceScalarField& faceFlux,
100 Istream& is
101 )
102 :
103 linear<Type>(mesh),
104 linearLimitFactor_(readScalar(is)),
105 centralWeight_(1000)
106 {}
107
108
109 // Member Functions
110
111 //- Return true if this scheme uses an explicit correction
112 virtual bool corrected() const
113 {
114 return true;
115 }
116
117 //- Return the explicit correction to the face-interpolate
120 (
122 ) const
123 {
124 const fvMesh& mesh = this->mesh();
125
127 (
128 mesh
129 );
130
131 const CentredFitData<Polynomial>& cfd =
133 (
134 mesh,
135 stencil,
136 linearLimitFactor_,
137 centralWeight_
138 );
139
140 const List<scalarList>& f = cfd.coeffs();
141
142 return stencil.weightedSum(vf, f);
143 }
144};
145
146
147// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148
149} // End namespace Foam
150
151// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152
153// Add the patch constructor functions to the hash tables
155#define makeCentredFitSurfaceInterpolationTypeScheme\
156( \
157 SS, \
158 POLYNOMIAL, \
159 STENCIL, \
160 TYPE \
161) \
162 \
163typedef CentredFitScheme<TYPE, POLYNOMIAL, STENCIL> \
164 CentredFitScheme##TYPE##POLYNOMIAL##STENCIL##_; \
165defineTemplateTypeNameAndDebugWithName \
166 (CentredFitScheme##TYPE##POLYNOMIAL##STENCIL##_, #SS, 0); \
167 \
168surfaceInterpolationScheme<TYPE>::addMeshConstructorToTable \
169<CentredFitScheme<TYPE, POLYNOMIAL, STENCIL>> \
170 add##SS##STENCIL##TYPE##MeshConstructorToTable_; \
171 \
172surfaceInterpolationScheme<TYPE>::addMeshFluxConstructorToTable \
173<CentredFitScheme<TYPE, POLYNOMIAL, STENCIL>> \
174 add##SS##STENCIL##TYPE##MeshFluxConstructorToTable_;
176#define makeCentredFitSurfaceInterpolationScheme(SS, POLYNOMIAL, STENCIL) \
177 \
178makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,scalar) \
179makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,vector) \
180makeCentredFitSurfaceInterpolationTypeScheme \
181( \
182 SS, \
183 POLYNOMIAL, \
184 STENCIL, \
185 sphericalTensor \
186) \
187makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,symmTensor)\
188makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,tensor)
189
190
191// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192
193#endif
194
195// ************************************************************************* //
Data for the quadratic fit correction interpolation scheme.
const List< scalarList > & coeffs() const
Return reference to fit coefficients.
Centred fit surface interpolation scheme which applies an explicit correction to linear.
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
CentredFitScheme(const fvMesh &mesh, Istream &is)
Construct from mesh and Istream.
CentredFitScheme(const fvMesh &mesh, const surfaceScalarField &faceFlux, Istream &is)
Construct from mesh, faceFlux and Istream.
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
TypeName("CentredFitScheme")
Runtime type information.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > weightedSum(const GeometricField< Type, fvPatchField, volMesh > &fld, const List< List< scalar > > &stencilWeights) const
Sum vol field contributions to create face values.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Central-differencing interpolation scheme class.
Definition: linear.H:58
const fvMesh & mesh() const
Return mesh reference.
A class for managing temporary objects.
Definition: tmp.H:65
Namespace for OpenFOAM.
labelList f(nPoints)
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73