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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::PhiLimiter
28 
29 Group
30  grpFvLimitedSurfaceInterpolationSchemes
31 
32 Description
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 
38 SourceFiles
39  Phi.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef Phi_H
44 #define Phi_H
45 
46 #include "vector.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class PhiLimiter Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class PhiLimiter
58 {
59  scalar k_;
60 
61 public:
62 
63  PhiLimiter(Istream& is)
64  :
65  k_(readScalar(is))
66  {
67  if (k_ < 0 || k_ > 1)
68  {
70  << "coefficient = " << k_
71  << " should be >= 0 and <= 1"
72  << exit(FatalIOError);
73  }
74  }
75 
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 // ************************************************************************* //
Foam::PhiLimiter
Class with limiter function which returns the limiter for the Phi differencing scheme.
Definition: Phi.H:56
Foam::FatalIOError
IOerror FatalIOError
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::stabilise
tmp< DimensionedField< scalar, GeoMesh > > stabilise(const DimensionedField< scalar, GeoMesh > &dsf, const dimensioned< scalar > &ds)
Definition: DimensionedScalarField.C:43
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::PhiLimiter::PhiLimiter
PhiLimiter(Istream &is)
Definition: Phi.H:62
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::Vector< scalar >
vector.H
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:401
Foam::PhiLimiter::limiter
scalar limiter(const scalar cdWeight, const scalar faceFlux, const vector &PhiP, const vector &PhiN, const vector &Sf, const scalar &) const
Definition: Phi.H:76