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::filteredLinear3Limiter 00026 00027 Description 00028 Class to generate weighting factors for the filteredLinear 00029 differencing scheme. 00030 00031 The aim is to remove high-frequency modes with "staggering" 00032 characteristics by comparing the face gradient with both neighbouring 00033 cell gradients and introduce small amounts of upwind in order to damp 00034 these modes. 00035 00036 Used in conjunction with the template class LimitedScheme. 00037 00038 SourceFiles 00039 filteredLinear3.C 00040 00041 \*---------------------------------------------------------------------------*/ 00042 00043 #ifndef filteredLinear3_H 00044 #define filteredLinear3_H 00045 00046 #include <OpenFOAM/vector.H> 00047 00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00049 00050 namespace Foam 00051 { 00052 00053 /*---------------------------------------------------------------------------*\ 00054 Class filteredLinear3Limiter Declaration 00055 \*---------------------------------------------------------------------------*/ 00056 00057 template<class LimiterFunc> 00058 class filteredLinear3Limiter 00059 : 00060 public LimiterFunc 00061 { 00062 // Private data 00063 00064 // Scaling corefficient for the gradient ratio, 00065 // 0 = linear 00066 // 1 = fully limited 00067 scalar k_; 00068 00069 public: 00070 00071 filteredLinear3Limiter(Istream& is) 00072 : 00073 k_(readScalar(is)) 00074 { 00075 if (k_ < 0 || k_ > 1) 00076 { 00077 FatalIOErrorIn("filteredLinear3Limiter(Istream& is)", is) 00078 << "coefficient = " << k_ 00079 << " should be >= 0 and <= 1" 00080 << exit(FatalIOError); 00081 } 00082 } 00083 00084 scalar limiter 00085 ( 00086 const scalar cdWeight, 00087 const scalar faceFlux, 00088 const typename LimiterFunc::phiType& phiP, 00089 const typename LimiterFunc::phiType& phiN, 00090 const typename LimiterFunc::gradPhiType& gradcP, 00091 const typename LimiterFunc::gradPhiType& gradcN, 00092 const vector& d 00093 ) const 00094 { 00095 // Difference across face 00096 scalar df = phiN - phiP; 00097 00098 // Twice the differences across face-neighbour cells 00099 scalar dP = 2*(d & gradcP); 00100 scalar dN = 2*(d & gradcN); 00101 00102 // Calculate the limiter 00103 scalar limiter = 1 - k_*(dN - df)*(dP - df)/max(sqr(dN + dP), SMALL); 00104 00105 // Limit the limiter between linear and upwind 00106 return max(min(limiter, 1), 0); 00107 } 00108 }; 00109 00110 00111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00112 00113 } // End namespace Foam 00114 00115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00116 00117 #endif 00118 00119 // ************************ vim: set sw=4 sts=4 et: ************************ //