initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / finiteVolume / finiteVolume / convectionSchemes / gaussConvectionScheme / gaussConvectionScheme.C
bloba219d8028167646cb5f3fc7e79e563db18174c70
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "gaussConvectionScheme.H"
28 #include "fvcSurfaceIntegrate.H"
29 #include "fvMatrices.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 namespace fv
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 template<class Type>
44 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
45 gaussConvectionScheme<Type>::interpolate
47     const surfaceScalarField&,
48     const GeometricField<Type, fvPatchField, volMesh>& vf
49 ) const
51     return tinterpScheme_().interpolate(vf);
55 template<class Type>
56 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
57 gaussConvectionScheme<Type>::flux
59     const surfaceScalarField& faceFlux,
60     const GeometricField<Type, fvPatchField, volMesh>& vf
61 ) const
63     return faceFlux*interpolate(faceFlux, vf);
67 template<class Type>
68 tmp<fvMatrix<Type> >
69 gaussConvectionScheme<Type>::fvmDiv
71     const surfaceScalarField& faceFlux,
72     GeometricField<Type, fvPatchField, volMesh>& vf
73 ) const
75     tmp<surfaceScalarField> tweights = tinterpScheme_().weights(vf);
76     const surfaceScalarField& weights = tweights();
78     tmp<fvMatrix<Type> > tfvm
79     (
80         new fvMatrix<Type>
81         (
82             vf,
83             faceFlux.dimensions()*vf.dimensions()
84         )
85     );
86     fvMatrix<Type>& fvm = tfvm();
88     fvm.lower() = -weights.internalField()*faceFlux.internalField();
89     fvm.upper() = fvm.lower() + faceFlux.internalField();
90     fvm.negSumDiag();
92     forAll(fvm.psi().boundaryField(), patchI)
93     {
94         const fvPatchField<Type>& psf = fvm.psi().boundaryField()[patchI];
95         const fvsPatchScalarField& patchFlux = faceFlux.boundaryField()[patchI];
96         const fvsPatchScalarField& pw = weights.boundaryField()[patchI];
98         fvm.internalCoeffs()[patchI] = patchFlux*psf.valueInternalCoeffs(pw);
99         fvm.boundaryCoeffs()[patchI] = -patchFlux*psf.valueBoundaryCoeffs(pw);
100     }
102     if (tinterpScheme_().corrected())
103     {
104         fvm += fvc::surfaceIntegrate(faceFlux*tinterpScheme_().correction(vf));
105     }
107     return tfvm;
111 template<class Type>
112 tmp<GeometricField<Type, fvPatchField, volMesh> >
113 gaussConvectionScheme<Type>::fvcDiv
115     const surfaceScalarField& faceFlux,
116     const GeometricField<Type, fvPatchField, volMesh>& vf
117 ) const
119     tmp<GeometricField<Type, fvPatchField, volMesh> > tConvection
120     (
121         fvc::surfaceIntegrate(flux(faceFlux, vf))
122     );
124     tConvection().rename
125     (
126         "convection(" + faceFlux.name() + ',' + vf.name() + ')'
127     );
129     return tConvection;
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 } // End namespace fv
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 } // End namespace Foam
141 // ************************************************************************* //