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