Phi.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2015 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::PhiLimiter
28
29Group
30 grpFvLimitedSurfaceInterpolationSchemes
31
32Description
33 Class with limiter function which returns the limiter for the
34 Phi differencing scheme.
35
36 Used in conjunction with the template class PhiScheme.
37
38SourceFiles
39 Phi.C
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef Phi_H
44#define Phi_H
45
46#include "vector.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52
53/*---------------------------------------------------------------------------*\
54 Class PhiLimiter Declaration
55\*---------------------------------------------------------------------------*/
57class PhiLimiter
58{
59 scalar k_;
60
61public:
64 :
65 k_(readScalar(is))
66 {
67 if (k_ < 0 || k_ > 1)
68 {
70 << "coefficient = " << k_
71 << " should be >= 0 and <= 1"
73 }
74 }
76 scalar limiter
77 (
78 const scalar cdWeight,
79 const scalar faceFlux,
80 const vector& PhiP,
81 const vector& PhiN,
82 const vector& Sf,
83 const scalar&
84 ) const
85 {
86 scalar phiP = Sf&PhiP;
87 scalar phiN = Sf&PhiN;
88
89 scalar phiU;
90
91 if (faceFlux > 0)
92 {
93 phiU = phiP;
94 }
95 else
96 {
97 phiU = phiN;
98 }
99
100 scalar phiCD = cdWeight*phiP + (1 - cdWeight)*phiN;
101
102 // Calculate the effective limiter for the Phi interpolation
103 //scalar PLimiter =
104 // (1.0 - k_) + k_*(faceFlux - phiU)/stabilise(phiCD - phiU, SMALL);
105
106 scalar PLimiter =
107 ((faceFlux - phiU)/stabilise(phiCD - phiU, SMALL) + k_);
108
109 // Limit the limiter between upwind and central
110 return max(min(PLimiter, 1), 0);
111 }
112};
113
114
115// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116
117} // End namespace Foam
118
119// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120
121#endif
122
123// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
Class with limiter function which returns the limiter for the Phi differencing scheme.
Definition: Phi.H:57
PhiLimiter(Istream &is)
Definition: Phi.H:62
scalar limiter(const scalar cdWeight, const scalar faceFlux, const vector &PhiP, const vector &PhiN, const vector &Sf, const scalar &) const
Definition: Phi.H:76
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
IOerror FatalIOError
dimensionedScalar stabilise(const dimensionedScalar &x, const dimensionedScalar &y)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130