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

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