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

limitedSnGrad.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     snGrad scheme with limited non-orthogonal correction.
00027 
00028     The limiter is controlled by a coefficient with a value between 0 and 1
00029     which when 0 switches the correction off and the scheme behaves as
00030     uncorrectedSnGrad, when set to 1 the full correction is applied and the
00031     scheme behaves as correctedSnGrad and when set to 0.5 the limiter is
00032     calculated such that the non-orthogonal contribution does not exceed the
00033     orthogonal part.
00034 
00035 \*---------------------------------------------------------------------------*/
00036 
00037 #include "fv.H"
00038 #include "limitedSnGrad.H"
00039 #include "volFields.H"
00040 #include "surfaceFields.H"
00041 #include "correctedSnGrad.H"
00042 #include "localMax.H"
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00050 
00051 namespace fv
00052 {
00053 
00054 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00055 
00056 template<class Type>
00057 limitedSnGrad<Type>::~limitedSnGrad()
00058 {}
00059 
00060 
00061 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00062 
00063 template<class Type>
00064 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00065 limitedSnGrad<Type>::correction
00066 (
00067     const GeometricField<Type, fvPatchField, volMesh>& vf
00068 ) const
00069 {
00070     GeometricField<Type, fvsPatchField, surfaceMesh> corr = 
00071         correctedSnGrad<Type>(this->mesh()).correction(vf);
00072 
00073     surfaceScalarField limiter
00074     (
00075         min
00076         (
00077             limitCoeff_
00078            *mag(snGradScheme<Type>::snGrad(vf, deltaCoeffs(vf), "orthSnGrad"))
00079            /(
00080                 (1 - limitCoeff_)*mag(corr)
00081               + dimensionedScalar("small", corr.dimensions(), SMALL)
00082             ),
00083             dimensionedScalar("one", dimless, 1.0)
00084         )
00085     );
00086 
00087     if (fv::debug)
00088     {
00089         Info<< "limitedSnGrad :: limiter min: " << min(limiter.internalField())
00090             << " max: "<< max(limiter.internalField())
00091             << " avg: " << average(limiter.internalField()) << endl;
00092     }
00093 
00094     return limiter*corr;
00095 }
00096 
00097 
00098 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00099 
00100 } // End namespace fv
00101 
00102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00103 
00104 } // End namespace Foam
00105 
00106 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd