CentredFitSnGradScheme.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) 2013-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::CentredFitSnGradScheme
28 
29 Group
30  grpFvSnGradSchemes
31 
32 Description
33  Centred fit snGrad scheme which applies an explicit correction to snGrad
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef CentredFitSnGradScheme_H
38 #define CentredFitSnGradScheme_H
39 
40 #include "CentredFitSnGradData.H"
41 #include "snGradScheme.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 class fvMesh;
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace fv
53 {
54 /*---------------------------------------------------------------------------*\
55  Class CentredFitSnGradSnGradScheme Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class Type, class Polynomial, class Stencil>
60 :
61  public snGradScheme<Type>
62 {
63  // Private Data
64 
65  //- Factor the fit is allowed to deviate from linear.
66  // This limits the amount of high-order correction and increases
67  // stability on bad meshes
68  const scalar linearLimitFactor_;
69 
70  //- Weights for central stencil
71  const scalar centralWeight_;
72 
73 
74  // Private Member Functions
75 
76  //- No copy construct
78 
79  //- No copy assignment
80  void operator=(const CentredFitSnGradScheme&) = delete;
81 
82 
83 public:
84 
85  //- Runtime type information
86  TypeName("CentredFitSnGradScheme");
87 
88 
89  // Constructors
90 
91  //- Construct from mesh and Istream
93  :
94  snGradScheme<Type>(mesh),
95  linearLimitFactor_(readScalar(is)),
96  centralWeight_(1000)
97  {}
98 
99 
100  // Member Functions
101 
102  //- Return the interpolation weighting factors for the given field
104  (
106  ) const
107  {
108  return this->mesh().nonOrthDeltaCoeffs();
109  }
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 
133  (
134  mesh,
135  stencil,
136  linearLimitFactor_,
137  centralWeight_
138  );
139 
141  (
142  stencil.weightedSum(vf, cfd.coeffs())
143  );
144 
145  sft.ref().dimensions() /= dimLength;
146 
147  return sft;
148  }
149 };
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace fv
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace Foam
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 // Add the patch constructor functions to the hash tables
163 
164 #define makeCentredFitSnGradTypeScheme(SS, POLYNOMIAL, STENCIL, TYPE) \
165  typedef Foam::fv::CentredFitSnGradScheme \
166  <Foam::TYPE, Foam::POLYNOMIAL, Foam::STENCIL> \
167  CentredFitSnGradScheme##TYPE##POLYNOMIAL##STENCIL##_; \
168  \
169  defineTemplateTypeNameAndDebugWithName \
170  (CentredFitSnGradScheme##TYPE##POLYNOMIAL##STENCIL##_, #SS, 0); \
171  \
172  namespace Foam \
173  { \
174  namespace fv \
175  { \
176  snGradScheme<TYPE>::addMeshConstructorToTable \
177  <CentredFitSnGradScheme<TYPE, POLYNOMIAL, STENCIL>> \
178  add##SS##STENCIL##TYPE##MeshConstructorToTable_; \
179  } \
180  }
181 
182 #define makeCentredFitSnGradScheme(SS, POLYNOMIAL, STENCIL) \
183  \
184  makeCentredFitSnGradTypeScheme(SS,POLYNOMIAL,STENCIL,scalar) \
185  makeCentredFitSnGradTypeScheme(SS,POLYNOMIAL,STENCIL,vector) \
186  makeCentredFitSnGradTypeScheme(SS,POLYNOMIAL,STENCIL,sphericalTensor) \
187  makeCentredFitSnGradTypeScheme(SS,POLYNOMIAL,STENCIL,symmTensor) \
188  makeCentredFitSnGradTypeScheme(SS,POLYNOMIAL,STENCIL,tensor)
189 
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #endif
194 
195 // ************************************************************************* //
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::surfaceInterpolation::nonOrthDeltaCoeffs
virtual const surfaceScalarField & nonOrthDeltaCoeffs() const
Return reference to non-orthogonal cell-centre difference.
Definition: surfaceInterpolation.C:125
Foam::extendedCentredCellToFaceStencil
Definition: extendedCentredCellToFaceStencil.H:51
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::fv::CentredFitSnGradScheme::deltaCoeffs
virtual tmp< surfaceScalarField > deltaCoeffs(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the interpolation weighting factors for the given field.
Definition: CentredFitSnGradScheme.H:103
Foam::fv::CentredFitSnGradScheme::CentredFitSnGradScheme
CentredFitSnGradScheme(const fvMesh &mesh, Istream &is)
Construct from mesh and Istream.
Definition: CentredFitSnGradScheme.H:91
Foam::MeshObject::New
static const Type & New(const Mesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
Definition: MeshObject.C:48
Foam::fv::CentredFitSnGradScheme::correction
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
Definition: CentredFitSnGradScheme.H:119
Foam::fv::CentredFitSnGradScheme::TypeName
TypeName("CentredFitSnGradScheme")
Runtime type information.
CentredFitSnGradData.H
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:228
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::fv::CentredFitSnGradScheme::corrected
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
Definition: CentredFitSnGradScheme.H:111
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
Foam::CentredFitSnGradData
Data for centred fit snGrad schemes.
Definition: CentredFitSnGradData.H:54
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
fv
labelList fv(nPoints)
Foam::fv::snGradScheme::mesh
const fvMesh & mesh() const
Return mesh reference.
Definition: snGradScheme.H:128
Foam::fv::CentredFitSnGradScheme
Definition: CentredFitSnGradScheme.H:58
Foam::fv::snGradScheme
Abstract base class for snGrad schemes.
Definition: snGradScheme.H:65
snGradScheme.H
Foam::GeometricField< Type, fvPatchField, volMesh >
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
Foam::CentredFitSnGradData::coeffs
const List< scalarList > & coeffs() const
Return reference to fit coefficients.
Definition: CentredFitSnGradData.H:94