All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 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 
73 namespace fv
74 {
75 
76 namespace gradientLimiters
77 {
78 
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 
81 class cubic
82 {
83  // Private Data
84 
85  //- Limiter transition point at which the limiter function -> 1
86  // Must be > 1
87  const scalar rt_;
88 
89  //- Coefficient of the r^3 term (evaluated from rt)
90  const scalar a_;
91 
92  // - Coefficient of the r^2 term (evaluated from rt)
93  const scalar b_;
94 
95 
96 public:
97 
98  // Constructors
99 
100  cubic(Istream& schemeData)
101  :
102  rt_(readScalar(schemeData)),
103  a_(2.0/sqr(rt_) - 2.0/pow3(rt_)),
104  b_(-(3.0/2.0)*a_*rt_)
105  {
106  if (rt_ < 1)
107  {
109  (
110  schemeData
111  ) << "coefficient = " << rt_
112  << " should be > 1"
113  << exit(FatalIOError);
114  }
115  }
116 
117 
118  // Member Functions
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 // ************************************************************************* //
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:331
Namespace for OpenFOAM.
IOerror FatalIOError