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

gaussConvectionScheme.C

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 \*---------------------------------------------------------------------------*/
00025 
00026 #include "gaussConvectionScheme.H"
00027 #include <finiteVolume/fvcSurfaceIntegrate.H>
00028 #include <finiteVolume/fvMatrices.H>
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00036 
00037 namespace fv
00038 {
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00041 
00042 template<class Type>
00043 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00044 gaussConvectionScheme<Type>::interpolate
00045 (
00046     const surfaceScalarField&,
00047     const GeometricField<Type, fvPatchField, volMesh>& vf
00048 ) const
00049 {
00050     return tinterpScheme_().interpolate(vf);
00051 }
00052 
00053 
00054 template<class Type>
00055 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00056 gaussConvectionScheme<Type>::flux
00057 (
00058     const surfaceScalarField& faceFlux,
00059     const GeometricField<Type, fvPatchField, volMesh>& vf
00060 ) const
00061 {
00062     return faceFlux*interpolate(faceFlux, vf);
00063 }
00064 
00065 
00066 template<class Type>
00067 tmp<fvMatrix<Type> >
00068 gaussConvectionScheme<Type>::fvmDiv
00069 (
00070     const surfaceScalarField& faceFlux,
00071     GeometricField<Type, fvPatchField, volMesh>& vf
00072 ) const
00073 {
00074     tmp<surfaceScalarField> tweights = tinterpScheme_().weights(vf);
00075     const surfaceScalarField& weights = tweights();
00076 
00077     tmp<fvMatrix<Type> > tfvm
00078     (
00079         new fvMatrix<Type>
00080         (
00081             vf,
00082             faceFlux.dimensions()*vf.dimensions()
00083         )
00084     );
00085     fvMatrix<Type>& fvm = tfvm();
00086 
00087     fvm.lower() = -weights.internalField()*faceFlux.internalField();
00088     fvm.upper() = fvm.lower() + faceFlux.internalField();
00089     fvm.negSumDiag();
00090 
00091     forAll(fvm.psi().boundaryField(), patchI)
00092     {
00093         const fvPatchField<Type>& psf = fvm.psi().boundaryField()[patchI];
00094         const fvsPatchScalarField& patchFlux = faceFlux.boundaryField()[patchI];
00095         const fvsPatchScalarField& pw = weights.boundaryField()[patchI];
00096 
00097         fvm.internalCoeffs()[patchI] = patchFlux*psf.valueInternalCoeffs(pw);
00098         fvm.boundaryCoeffs()[patchI] = -patchFlux*psf.valueBoundaryCoeffs(pw);
00099     }
00100 
00101     if (tinterpScheme_().corrected())
00102     {
00103         fvm += fvc::surfaceIntegrate(faceFlux*tinterpScheme_().correction(vf));
00104     }
00105 
00106     return tfvm;
00107 }
00108 
00109 
00110 template<class Type>
00111 tmp<GeometricField<Type, fvPatchField, volMesh> >
00112 gaussConvectionScheme<Type>::fvcDiv
00113 (
00114     const surfaceScalarField& faceFlux,
00115     const GeometricField<Type, fvPatchField, volMesh>& vf
00116 ) const
00117 {
00118     tmp<GeometricField<Type, fvPatchField, volMesh> > tConvection
00119     (
00120         fvc::surfaceIntegrate(flux(faceFlux, vf))
00121     );
00122 
00123     tConvection().rename
00124     (
00125         "convection(" + faceFlux.name() + ',' + vf.name() + ')'
00126     );
00127 
00128     return tConvection;
00129 }
00130 
00131 
00132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00133 
00134 } // End namespace fv
00135 
00136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00137 
00138 } // End namespace Foam
00139 
00140 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines