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

cubic.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::cubic
00026 
00027 Description
00028     Cubic interpolation scheme class derived from linear and returns
00029     linear weighting factors but also applies an explicit correction.
00030 
00031 SourceFiles
00032     cubic.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef cubic_H
00037 #define cubic_H
00038 
00039 #include <finiteVolume/linear.H>
00040 #include <finiteVolume/gaussGrad.H>
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace Foam
00045 {
00046 
00047 /*---------------------------------------------------------------------------*\
00048                            Class cubic Declaration
00049 \*---------------------------------------------------------------------------*/
00050 
00051 template<class Type>
00052 class cubic
00053 :
00054     public linear<Type>
00055 {
00056     // Private Member Functions
00057 
00058         //- Disallow default bitwise copy construct
00059         cubic(const cubic&);
00060 
00061         //- Disallow default bitwise assignment
00062         void operator=(const cubic&);
00063 
00064 
00065 public:
00066 
00067     //- Runtime type information
00068     TypeName("cubic");
00069 
00070 
00071     // Constructors
00072 
00073         //- Construct from mesh
00074         cubic(const fvMesh& mesh)
00075         :
00076             linear<Type>(mesh)
00077         {}
00078 
00079         //- Construct from mesh and Istream
00080         cubic
00081         (
00082             const fvMesh& mesh,
00083             Istream&
00084         )
00085         :
00086             linear<Type>(mesh)
00087         {}
00088 
00089         //- Construct from mesh, faceFlux and Istream
00090         cubic
00091         (
00092             const fvMesh& mesh,
00093             const surfaceScalarField&,
00094             Istream&
00095         )
00096         :
00097             linear<Type>(mesh)
00098         {}
00099 
00100 
00101     // Member Functions
00102 
00103         //- Return true if this scheme uses an explicit correction
00104         virtual bool corrected() const
00105         {
00106             return true;
00107         }
00108 
00109         //- Return the explicit correction to the face-interpolate
00110         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00111         correction
00112         (
00113             const GeometricField<Type, fvPatchField, volMesh>& vf
00114         ) const
00115         {
00116             const fvMesh& mesh = this->mesh();
00117 
00118             // calculate the appropriate interpolation factors
00119             const surfaceScalarField& lambda = mesh.weights();
00120 
00121             surfaceScalarField kSc = 
00122                 lambda*(scalar(1) - lambda*(scalar(3) - scalar(2)*lambda));
00123 
00124             surfaceScalarField kVecP = sqr(scalar(1) - lambda)*lambda;
00125             surfaceScalarField kVecN = sqr(lambda)*(lambda - scalar(1));
00126 
00127             tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
00128             (
00129                 new GeometricField<Type, fvsPatchField, surfaceMesh>
00130                 (
00131                     IOobject
00132                     (
00133                         vf.name(),
00134                         mesh.time().timeName(),
00135                         mesh
00136                     ),
00137                     surfaceInterpolationScheme<Type>::interpolate(vf, kSc, -kSc)
00138                 )
00139             );
00140 
00141             GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr();
00142 
00143             for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00144             {
00145                 sfCorr.replace
00146                 (
00147                     cmpt,
00148                     sfCorr.component(cmpt)
00149                   + (
00150                         surfaceInterpolationScheme
00151                         <
00152                             typename outerProduct
00153                             <
00154                                 vector,
00155                                 typename pTraits<Type>::cmptType
00156                             >::type
00157                         >::interpolate
00158                         (
00159                             fv::gaussGrad
00160                             <typename pTraits<Type>::cmptType>(mesh)
00161                            .grad(vf.component(cmpt)),
00162                             kVecP,
00163                             kVecN
00164                         ) & mesh.Sf()
00165                     )/mesh.magSf()/mesh.surfaceInterpolation::deltaCoeffs()
00166                 );
00167             }
00168 
00169             forAll (sfCorr.boundaryField(), pi)
00170             {
00171                 if (!sfCorr.boundaryField()[pi].coupled())
00172                 {
00173                     sfCorr.boundaryField()[pi] = pTraits<Type>::zero;
00174                 }
00175             }
00176 
00177             return tsfCorr;
00178         }
00179 };
00180 
00181 
00182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00183 
00184 } // End namespace Foam
00185 
00186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00187 
00188 #endif
00189 
00190 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines