1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Foam::filteredLinear2Limiter
29 Class to generate weighting factors for the filteredLinear2
32 The aim is to remove high-frequency modes with "staggering"
33 characteristics by comparing the face gradient with both neighbouring
34 cell gradients and introduce small amounts of upwind in order to damp
37 Used in conjunction with the template class LimitedScheme.
42 \*---------------------------------------------------------------------------*/
44 #ifndef filteredLinear2_H
45 #define filteredLinear2_H
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 /*---------------------------------------------------------------------------*\
55 Class filteredLinear2Limiter Declaration
56 \*---------------------------------------------------------------------------*/
58 template<class LimiterFunc>
59 class filteredLinear2Limiter
65 // Scaling corefficient for the gradient ratio,
70 // Maximum allowed overshoot/undershoot relative to the difference
73 // 0 = no overshoot/undershoot
74 // 1 = overshoot/undershoot equal to the difference across the face
75 // Note: After input 1 is added to l_
81 filteredLinear2Limiter(Istream& is)
88 FatalIOErrorIn("filteredLinearV2Limiter(Istream& is)", is)
89 << "coefficient = " << k_
90 << " should be >= 0 and <= 1"
91 << exit(FatalIOError);
96 FatalIOErrorIn("filteredLinearV2Limiter(Istream& is)", is)
97 << "coefficient = " << l_
98 << " should be >= 0 and <= 1"
99 << exit(FatalIOError);
107 const scalar cdWeight,
108 const scalar faceFlux,
109 const typename LimiterFunc::phiType& phiP,
110 const typename LimiterFunc::phiType& phiN,
111 const typename LimiterFunc::gradPhiType& gradcP,
112 const typename LimiterFunc::gradPhiType& gradcN,
116 // Difference across face
117 scalar df = phiN - phiP;
119 // Twice the differences across face-neighbour cells
120 scalar tdcP = 2*(d & gradcP);
121 scalar tdcN = 2*(d & gradcN);
123 // Calculate the limiter according to the sign of the face difference
129 - k_*min(max(df - tdcP, 0), max(df - tdcN, 0))
130 /(max(mag(df), max(mag(tdcP), mag(tdcN))) + SMALL);
135 - k_*min(max(tdcP - df, 0), max(tdcN - df, 0))
136 /(max(mag(df), max(mag(tdcP), mag(tdcN))) + SMALL);
139 // Limit the limiter between linear and upwind
140 return max(min(limiter, 1), 0);
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 } // End namespace Foam
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 // ************************************************************************* //