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

correctedSnGrad.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 Description
00026     Simple central-difference snGrad scheme with non-orthogonal correction.
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #include "correctedSnGrad.H"
00031 #include "volFields.H"
00032 #include "surfaceFields.H"
00033 #include "linear.H"
00034 #include "fvcGrad.H"
00035 #include "gaussGrad.H"
00036 
00037 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00038 
00039 namespace Foam
00040 {
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace fv
00045 {
00046 
00047 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00048 
00049 template<class Type>
00050 correctedSnGrad<Type>::~correctedSnGrad()
00051 {}
00052 
00053 
00054 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00055 
00056 template<class Type>
00057 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00058 correctedSnGrad<Type>::correction
00059 (
00060     const GeometricField<Type, fvPatchField, volMesh>& vf
00061 ) const
00062 {
00063     const fvMesh& mesh = this->mesh();
00064 
00065     // construct GeometricField<Type, fvsPatchField, surfaceMesh>
00066     tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tssf
00067     (
00068         new GeometricField<Type, fvsPatchField, surfaceMesh>
00069         (
00070             IOobject
00071             (
00072                 "snGradCorr("+vf.name()+')',
00073                 vf.instance(),
00074                 mesh,
00075                 IOobject::NO_READ,
00076                 IOobject::NO_WRITE
00077             ),
00078             mesh,
00079             vf.dimensions()*mesh.deltaCoeffs().dimensions()
00080         )
00081     );
00082     GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tssf();
00083 
00084     for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
00085     {
00086         ssf.replace
00087         (
00088             cmpt,
00089             mesh.correctionVectors()
00090           & linear
00091             <
00092                 typename 
00093                 outerProduct<vector, typename pTraits<Type>::cmptType>::type
00094             >(mesh).interpolate
00095             (
00096                 gradScheme<typename pTraits<Type>::cmptType>::New
00097                 (
00098                     mesh,
00099                     mesh.gradScheme(ssf.name())
00100                 )()
00101                 //gaussGrad<typename pTraits<Type>::cmptType>(mesh)
00102                .grad(vf.component(cmpt))
00103             )
00104         );
00105     }
00106 
00107     return tssf;
00108 }
00109 
00110 
00111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00112 
00113 } // End namespace fv
00114 
00115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00116 
00117 } // End namespace Foam
00118 
00119 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd