All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
filteredLinear.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) 2011-2020 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::filteredLinearLimiter
26 
27 Description
28  Class to generate weighting factors for the filteredLinear
29  differencing scheme.
30 
31  The aim is to remove high-frequency modes with "staggering"
32  characteristics by comparing the face gradient relative to the
33  background distribution represented by the neighbouring cell gradients
34  with those gradients and introduce small amounts of upwind in order to
35  damp these modes.
36 
37  Used in conjunction with the template class LimitedScheme.
38 
39 SourceFiles
40  filteredLinear.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef filteredLinear_H
45 #define filteredLinear_H
46 
47 #include "vector.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class filteredLinearWeight Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class LimiterFunc>
60 :
61  public LimiterFunc
62 {
63 
64 public:
65 
67  {}
68 
69  scalar limiter
70  (
71  const scalar cdWeight,
72  const scalar faceFlux,
73  const typename LimiterFunc::phiType& phiP,
74  const typename LimiterFunc::phiType& phiN,
75  const typename LimiterFunc::gradPhiType& gradcP,
76  const typename LimiterFunc::gradPhiType& gradcN,
77  const vector& d
78  ) const
79  {
80  scalar df = phiN - phiP;
81 
82  scalar dcP = d & gradcP;
83  scalar dcN = d & gradcN;
84 
85  scalar limiter =
86  2
87  - 0.5*min(mag(df - dcP), mag(df - dcN))
88  /(max(mag(dcP), mag(dcN)) + small);
89 
90  // Limit the limiter between linear and 20% upwind
91  return max(min(limiter, 1), 0.8);
92  }
93 };
94 
95 
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
97 
98 } // End namespace Foam
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
102 #endif
103 
104 // ************************************************************************* //
Class to generate weighting factors for the filteredLinear differencing scheme.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
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
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
dimensioned< scalar > mag(const dimensioned< Type > &)
Namespace for OpenFOAM.