initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / finiteVolume / snGradSchemes / quadraticFitSnGrad / quadraticFitSnGrad.H
blob035bb1d6dba485422291895e14000961dd692c54
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     quadraticFitSnGrad
28 Description
29     Simple central-difference snGrad scheme with quadratic fit correction from
30     a larger stencil.
32 SourceFiles
33     quadraticFitSnGrad.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef quadraticFitSnGrad_H
38 #define quadraticFitSnGrad_H
40 #include "snGradScheme.H"
41 #include "quadraticFitSnGradData.H"
42 #include "extendedCellToFaceStencil.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 namespace fv
54 /*---------------------------------------------------------------------------*\
55                  Class quadraticFitSnGrad Declaration
56 \*---------------------------------------------------------------------------*/
58 template<class Type>
59 class quadraticFitSnGrad
61     public snGradScheme<Type>
63     // Private Data
64         //- weights for central stencil
65         const scalar centralWeight_;
67     // Private Member Functions
69         //- Disallow default bitwise assignment
70         void operator=(const quadraticFitSnGrad&);
73 public:
75     //- Runtime type information
76     TypeName("quadraticFit");
79     // Constructors
81         //- Construct from mesh and scheme data
82         quadraticFitSnGrad
83         (
84             const fvMesh& mesh,
85             const scalar centralWeight
86         )
87         :
88             snGradScheme<Type>(mesh),
89             centralWeight_(centralWeight)
90         {}
93         //- Construct from mesh and data stream
94         quadraticFitSnGrad(const fvMesh& mesh, Istream& is)
95         :
96             snGradScheme<Type>(mesh),
97             centralWeight_(readScalar(is))
98         {}
101     // Destructor
103         virtual ~quadraticFitSnGrad() {}
106     // Member Functions
108         //- Return the interpolation weighting factors for the given field
109         virtual tmp<surfaceScalarField> deltaCoeffs
110         (
111             const GeometricField<Type, fvPatchField, volMesh>&
112         ) const
113         {
114             return this->mesh().deltaCoeffs();
115         }
117         //- Return true if this scheme uses an explicit correction
118         virtual bool corrected() const
119         {
120             return true;
121         }
123         //- Return the explicit correction to the quadraticFitSnGrad
124         //  for the given field
125         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
126         correction(const GeometricField<Type, fvPatchField, volMesh>& vf) const
127         {
128             const fvMesh& mesh = this->mesh();
130             const quadraticFitSnGradData& qfd = quadraticFitSnGradData::New
131             (
132                 mesh,
133                 centralWeight_
134             );
136             const extendedCellToFaceStencil& stencil = qfd.stencil();
137             const List<scalarList>& f = qfd.fit();
139             tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > sft
140                 = stencil.weightedSum(vf, f);
142             sft().dimensions() /= dimLength;
144             return sft;
145         }
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 } // End namespace fv
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 } // End namespace Foam
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 #endif
161 // ************************************************************************* //