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