1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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
29 Class with limiter function which returns the limiter for the
30 Phi differencing scheme.
32 Used in conjunction with the template class PhiScheme.
37 \*---------------------------------------------------------------------------*/
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 /*---------------------------------------------------------------------------*\
50 Class PhiLimiter Declaration
51 \*---------------------------------------------------------------------------*/
59 PhiLimiter(Istream& is)
65 FatalIOErrorIn("PhiLimiter(Istream& is)", is)
66 << "coefficient = " << k_
67 << " should be >= 0 and <= 1"
68 << exit(FatalIOError);
74 const scalar cdWeight,
75 const scalar faceFlux,
82 scalar phiP = Sf&PhiP;
83 scalar phiN = Sf&PhiN;
96 scalar phiCD = cdWeight*phiP + (1 - cdWeight)*phiN;
98 // Calculate the effective limiter for the Phi interpolation
100 // (1.0 - k_) + k_*(faceFlux - phiU)/stabilise(phiCD - phiU, SMALL);
103 ((faceFlux - phiU)/stabilise(phiCD - phiU, SMALL) + k_);
105 // Limit the limiter between upwind and central
106 return max(min(PLimiter, 1), 0);
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113 } // End namespace Foam
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
119 // ************************************************************************* //