![]() |
|
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 PhiLimiter 00027 00028 Description 00029 Class with limiter function which returns the limiter for the 00030 Phi differencing scheme. 00031 00032 Used in conjunction with the template class PhiScheme. 00033 00034 SourceFiles 00035 Phi.C 00036 00037 \*---------------------------------------------------------------------------*/ 00038 00039 #ifndef Phi_H 00040 #define Phi_H 00041 00042 #include "vector.H" 00043 00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00045 00046 namespace Foam 00047 { 00048 00049 /*---------------------------------------------------------------------------*\ 00050 Class PhiLimiter Declaration 00051 \*---------------------------------------------------------------------------*/ 00052 00053 class PhiLimiter 00054 { 00055 scalar k_; 00056 00057 public: 00058 00059 PhiLimiter(Istream& is) 00060 : 00061 k_(readScalar(is)) 00062 { 00063 if (k_ < 0 || k_ > 1) 00064 { 00065 FatalIOErrorIn("PhiLimiter(Istream& is)", is) 00066 << "coefficient = " << k_ 00067 << " should be >= 0 and <= 1" 00068 << exit(FatalIOError); 00069 } 00070 } 00071 00072 scalar limiter 00073 ( 00074 const scalar cdWeight, 00075 const scalar faceFlux, 00076 const vector& PhiP, 00077 const vector& PhiN, 00078 const vector& Sf, 00079 const scalar& 00080 ) const 00081 { 00082 scalar phiP = Sf&PhiP; 00083 scalar phiN = Sf&PhiN; 00084 00085 scalar phiU; 00086 00087 if (faceFlux > 0) 00088 { 00089 phiU = phiP; 00090 } 00091 else 00092 { 00093 phiU = phiN; 00094 } 00095 00096 scalar phiCD = cdWeight*phiP + (1 - cdWeight)*phiN; 00097 00098 // Calculate the effective limiter for the Phi interpolation 00099 scalar PLimiter = 00100 (1.0 - k_) + k_*(faceFlux - phiU)/stabilise(phiCD - phiU, SMALL); 00101 00102 // Limit the limiter between upwind and central 00103 return max(min(PLimiter, 1.0), 0); 00104 } 00105 }; 00106 00107 00108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00109 00110 } // End namespace Foam 00111 00112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00113 00114 #endif 00115 00116 // ************************************************************************* //