|
|
|
filteredLinear2V.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 filteredLinear2VLimiter 00027 00028 Description 00029 Class to generate weighting factors for the filteredLinear2V differencing 00030 scheme. The aim is to remove high-frequency modes with "staggering" 00031 characteristics from vector fields by comparing the face gradient in the 00032 direction of maximum gradient with both neighbouring cell gradients and 00033 introduce small amounts of upwind in order to damp these modes. 00034 00035 Used in conjunction with the template class LimitedScheme. 00036 00037 SourceFiles 00038 filteredLinear2V.C 00039 00040 \*---------------------------------------------------------------------------*/ 00041 00042 #ifndef filteredLinear2V_H 00043 #define filteredLinear2V_H 00044 00045 #include "vector.H" 00046 00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00048 00049 namespace Foam 00050 { 00051 00052 /*---------------------------------------------------------------------------*\ 00053 Class filteredLinear2VLimiter Declaration 00054 \*---------------------------------------------------------------------------*/ 00055 00056 template<class LimiterFunc> 00057 class filteredLinear2VLimiter 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 filteredLinear2VLimiter(Istream& is) 00080 : 00081 k_(readScalar(is)), 00082 l_(readScalar(is)) 00083 { 00084 if (k_ < 0 || k_ > 1) 00085 { 00086 FatalIOErrorIn("filteredLinear2VLimiter(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("filteredLinear2VLimiter(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 vector dfV = phiN - phiP; 00116 00117 // Scalar difference across the face 00118 // in the direction in which the difference is largest 00119 scalar df = dfV & dfV; 00120 00121 // Twice differences across face-neighbour cells 00122 // in the direction in which the face-difference is largest 00123 scalar tdcP = 2*(dfV & (d & gradcP)); 00124 scalar tdcN = 2*(dfV & (d & gradcN)); 00125 00126 // Calculate the limiter according to the sign of the face difference 00127 scalar limiter; 00128 00129 if (df > 0) 00130 { 00131 limiter = l_ 00132 - k_*min(max(df - tdcP, 0), max(df - tdcN, 0)) 00133 /(max(mag(df), max(mag(tdcP), mag(tdcN))) + VSMALL); 00134 } 00135 else 00136 { 00137 limiter = l_ 00138 - k_*min(max(tdcP - df, 0), max(tdcN - df, 0)) 00139 /(max(mag(df), max(mag(tdcP), mag(tdcN))) + VSMALL); 00140 } 00141 00142 // Limit the limiter between linear and upwind 00143 return max(min(limiter, 1), 0); 00144 } 00145 }; 00146 00147 00148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00149 00150 } // End namespace Foam 00151 00152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00153 00154 #endif 00155 00156 // ************************************************************************* // |