limitedCubic.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::limitedCubicLimiter
28
29Group
30 grpFvLimitedSurfaceInterpolationSchemes
31
32Description
33 Class with limiter function which returns the limiter for the
34 TVD limited centred-cubic differencing scheme based on r obtained from
35 the LimiterFunc class.
36
37 Used in conjunction with the template class LimitedScheme.
38
39SourceFiles
40 limitedCubic.C
41
42\*---------------------------------------------------------------------------*/
43
44#ifndef limitedCubic_H
45#define limitedCubic_H
46
47#include "vector.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
53
54/*---------------------------------------------------------------------------*\
55 Class limitedCubicLimiter Declaration
56\*---------------------------------------------------------------------------*/
57
58template<class LimiterFunc>
60:
61 public LimiterFunc
62{
63 scalar k_;
64 scalar twoByk_;
65
66public:
69 :
70 k_(readScalar(is))
71 {
72 if (k_ < 0 || k_ > 1)
73 {
75 << "coefficient = " << k_
76 << " should be >= 0 and <= 1"
78 }
79
80 // Avoid the /0 when k_ = 0
81 twoByk_ = 2.0/max(k_, SMALL);
82 }
84 scalar limiter
85 (
86 const scalar cdWeight,
87 const scalar faceFlux,
88 const typename LimiterFunc::phiType& phiP,
89 const typename LimiterFunc::phiType& phiN,
90 const typename LimiterFunc::gradPhiType& gradcP,
91 const typename LimiterFunc::gradPhiType& gradcN,
92 const vector& d
93 ) const
94 {
95 scalar twor = twoByk_*LimiterFunc::r
96 (
97 faceFlux, phiP, phiN, gradcP, gradcN, d
98 );
99
100 scalar phiU;
101
102 if (faceFlux > 0)
103 {
104 phiU = phiP;
105 }
106 else
107 {
108 phiU = phiN;
109 }
110
111 // Calculate the face value using cubic interpolation
112 scalar phif =
113 cdWeight*(phiP - 0.25*(d & gradcN))
114 + (1 - cdWeight)*(phiN + 0.25*(d & gradcP));
115
116 scalar phiCD = cdWeight*phiP + (1 - cdWeight)*phiN;
117
118 // Calculate the effective limiter for the cubic interpolation
119 scalar cubicLimiter = (phif - phiU)/stabilise(phiCD - phiU, SMALL);
120
121 /*
122 if (twor < 0.05)
123 {
124 cubicLimiter = twor;
125 }
126
127 return max(min(cubicLimiter, 2), 0);
128 */
129
130 // Limit the limiter to obey the TVD constraint
131 return max(min(min(twor, cubicLimiter), 2), 0);
132 }
133};
134
135
136// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137
138} // End namespace Foam
139
140// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141
142#endif
143
144// ************************************************************************* //
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 TVD limited centred-cubic differencing ...
Definition: limitedCubic.H:61
limitedCubicLimiter(Istream &is)
Definition: limitedCubic.H:67
scalar limiter(const scalar cdWeight, const scalar faceFlux, const typename LimiterFunc::phiType &phiP, const typename LimiterFunc::phiType &phiN, const typename LimiterFunc::gradPhiType &gradcP, const typename LimiterFunc::gradPhiType &gradcN, const vector &d) const
Definition: limitedCubic.H:84
#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