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),
85  linearLimitFactor_(readScalar(is)),
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),
99  linearLimitFactor_(readScalar(is)),
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,
131  linearLimitFactor_,
132  centralWeight_
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
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_;
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 // ************************************************************************* //
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
labelList f(nPoints)
Central-differencing interpolation scheme class.
Definition: linear.H:50
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
TypeName("CentredFitScheme")
Runtime type information.
Namespace for OpenFOAM.
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
const fvMesh & mesh() const
Return mesh reference.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
Centred fit surface interpolation scheme which applies an explicit correction to linear.
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.
const List< scalarList > & coeffs() const
Return reference to fit coefficients.
Data for the quadratic fit correction interpolation scheme.
A class for managing temporary objects.
Definition: PtrList.H:118