initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / interpolation / surfaceInterpolation / schemes / skewCorrected / skewCorrected.H
blob047f5c7df145e597ff43ebb68c2e3834533be966
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::skewCorrected
28 Description
29     Skewness-corrected interpolation scheme that applies an explicit
30     correction to given scheme.
32 SourceFiles
33     skewCorrected.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef skewCorrected_H
38 #define skewCorrected_H
40 #include "surfaceInterpolationScheme.H"
41 #include "skewCorrectionVectors.H"
42 #include "linear.H"
43 #include "gaussGrad.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 namespace Foam
50 /*---------------------------------------------------------------------------*\
51                            Class skewCorrected Declaration
52 \*---------------------------------------------------------------------------*/
54 template<class Type>
55 class skewCorrected
57     public surfaceInterpolationScheme<Type>
59     // Private member data
61         tmp<surfaceInterpolationScheme<Type> > tScheme_;
64     // Private Member Functions
66         //- Disallow default bitwise copy construct
67         skewCorrected(const skewCorrected&);
69         //- Disallow default bitwise assignment
70         void operator=(const skewCorrected&);
73 public:
75     //- Runtime type information
76     TypeName("skewCorrected");
79     // Constructors
81         //- Construct from mesh and Istream
82         skewCorrected
83         (
84             const fvMesh& mesh,
85             Istream& is
86         )
87         :
88             surfaceInterpolationScheme<Type>(mesh),
89             tScheme_
90             (
91                 surfaceInterpolationScheme<Type>::New(mesh, is)
92             )
93         {}
96         //- Construct from mesh, faceFlux and Istream
97         skewCorrected
98         (
99             const fvMesh& mesh,
100             const surfaceScalarField& faceFlux,
101             Istream& is
102         )
103         :
104             surfaceInterpolationScheme<Type>(mesh),
105             tScheme_
106             (
107                 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
108             )
109         {}
112     // Member Functions
114         //- Return the interpolation weighting factors
115         tmp<surfaceScalarField> weights
116         (
117             const GeometricField<Type, fvPatchField, volMesh>& vf
118         ) const
119         {
120             return tScheme_().weights(vf);
121         }
123         //- Return true if this scheme uses an explicit correction
124         virtual bool corrected() const
125         {
126             return 
127                 tScheme_().corrected()
128              || skewCorrectionVectors::New(this->mesh()).skew();
129         }
131         tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
132         skewCorrection
133         (
134             const GeometricField<Type, fvPatchField, volMesh>& vf
135         ) const
136         {
137             const fvMesh& mesh = this->mesh();
139             const skewCorrectionVectors& scv = skewCorrectionVectors::New(mesh);
141             tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
142             (
143                 new GeometricField<Type, fvsPatchField, surfaceMesh>
144                 (
145                     IOobject
146                     (
147                         vf.name(),
148                         mesh.time().timeName(),
149                         mesh
150                     ),
151                     mesh,
152                     dimensioned<Type>
153                     (
154                         vf.name(),
155                         vf.dimensions(),
156                         pTraits<Type>::zero
157                     )
158                 )
159             );
161             for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
162             {
163                 tsfCorr().replace
164                 (
165                     cmpt,
166                     scv() & linear
167                     <
168                         typename outerProduct
169                         <
170                             vector,
171                             typename pTraits<Type>::cmptType
172                         >::type
173                     > (mesh).interpolate
174                     (
175                         fv::gaussGrad<typename pTraits<Type>::cmptType>
176                         (mesh).grad(vf.component(cmpt))
177                     )
178                 );
179             }
181             return tsfCorr;
182         }
185         //- Return the explicit correction to the face-interpolate
186         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
187         correction
188         (
189             const GeometricField<Type, fvPatchField, volMesh>& vf
190         ) const
191         {
192             if
193             (
194                 tScheme_().corrected()
195              && skewCorrectionVectors::New(this->mesh()).skew()
196             )
197             {
198                 return tScheme_().correction(vf) + skewCorrection(vf);
199             }
200             else if (tScheme_().corrected())
201             {
202                 return tScheme_().correction(vf);
203             }
204             else if (skewCorrectionVectors::New(this->mesh()).skew())
205             {
206                 return skewCorrection(vf);
207             }
208             else
209             {
210                 return 
211                     tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >(NULL);
212             }
213         }
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 } // End namespace Foam
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 #endif
225 // ************************************************************************* //