FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::skewCorrected
00026 
00027 Description
00028     Skewness-corrected interpolation scheme that applies an explicit
00029     correction to given scheme.
00030 
00031 SourceFiles
00032     skewCorrected.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef skewCorrected_H
00037 #define skewCorrected_H
00038 
00039 #include <finiteVolume/surfaceInterpolationScheme.H>
00040 #include "skewCorrectionVectors.H"
00041 #include <finiteVolume/linear.H>
00042 #include <finiteVolume/gaussGrad.H>
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 /*---------------------------------------------------------------------------*\
00050                            Class skewCorrected Declaration
00051 \*---------------------------------------------------------------------------*/
00052 
00053 template<class Type>
00054 class skewCorrected
00055 :
00056     public surfaceInterpolationScheme<Type>
00057 {
00058     // Private member data
00059 
00060         tmp<surfaceInterpolationScheme<Type> > tScheme_;
00061 
00062 
00063     // Private Member Functions
00064 
00065         //- Disallow default bitwise copy construct
00066         skewCorrected(const skewCorrected&);
00067 
00068         //- Disallow default bitwise assignment
00069         void operator=(const skewCorrected&);
00070 
00071 
00072 public:
00073 
00074     //- Runtime type information
00075     TypeName("skewCorrected");
00076 
00077 
00078     // Constructors
00079 
00080         //- Construct from mesh and Istream
00081         skewCorrected
00082         (
00083             const fvMesh& mesh,
00084             Istream& is
00085         )
00086         :
00087             surfaceInterpolationScheme<Type>(mesh),
00088             tScheme_
00089             (
00090                 surfaceInterpolationScheme<Type>::New(mesh, is)
00091             )
00092         {}
00093 
00094 
00095         //- Construct from mesh, faceFlux and Istream
00096         skewCorrected
00097         (
00098             const fvMesh& mesh,
00099             const surfaceScalarField& faceFlux,
00100             Istream& is
00101         )
00102         :
00103             surfaceInterpolationScheme<Type>(mesh),
00104             tScheme_
00105             (
00106                 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
00107             )
00108         {}
00109 
00110 
00111     // Member Functions
00112 
00113         //- Return the interpolation weighting factors
00114         tmp<surfaceScalarField> weights
00115         (
00116             const GeometricField<Type, fvPatchField, volMesh>& vf
00117         ) const
00118         {
00119             return tScheme_().weights(vf);
00120         }
00121 
00122         //- Return true if this scheme uses an explicit correction
00123         virtual bool corrected() const
00124         {
00125             return 
00126                 tScheme_().corrected()
00127              || skewCorrectionVectors::New(this->mesh()).skew();
00128         }
00129 
00130         tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00131         skewCorrection
00132         (
00133             const GeometricField<Type, fvPatchField, volMesh>& vf
00134         ) const
00135         {
00136             const fvMesh& mesh = this->mesh();
00137 
00138             const skewCorrectionVectors& scv = skewCorrectionVectors::New(mesh);
00139 
00140             tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
00141             (
00142                 new GeometricField<Type, fvsPatchField, surfaceMesh>
00143                 (
00144                     IOobject
00145                     (
00146                         vf.name(),
00147                         mesh.time().timeName(),
00148                         mesh
00149                     ),
00150                     mesh,
00151                     dimensioned<Type>
00152                     (
00153                         vf.name(),
00154                         vf.dimensions(),
00155                         pTraits<Type>::zero
00156                     )
00157                 )
00158             );
00159 
00160             for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00161             {
00162                 tsfCorr().replace
00163                 (
00164                     cmpt,
00165                     scv() & linear
00166                     <
00167                         typename outerProduct
00168                         <
00169                             vector,
00170                             typename pTraits<Type>::cmptType
00171                         >::type
00172                     > (mesh).interpolate
00173                     (
00174                         fv::gaussGrad<typename pTraits<Type>::cmptType>
00175                         (mesh).grad(vf.component(cmpt))
00176                     )
00177                 );
00178             }
00179 
00180             return tsfCorr;
00181         }
00182 
00183 
00184         //- Return the explicit correction to the face-interpolate
00185         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00186         correction
00187         (
00188             const GeometricField<Type, fvPatchField, volMesh>& vf
00189         ) const
00190         {
00191             if
00192             (
00193                 tScheme_().corrected()
00194              && skewCorrectionVectors::New(this->mesh()).skew()
00195             )
00196             {
00197                 return tScheme_().correction(vf) + skewCorrection(vf);
00198             }
00199             else if (tScheme_().corrected())
00200             {
00201                 return tScheme_().correction(vf);
00202             }
00203             else if (skewCorrectionVectors::New(this->mesh()).skew())
00204             {
00205                 return skewCorrection(vf);
00206             }
00207             else
00208             {
00209                 return 
00210                     tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >(NULL);
00211             }
00212         }
00213 };
00214 
00215 
00216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00217 
00218 } // End namespace Foam
00219 
00220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00221 
00222 #endif
00223 
00224 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines