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::filteredLinearLimiter
29 Class to generate weighting factors for the filteredLinear
32 The aim is to remove high-frequency modes with "staggering"
33 characteristics by comparing the face gradient relative to the
34 background distribution represented by the neighbouring cell gradients
35 with those gradients and introduce small amounts of upwind in order to
38 Used in conjunction with the template class LimitedScheme.
43 \*---------------------------------------------------------------------------*/
45 #ifndef filteredLinear_H
46 #define filteredLinear_H
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 /*---------------------------------------------------------------------------*\
56 Class filteredLinearWeight Declaration
57 \*---------------------------------------------------------------------------*/
59 template<class LimiterFunc>
60 class filteredLinearLimiter
67 filteredLinearLimiter(Istream&)
72 const scalar cdWeight,
73 const scalar faceFlux,
74 const typename LimiterFunc::phiType& phiP,
75 const typename LimiterFunc::phiType& phiN,
76 const typename LimiterFunc::gradPhiType& gradcP,
77 const typename LimiterFunc::gradPhiType& gradcN,
81 scalar df = phiN - phiP;
83 scalar dcP = d & gradcP;
84 scalar dcN = d & gradcN;
88 - 0.5*min(mag(df - dcP), mag(df - dcN))
89 /(max(mag(dcP), mag(dcN)) + SMALL);
91 // Limit the limiter between linear and 20% upwind
92 return max(min(limiter, 1), 0.8);
97 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99 } // End namespace Foam
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105 // ************************************************************************* //