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

gaussLaplacianSchemes.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 "gaussLaplacianScheme.H"
00028 #include "fvMesh.H"
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 namespace fv
00035 {
00036     makeFvLaplacianScheme(gaussLaplacianScheme)
00037 }
00038 }
00039 
00040 #define declareFvmLaplacianScalarGamma(Type)                                 \
00041                                                                              \
00042 template<>                                                                   \
00043 Foam::tmp<Foam::fvMatrix<Foam::Type> >                                       \
00044 Foam::fv::gaussLaplacianScheme<Foam::Type, Foam::scalar>::fvmLaplacian       \
00045 (                                                                            \
00046     const GeometricField<scalar, fvsPatchField, surfaceMesh>& gamma,         \
00047     GeometricField<Type, fvPatchField, volMesh>& vf                          \
00048 )                                                                            \
00049 {                                                                            \
00050     const fvMesh& mesh = this->mesh();                                       \
00051                                                                              \
00052     GeometricField<scalar, fvsPatchField, surfaceMesh> gammaMagSf            \
00053     (                                                                        \
00054         gamma*mesh.magSf()                                                   \
00055     );                                                                       \
00056                                                                              \
00057     tmp<fvMatrix<Type> > tfvm = fvmLaplacianUncorrected(gammaMagSf, vf);     \
00058     fvMatrix<Type>& fvm = tfvm();                                            \
00059                                                                              \
00060     if (this->tsnGradScheme_().corrected())                                  \
00061     {                                                                        \
00062         if (mesh.fluxRequired(vf.name()))                                    \
00063         {                                                                    \
00064             fvm.faceFluxCorrectionPtr() = new                                \
00065             GeometricField<Type, fvsPatchField, surfaceMesh>                 \
00066             (                                                                \
00067                 gammaMagSf*this->tsnGradScheme_().correction(vf)             \
00068             );                                                               \
00069                                                                              \
00070             fvm.source() -=                                                  \
00071                 mesh.V()*                                                    \
00072                 fvc::div                                                     \
00073                 (                                                            \
00074                     *fvm.faceFluxCorrectionPtr()                             \
00075                 )().internalField();                                         \
00076         }                                                                    \
00077         else                                                                 \
00078         {                                                                    \
00079             fvm.source() -=                                                  \
00080                 mesh.V()*                                                    \
00081                 fvc::div                                                     \
00082                 (                                                            \
00083                     gammaMagSf*this->tsnGradScheme_().correction(vf)         \
00084                 )().internalField();                                         \
00085         }                                                                    \
00086     }                                                                        \
00087                                                                              \
00088     return tfvm;                                                             \
00089 }                                                                            \
00090                                                                              \
00091                                                                              \
00092 template<>                                                                   \
00093 Foam::tmp<Foam::GeometricField<Foam::Type, Foam::fvPatchField, Foam::volMesh> >\
00094 Foam::fv::gaussLaplacianScheme<Foam::Type, Foam::scalar>::fvcLaplacian       \
00095 (                                                                            \
00096     const GeometricField<scalar, fvsPatchField, surfaceMesh>& gamma,         \
00097     const GeometricField<Type, fvPatchField, volMesh>& vf                    \
00098 )                                                                            \
00099 {                                                                            \
00100     const fvMesh& mesh = this->mesh();                                       \
00101                                                                              \
00102     tmp<GeometricField<Type, fvPatchField, volMesh> > tLaplacian             \
00103     (                                                                        \
00104         fvc::div(gamma*this->tsnGradScheme_().snGrad(vf)*mesh.magSf())       \
00105     );                                                                       \
00106                                                                              \
00107     tLaplacian().rename("laplacian(" + gamma.name() + ',' + vf.name() + ')');\
00108                                                                              \
00109     return tLaplacian;                                                       \
00110 }
00111 
00112 
00113 declareFvmLaplacianScalarGamma(scalar);
00114 declareFvmLaplacianScalarGamma(vector);
00115 declareFvmLaplacianScalarGamma(sphericalTensor);
00116 declareFvmLaplacianScalarGamma(symmTensor);
00117 declareFvmLaplacianScalarGamma(tensor);
00118 
00119 
00120 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd