OpenFOAM logo
Open Source CFD Toolkit

Gamma.H

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-2005 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 Class
00026     Gamma
00027 
00028 Description
00029     Class with operator() which returns the weighting factors for the
00030     Gamma differencing scheme.  Used in conjunction with the template class
00031     NVDscheme.
00032 
00033 SourceFiles
00034     GammaMake.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef Gamma_H
00039 #define Gamma_H
00040 
00041 #include "scalar.H"
00042 #include "vector.H"
00043 #include "Istream.H"
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 /*---------------------------------------------------------------------------*\
00051                            Class GammaWeight Declaration
00052 \*---------------------------------------------------------------------------*/
00053 
00054 class GammaWeight
00055 {
00056     scalar k_;
00057 
00058 public:
00059 
00060     GammaWeight(Istream& is)
00061     :
00062         k_(readScalar(is))
00063     {
00064         if (k_ < 0 || k_ > 1)
00065         {
00066             FatalIOErrorIn("GammaWeight(Istream& is)", is)
00067                 << "coefficient = " << k_
00068                 << " should be >= 0 and <= 1"
00069                 << exit(FatalIOError);
00070         }
00071 
00072         // Rescale k_ to be >= 0 and <= 0.5 (TVD conformant)
00073         // and avoid the /0 when k_ = 0
00074         k_ = max(k_/2.0, SMALL);
00075     }
00076 
00077 
00078     scalar weight
00079     (
00080         scalar cdWeight,
00081         scalar faceFlux,
00082         scalar phiP,
00083         scalar phiN,
00084         const vector& gradcP,
00085         const vector& gradcN,
00086         const vector& d
00087     ) const
00088     {
00089         scalar magd = mag(d);
00090         vector dHat = d/mag(d);
00091 
00092         scalar gradf = (phiN - phiP)/magd;
00093 
00094         scalar gradcf;
00095         scalar udWeight;
00096 
00097         if (faceFlux > 0)
00098         {
00099             gradcf = dHat & gradcP;
00100             udWeight = 1;
00101         }
00102         else
00103         {
00104             gradcf = dHat & gradcN;
00105             udWeight = 0;
00106         }
00107 
00108         // Stabilise for division
00109         gradcf = stabilise(gradcf, SMALL);
00110 
00111         scalar phict = 1 - 0.5*gradf/gradcf;
00112         scalar limiter = min(max(phict/k_, 0), 1);
00113 
00114         return limiter*cdWeight + (1 - limiter)*udWeight;
00115     }
00116 };
00117 
00118 
00119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00120 
00121 } // End namespace Foam
00122 
00123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00124 
00125 #endif
00126 
00127 // ************************************************************************* //
For further information go to www.openfoam.org