|
|
|
filteredLinear2.HGo 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-2007 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 filteredLinear2Limiter 00027 00028 Description 00029 Class to generate weighting factors for the filtered-linear-2 differencing 00030 scheme. The aim is to remove high-frequency modes with "staggering" 00031 characteristics by comparing the face gradient with both neighbouring cell 00032 gradients and introduce small amounts of upwind in order to damp these 00033 modes. 00034 00035 Used in conjunction with the template class LimitedScheme. 00036 00037 SourceFiles 00038 filteredLinear2.C 00039 00040 \*---------------------------------------------------------------------------*/ 00041 00042 #ifndef filteredLinear2_H 00043 #define filteredLinear2_H 00044 00045 #include "vector.H" 00046 00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00048 00049 namespace Foam 00050 { 00051 00052 /*---------------------------------------------------------------------------*\ 00053 Class filteredLinear2Limiter Declaration 00054 \*---------------------------------------------------------------------------*/ 00055 00056 template<class LimiterFunc> 00057 class filteredLinear2Limiter 00058 : 00059 public LimiterFunc 00060 { 00061 // Private data 00062 00063 // Scaling corefficient for the gradient ratio, 00064 // 0 = linear 00065 // 1 = fully limited 00066 scalar k_; 00067 00068 // Maximum allowed overshoot/undershoot relative to the difference 00069 // across the face. 00070 // On input: 00071 // 0 = no overshoot/undershoot 00072 // 1 = overshoot/undershoot equal to the difference across the face 00073 // Note: After input 1 is added to l_ 00074 scalar l_; 00075 00076 00077 public: 00078 00079 filteredLinear2Limiter(Istream& is) 00080 : 00081 k_(readScalar(is)), 00082 l_(readScalar(is)) 00083 { 00084 if (k_ < 0 || k_ > 1) 00085 { 00086 FatalIOErrorIn("filteredLinearV2Limiter(Istream& is)", is) 00087 << "coefficient = " << k_ 00088 << " should be >= 0 and <= 1" 00089 << exit(FatalIOError); 00090 } 00091 00092 if (l_ < 0 || l_ > 1) 00093 { 00094 FatalIOErrorIn("filteredLinearV2Limiter(Istream& is)", is) 00095 << "coefficient = " << l_ 00096 << " should be >= 0 and <= 1" 00097 << exit(FatalIOError); 00098 } 00099 00100 l_ += 1.0; 00101 } 00102 00103 scalar limiter 00104 ( 00105 const scalar cdWeight, 00106 const scalar faceFlux, 00107 const typename LimiterFunc::phiType& phiP, 00108 const typename LimiterFunc::phiType& phiN, 00109 const typename LimiterFunc::gradPhiType& gradcP, 00110 const typename LimiterFunc::gradPhiType& gradcN, 00111 const vector& d 00112 ) const 00113 { 00114 // Difference across face 00115 scalar df = phiN - phiP; 00116 00117 // Twice the differences across face-neighbour cells 00118 scalar tdcP = 2*(d & gradcP); 00119 scalar tdcN = 2*(d & gradcN); 00120 00121 // Calculate the limiter according to the sign of the face difference 00122 scalar limiter; 00123 00124 if (df > 0) 00125 { 00126 limiter = l_ 00127 - k_*min(max(df - tdcP, 0), max(df - tdcN, 0)) 00128 /(max(mag(df), max(mag(tdcP), mag(tdcN))) + SMALL); 00129 } 00130 else 00131 { 00132 limiter = l_ 00133 - k_*min(max(tdcP - df, 0), max(tdcN - df, 0)) 00134 /(max(mag(df), max(mag(tdcP), mag(tdcN))) + SMALL); 00135 } 00136 00137 // Limit the limiter between linear and upwind 00138 return max(min(limiter, 1), 0); 00139 } 00140 }; 00141 00142 00143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00144 00145 } // End namespace Foam 00146 00147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00148 00149 #endif 00150 00151 // ************************************************************************* // |