initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / interpolation / surfaceInterpolation / schemes / CentredFitScheme / CentredFitScheme.H
blob7e981024c01013dd755d35c58dc165f6382ab463
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     Foam::CentredFitScheme
28 Description
29     Centred fit surface interpolation scheme which applies an explicit
30     correction to linear.
32 \*---------------------------------------------------------------------------*/
34 #ifndef CentredFitScheme_H
35 #define CentredFitScheme_H
37 #include "CentredFitData.H"
38 #include "linear.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 namespace Foam
45 /*---------------------------------------------------------------------------*\
46                            Class CentredFitScheme Declaration
47 \*---------------------------------------------------------------------------*/
49 template<class Type, class Polynomial, class Stencil>
50 class CentredFitScheme
52     public linear<Type>
54     // Private Data
56         //- Factor the fit is allowed to deviate from linear.
57         //  This limits the amount of high-order correction and increases
58         //  stability on bad meshes
59         const scalar linearLimitFactor_;
61         //- Weights for central stencil
62         const scalar centralWeight_;
65     // Private Member Functions
67         //- Disallow default bitwise copy construct
68         CentredFitScheme(const CentredFitScheme&);
70         //- Disallow default bitwise assignment
71         void operator=(const CentredFitScheme&);
74 public:
76     //- Runtime type information
77     TypeName("CentredFitScheme");
80     // Constructors
82         //- Construct from mesh and Istream
83         CentredFitScheme(const fvMesh& mesh, Istream& is)
84         :
85             linear<Type>(mesh),
86             linearLimitFactor_(readScalar(is)),
87             centralWeight_(1000)
88         {}
91         //- Construct from mesh, faceFlux and Istream
92         CentredFitScheme
93         (
94             const fvMesh& mesh,
95             const surfaceScalarField& faceFlux,
96             Istream& is
97         )
98         :
99             linear<Type>(mesh),
100             linearLimitFactor_(readScalar(is)),
101             centralWeight_(1000)
102         {}
105     // Member Functions
107         //- Return true if this scheme uses an explicit correction
108         virtual bool corrected() const
109         {
110             return true;
111         }
113         //- Return the explicit correction to the face-interpolate
114         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
115         correction
116         (
117             const GeometricField<Type, fvPatchField, volMesh>& vf
118         ) const
119         {
120             const fvMesh& mesh = this->mesh();
122             const extendedCentredCellToFaceStencil& stencil = Stencil::New
123             (
124                 mesh
125             );
127             const CentredFitData<Polynomial>& cfd =
128             CentredFitData<Polynomial>::New
129             (
130                 mesh,
131                 stencil,
132                 linearLimitFactor_,
133                 centralWeight_
134             );
136             const List<scalarList>& f = cfd.coeffs();
138             return stencil.weightedSum(vf, f);
139         }
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 } // End namespace Foam
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 // Add the patch constructor functions to the hash tables
151 #define makeCentredFitSurfaceInterpolationTypeScheme(SS, POLYNOMIAL, STENCIL, TYPE) \
152                                                                               \
153 typedef CentredFitScheme<TYPE, POLYNOMIAL, STENCIL>                           \
154     CentredFitScheme##TYPE##POLYNOMIAL##STENCIL##_;                           \
155 defineTemplateTypeNameAndDebugWithName                                        \
156     (CentredFitScheme##TYPE##POLYNOMIAL##STENCIL##_, #SS, 0);                 \
157                                                                               \
158 surfaceInterpolationScheme<TYPE>::addMeshConstructorToTable                   \
159 <CentredFitScheme<TYPE, POLYNOMIAL, STENCIL> >                                \
160     add##SS##STENCIL##TYPE##MeshConstructorToTable_;                          \
161                                                                               \
162 surfaceInterpolationScheme<TYPE>::addMeshFluxConstructorToTable               \
163 <CentredFitScheme<TYPE, POLYNOMIAL, STENCIL> >                                \
164     add##SS##STENCIL##TYPE##MeshFluxConstructorToTable_;
166 #define makeCentredFitSurfaceInterpolationScheme(SS, POLYNOMIAL, STENCIL)     \
167                                                                               \
168 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,scalar)    \
169 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,vector)    \
170 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,sphericalTensor) \
171 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,symmTensor)\
172 makeCentredFitSurfaceInterpolationTypeScheme(SS,POLYNOMIAL,STENCIL,tensor)
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 #endif
179 // ************************************************************************* //