00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 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 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your 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, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::PhiLimiter 00026 00027 Description 00028 Class with limiter function which returns the limiter for the 00029 Phi differencing scheme. 00030 00031 Used in conjunction with the template class PhiScheme. 00032 00033 SourceFiles 00034 Phi.C 00035 00036 \*---------------------------------------------------------------------------*/ 00037 00038 #ifndef Phi_H 00039 #define Phi_H 00040 00041 #include <OpenFOAM/vector.H> 00042 00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00044 00045 namespace Foam 00046 { 00047 00048 /*---------------------------------------------------------------------------*\ 00049 Class PhiLimiter Declaration 00050 \*---------------------------------------------------------------------------*/ 00051 00052 class PhiLimiter 00053 { 00054 scalar k_; 00055 00056 public: 00057 00058 PhiLimiter(Istream& is) 00059 : 00060 k_(readScalar(is)) 00061 { 00062 if (k_ < 0 || k_ > 1) 00063 { 00064 FatalIOErrorIn("PhiLimiter(Istream& is)", is) 00065 << "coefficient = " << k_ 00066 << " should be >= 0 and <= 1" 00067 << exit(FatalIOError); 00068 } 00069 } 00070 00071 scalar limiter 00072 ( 00073 const scalar cdWeight, 00074 const scalar faceFlux, 00075 const vector& PhiP, 00076 const vector& PhiN, 00077 const vector& Sf, 00078 const scalar& 00079 ) const 00080 { 00081 scalar phiP = Sf&PhiP; 00082 scalar phiN = Sf&PhiN; 00083 00084 scalar phiU; 00085 00086 if (faceFlux > 0) 00087 { 00088 phiU = phiP; 00089 } 00090 else 00091 { 00092 phiU = phiN; 00093 } 00094 00095 scalar phiCD = cdWeight*phiP + (1 - cdWeight)*phiN; 00096 00097 // Calculate the effective limiter for the Phi interpolation 00098 //scalar PLimiter = 00099 // (1.0 - k_) + k_*(faceFlux - phiU)/stabilise(phiCD - phiU, SMALL); 00100 00101 scalar PLimiter = 00102 ((faceFlux - phiU)/stabilise(phiCD - phiU, SMALL) + k_); 00103 00104 // Limit the limiter between upwind and central 00105 return max(min(PLimiter, 1), 0); 00106 } 00107 }; 00108 00109 00110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00111 00112 } // End namespace Foam 00113 00114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00115 00116 #endif 00117 00118 // ************************ vim: set sw=4 sts=4 et: ************************ //