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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::CentredFitScheme
28 
29 Group
30  grpFvSurfaceInterpolationSchemes
31 
32 Description
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 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class CentredFitScheme Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template<class Type, class Polynomial, class Stencil>
54 class CentredFitScheme
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 
78 public:
79 
80  //- Runtime type information
81  TypeName("CentredFitScheme");
82 
83 
84  // Constructors
85 
86  //- Construct from mesh and Istream
87  CentredFitScheme(const fvMesh& mesh, Istream& is)
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
154 
155 #define makeCentredFitSurfaceInterpolationTypeScheme\
156 ( \
157  SS, \
158  POLYNOMIAL, \
159  STENCIL, \
160  TYPE \
161 ) \
162  \
163 typedef CentredFitScheme<TYPE, POLYNOMIAL, STENCIL> \
164  CentredFitScheme##TYPE##POLYNOMIAL##STENCIL##_; \
165 defineTemplateTypeNameAndDebugWithName \
166  (CentredFitScheme##TYPE##POLYNOMIAL##STENCIL##_, #SS, 0); \
167  \
168 surfaceInterpolationScheme<TYPE>::addMeshConstructorToTable \
169 <CentredFitScheme<TYPE, POLYNOMIAL, STENCIL>> \
170  add##SS##STENCIL##TYPE##MeshConstructorToTable_; \
171  \
172 surfaceInterpolationScheme<TYPE>::addMeshFluxConstructorToTable \
173 <CentredFitScheme<TYPE, POLYNOMIAL, STENCIL>> \
174  add##SS##STENCIL##TYPE##MeshFluxConstructorToTable_;
175 
176 #define makeCentredFitSurfaceInterpolationScheme(SS, POLYNOMIAL, STENCIL) \
177  \
178 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,scalar) \
179 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,vector) \
180 makeCentredFitSurfaceInterpolationTypeScheme \
181 ( \
182  SS, \
183  POLYNOMIAL, \
184  STENCIL, \
185  sphericalTensor \
186 ) \
187 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,symmTensor)\
188 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,tensor)
189 
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #endif
194 
195 // ************************************************************************* //
Foam::CentredFitData::coeffs
const List< scalarList > & coeffs() const
Return reference to fit coefficients.
Definition: CentredFitData.H:101
Foam::CentredFitScheme::CentredFitScheme
CentredFitScheme(const fvMesh &mesh, Istream &is)
Construct from mesh and Istream.
Definition: CentredFitScheme.H:86
Foam::extendedCentredCellToFaceStencil
Definition: extendedCentredCellToFaceStencil.H:51
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::CentredFitScheme::TypeName
TypeName("CentredFitScheme")
Runtime type information.
Foam::MeshObject::New
static const Type & New(const Mesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
Definition: MeshObject.C:48
Foam::CentredFitData
Data for the quadratic fit correction interpolation scheme.
Definition: CentredFitData.H:54
CentredFitData.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
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:119
Foam::CentredFitScheme::corrected
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
Definition: CentredFitScheme.H:111
f
labelList f(nPoints)
Foam::List< scalarList >
Foam::surfaceInterpolationScheme::mesh
const fvMesh & mesh() const
Return mesh reference.
Definition: surfaceInterpolationScheme.H:144
Foam::linear
Central-differencing interpolation scheme class.
Definition: linear.H:55
Foam::GeometricField< scalar, fvsPatchField, surfaceMesh >
Foam::CentredFitScheme
Centred fit surface interpolation scheme which applies an explicit correction to linear.
Definition: CentredFitScheme.H:53
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:121