cubicGradientLimiter.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) 2018 OpenFOAM Foundation
9 Copyright (C) 2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::fv::gradientLimiters::cubic
29
30Description
31 Cubic gradient limiter
32
33 to be used with the Foam::fv::cellLimitedGrad limited gradient. This
34 limiter function is similar to Foam::fv::gradientLimiters::Venkatakrishnan
35 but is a fit to obey the value and gradient constraints and avoids the
36 problem of the limiter exceeding 1 present in the Venkatakrishnan function.
37
38 The transition point at which the limiter function reaches 1 is an input
39 parameter and should be set to a value between 1 and 2 although values
40 larger than 2 are physical but likely to significantly reduce the accuracy
41 of the scheme.
42
43 Reference:
44 \verbatim
45 Michalak, K., & Ollivier-Gooch, C. (2008).
46 Limiters for unstructured higher-order accurate solutions
47 of the Euler equations.
48 In 46th AIAA Aerospace Sciences Meeting and Exhibition.
49 DOI:10.2514/6.2008-776
50 \endverbatim
51
52Usage
53 Example:
54 \verbatim
55 gradSchemes
56 {
57 default Gauss linear;
58 limited cellLimited<cubic> 1.5 Gauss linear 1;
59 }
60 \endverbatim
61
62See also
63 - Foam::fv::cellLimitedGrad
64 - Foam::fv::gradientLimiters::Venkatakrishnan
65
66\*---------------------------------------------------------------------------*/
67
68#ifndef cubicGradientLimiter_H
69#define cubicGradientLimiter_H
70
71#include "Istream.H"
72
73// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74
75namespace Foam
76{
77
78namespace fv
79{
81namespace gradientLimiters
82{
83
84// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86class cubic
87{
88 // Private Data
89
90 //- Limiter transition point at which the limiter function -> 1
91 // Must be > 1
92 const scalar rt_;
93
94 //- Coefficient of the r^3 term (evaluated from rt)
95 const scalar a_;
96
97 // - Coefficient of the r^2 term (evaluated from rt)
98 const scalar b_;
99
100
101public:
102
103 // Constructors
105 cubic(Istream& schemeData)
106 :
107 rt_(readScalar(schemeData)),
108 a_((rt_ - 2)/pow3(rt_)),
109 b_(-(3*a_*sqr(rt_) + 1)/(2*rt_))
110 {
111 if (rt_ < 1)
112 {
113 FatalIOErrorInFunction(schemeData)
114 << "coefficient = " << rt_
115 << " should be > 1"
116 << exit(FatalIOError);
117 }
118 }
119
120
121 // Member Functions
123 inline scalar limiter(const scalar r) const
124 {
125 if (r < rt_)
126 {
127 return ((a_*r + b_)*r + 1)*r;
128 }
129
130 return 1;
131 }
132};
133
134
135// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136
137} // End namespace gradientLimiters
138
139} // End namespace fv
140
141} // End namespace Foam
142
143// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144
145#endif
146
147// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
scalar limiter(const scalar r) const
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Namespace for OpenFOAM.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar pow3(const dimensionedScalar &ds)
IOerror FatalIOError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
labelList fv(nPoints)