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 -------------------------------------------------------------------------------
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::fv::gradientLimiters::minmod
28 
29 Description
30  Cubic gradient limiter
31 
32  to be used with the Foam::fv::cellLimitedGrad limited gradient. This
33  limiter function is similar to Foam::fv::gradientLimiters::Venkatakrishnan
34  but is a fit to obey the value and gradient constraints and avoids the
35  problem of the limiter exceeding 1 present in the Venkatakrishnan function.
36 
37  The transition point at which the limiter function reaches 1 is an input
38  parameter and should be set to a value between 1 and 2 although values
39  larger than 2 are physical but likely to significantly reduce the accuracy
40  of the scheme.
41 
42  Reference:
43  \verbatim
44  Michalak, K., & Ollivier-Gooch, C. (2008).
45  Limiters for unstructured higher-order accurate solutions
46  of the Euler equations.
47  In 46th AIAA Aerospace Sciences Meeting and Exhibit (p. 776).
48  \endverbatim
49 
50  Example:
51  \verbatim
52  gradSchemes
53  {
54  default Gauss linear;
55  limited cellLimited<cubic> 1.5 Gauss linear 1;
56  }
57  \endverbatim
58 
59 See also
60  Foam::fv::cellLimitedGrad
61  Foam::fv::gradientLimiters::Venkatakrishnan
62 
63 \*---------------------------------------------------------------------------*/
64 
65 #ifndef cubicGradientLimiter_H
66 #define cubicGradientLimiter_H
67 
68 #include "Istream.H"
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72 namespace Foam
73 {
74 
75 namespace fv
76 {
77 
78 namespace gradientLimiters
79 {
80 
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 
83 class cubic
84 {
85  // Private Data
86 
87  //- Limiter transition point at which the limiter function -> 1
88  // Must be > 1
89  const scalar rt_;
90 
91  //- Coefficient of the r^3 term (evaluated from rt)
92  const scalar a_;
93 
94  // - Coefficient of the r^2 term (evaluated from rt)
95  const scalar b_;
96 
97 
98 public:
99 
100  // Constructors
101 
102  cubic(Istream& schemeData)
103  :
104  rt_(readScalar(schemeData)),
105  a_(2.0/sqr(rt_) - 2.0/pow3(rt_)),
106  b_(-(3.0/2.0)*a_*rt_)
107  {
108  if (rt_ < 1)
109  {
110  FatalIOErrorInFunction(schemeData)
111  << "coefficient = " << rt_
112  << " should be > 1"
113  << exit(FatalIOError);
114  }
115  }
116 
117 
118  // Member Functions
119 
120  inline scalar limiter(const scalar r) const
121  {
122  if (r < rt_)
123  {
124  return ((a_*r + b_)*r + 1)*r;
125  }
126  else
127  {
128  return 1;
129  }
130  }
131 };
132 
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 } // End namespace gradientLimiters
137 
138 } // End namespace fv
139 
140 } // End namespace Foam
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 #endif
145 
146 // ************************************************************************* //
Foam::fv::gradientLimiters::cubic::limiter
scalar limiter(const scalar r) const
Definition: cubicGradientLimiter.H:119
Foam::fv::gradientLimiters::cubic::cubic
cubic(Istream &schemeData)
Definition: cubicGradientLimiter.H:101
Foam::FatalIOError
IOerror FatalIOError
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::pow3
dimensionedScalar pow3(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:89
Istream.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
fv
labelList fv(nPoints)
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::fv::gradientLimiters::cubic
Definition: cubicGradientLimiter.H:82
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:401