OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

skewCorrected.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::skewCorrected
00027 
00028 Description
00029     Skewness-corrected interpolation scheme that applies an explicit
00030     correction to given scheme.
00031 
00032 SourceFiles
00033     skewCorrected.C
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #ifndef skewCorrected_H
00038 #define skewCorrected_H
00039 
00040 #include "surfaceInterpolationScheme.H"
00041 #include "skewCorrectionVectors.H"
00042 #include "linear.H"
00043 #include "gaussGrad.H"
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 /*---------------------------------------------------------------------------*\
00051                            Class skewCorrected Declaration
00052 \*---------------------------------------------------------------------------*/
00053 
00054 template<class Type>
00055 class skewCorrected
00056 :
00057     public surfaceInterpolationScheme<Type>
00058 {
00059     // Private member data
00060 
00061         tmp<surfaceInterpolationScheme<Type> > tScheme_;
00062 
00063 
00064     // Private Member Functions
00065 
00066         //- Disallow default bitwise copy construct
00067         skewCorrected(const skewCorrected&);
00068 
00069         //- Disallow default bitwise assignment
00070         void operator=(const skewCorrected&);
00071 
00072 
00073 public:
00074 
00075     //- Runtime type information
00076     TypeName("skewCorrected");
00077 
00078 
00079     // Constructors
00080 
00081         //- Construct from mesh and Istream
00082         skewCorrected
00083         (
00084             const fvMesh& mesh,
00085             Istream& is
00086         )
00087         :
00088             surfaceInterpolationScheme<Type>(mesh),
00089             tScheme_
00090             (
00091                 surfaceInterpolationScheme<Type>::New(mesh, is)
00092             )
00093         {}
00094 
00095 
00096         //- Construct from mesh, faceFlux and Istream
00097         skewCorrected
00098         (
00099             const fvMesh& mesh,
00100             const surfaceScalarField& faceFlux,
00101             Istream& is
00102         )
00103         :
00104             surfaceInterpolationScheme<Type>(mesh),
00105             tScheme_
00106             (
00107                 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
00108             )
00109         {}
00110 
00111 
00112     // Member Functions
00113 
00114         //- Return the interpolation weighting factors
00115         tmp<surfaceScalarField> weights
00116         (
00117             const GeometricField<Type, fvPatchField, volMesh>& vf
00118         ) const
00119         {
00120             return tScheme_().weights(vf);
00121         }
00122 
00123         //- Return true if this scheme uses an explicit correction
00124         virtual bool corrected() const
00125         {
00126             return 
00127                 tScheme_().corrected()
00128              || skewCorrectionVectors::New(this->mesh()).skew();
00129         }
00130 
00131         tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00132         skewCorrection
00133         (
00134             const GeometricField<Type, fvPatchField, volMesh>& vf
00135         ) const
00136         {
00137             const fvMesh& mesh = this->mesh();
00138 
00139             const skewCorrectionVectors& scv = skewCorrectionVectors::New(mesh);
00140 
00141             tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
00142             (
00143                 new GeometricField<Type, fvsPatchField, surfaceMesh>
00144                 (
00145                     IOobject
00146                     (
00147                         vf.name(),
00148                         mesh.time().timeName(),
00149                         mesh
00150                     ),
00151                     mesh,
00152                     dimensioned<Type>
00153                     (
00154                         vf.name(),
00155                         vf.dimensions(),
00156                         pTraits<Type>::zero
00157                     )
00158                 )
00159             );
00160 
00161             for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00162             {
00163                 tsfCorr().replace
00164                 (
00165                     cmpt,
00166                     scv() & linear
00167                     <
00168                         typename outerProduct
00169                         <
00170                             vector,
00171                             typename pTraits<Type>::cmptType
00172                         >::type
00173                     > (mesh).interpolate
00174                     (
00175                         fv::gaussGrad<typename pTraits<Type>::cmptType>
00176                         (mesh).grad(vf.component(cmpt))
00177                     )
00178                 );
00179             }
00180 
00181             return tsfCorr;
00182         }
00183 
00184 
00185         //- Return the explicit correction to the face-interpolate
00186         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00187         correction
00188         (
00189             const GeometricField<Type, fvPatchField, volMesh>& vf
00190         ) const
00191         {
00192             if
00193             (
00194                 tScheme_().corrected()
00195              && skewCorrectionVectors::New(this->mesh()).skew()
00196             )
00197             {
00198                 return tScheme_().correction(vf) + skewCorrection(vf);
00199             }
00200             else if (tScheme_().corrected())
00201             {
00202                 return tScheme_().correction(vf);
00203             }
00204             else if (skewCorrectionVectors::New(this->mesh()).skew())
00205             {
00206                 return skewCorrection(vf);
00207             }
00208             else
00209             {
00210                 return 
00211                     tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >(NULL);
00212             }
00213         }
00214 };
00215 
00216 
00217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00218 
00219 } // End namespace Foam
00220 
00221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00222 
00223 #endif
00224 
00225 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd