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 | Copyright (C) 2011 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::CentredFitScheme
26 
27 Description
28  Centred fit surface interpolation scheme which applies an explicit
29  correction to linear.
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #ifndef CentredFitScheme_H
34 #define CentredFitScheme_H
35 
36 #include "CentredFitData.H"
37 #include "linear.H"
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 namespace Foam
42 {
43 
44 /*---------------------------------------------------------------------------*\
45  Class CentredFitScheme Declaration
46 \*---------------------------------------------------------------------------*/
47 
48 template<class Type, class Polynomial, class Stencil>
49 class CentredFitScheme
50 :
51  public linear<Type>
52 {
53  // Private Data
54 
55  //- Factor the fit is allowed to deviate from linear.
56  // This limits the amount of high-order correction and increases
57  // stability on bad meshes
58  const scalar linearLimitFactor_;
59 
60  //- Weights for central stencil
61  const scalar centralWeight_;
62 
63 
64  // Private Member Functions
65 
66  //- Disallow default bitwise copy construct
68 
69  //- Disallow default bitwise assignment
70  void operator=(const CentredFitScheme&);
71 
72 
73 public:
74 
75  //- Runtime type information
76  TypeName("CentredFitScheme");
77 
78 
79  // Constructors
80 
81  //- Construct from mesh and Istream
82  CentredFitScheme(const fvMesh& mesh, Istream& is)
83  :
84  linear<Type>(mesh),
86  centralWeight_(1000)
87  {}
88 
89 
90  //- Construct from mesh, faceFlux and Istream
92  (
93  const fvMesh& mesh,
94  const surfaceScalarField& faceFlux,
95  Istream& is
96  )
97  :
98  linear<Type>(mesh),
100  centralWeight_(1000)
101  {}
102 
103 
104  // Member Functions
105 
106  //- Return true if this scheme uses an explicit correction
107  virtual bool corrected() const
108  {
109  return true;
110  }
111 
112  //- Return the explicit correction to the face-interpolate
115  (
117  ) const
118  {
119  const fvMesh& mesh = this->mesh();
120 
122  (
123  mesh
124  );
125 
126  const CentredFitData<Polynomial>& cfd =
128  (
129  mesh,
130  stencil,
133  );
134 
135  const List<scalarList>& f = cfd.coeffs();
136 
137  return stencil.weightedSum(vf, f);
138  }
139 };
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace Foam
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 // Add the patch constructor functions to the hash tables
149 
150 #define makeCentredFitSurfaceInterpolationTypeScheme\
151 ( \
152  SS, \
153  POLYNOMIAL, \
154  STENCIL, \
155  TYPE \
156 ) \
157  \
158 typedef CentredFitScheme<TYPE, POLYNOMIAL, STENCIL> \
159  CentredFitScheme##TYPE##POLYNOMIAL##STENCIL##_; \
160 defineTemplateTypeNameAndDebugWithName \
161  (CentredFitScheme##TYPE##POLYNOMIAL##STENCIL##_, #SS, 0); \
162  \
163 surfaceInterpolationScheme<TYPE>::addMeshConstructorToTable \
164 <CentredFitScheme<TYPE, POLYNOMIAL, STENCIL> > \
165  add##SS##STENCIL##TYPE##MeshConstructorToTable_; \
166  \
167 surfaceInterpolationScheme<TYPE>::addMeshFluxConstructorToTable \
168 <CentredFitScheme<TYPE, POLYNOMIAL, STENCIL> > \
169  add##SS##STENCIL##TYPE##MeshFluxConstructorToTable_;
170 
171 #define makeCentredFitSurfaceInterpolationScheme(SS, POLYNOMIAL, STENCIL) \
172  \
173 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,scalar) \
174 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,vector) \
175 makeCentredFitSurfaceInterpolationTypeScheme \
176 ( \
177  SS, \
178  POLYNOMIAL, \
179  STENCIL, \
180  sphericalTensor \
181 ) \
182 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,symmTensor)\
183 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,tensor)
184 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #endif
189 
190 // ************************************************************************* //
Foam::CentredFitData::coeffs
const List< scalarList > & coeffs() const
Return reference to fit coefficients.
Definition: CentredFitData.H:99
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::CentredFitScheme::CentredFitScheme
CentredFitScheme(const fvMesh &mesh, Istream &is)
Construct from mesh and Istream.
Definition: CentredFitScheme.H:81
Foam::extendedCentredCellToFaceStencil
Definition: extendedCentredCellToFaceStencil.H:49
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::CentredFitScheme::TypeName
TypeName("CentredFitScheme")
Runtime type information.
Foam::CentredFitScheme::linearLimitFactor_
const scalar linearLimitFactor_
Factor the fit is allowed to deviate from linear.
Definition: CentredFitScheme.H:57
Foam::CentredFitScheme::CentredFitScheme
CentredFitScheme(const CentredFitScheme &)
Disallow default bitwise copy construct.
Foam::MeshObject< fvMesh, MoveableMeshObject, CentredFitData< Polynomial > >::New
static const CentredFitData< Polynomial > & New(const fvMesh &mesh)
Definition: MeshObject.C:44
Foam::extendedCentredCellToFaceStencil::weightedSum
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.
Definition: extendedCentredCellToFaceStencil.H:119
Foam::CentredFitData
Data for the quadratic fit correction interpolation scheme.
Definition: CentredFitData.H:51
CentredFitData.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam::CentredFitScheme::centralWeight_
const scalar centralWeight_
Weights for central stencil.
Definition: CentredFitScheme.H:60
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::CentredFitScheme::correction
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
Definition: CentredFitScheme.H:114
Foam::CentredFitScheme::operator=
void operator=(const CentredFitScheme &)
Disallow default bitwise assignment.
Foam::CentredFitScheme::corrected
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
Definition: CentredFitScheme.H:106
Foam::readScalar
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
f
labelList f(nPoints)
Foam::List< scalarList >
Foam::surfaceInterpolationScheme::mesh
const fvMesh & mesh() const
Return mesh reference.
Definition: surfaceInterpolationScheme.H:142
Foam::linear
Central-differencing interpolation scheme class.
Definition: linear.H:50
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::CentredFitScheme
Centred fit surface interpolation scheme which applies an explicit correction to linear.
Definition: CentredFitScheme.H:48