filteredLinear3.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-2015 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::filteredLinear3Limiter
28
29Group
30 grpFvLimitedSurfaceInterpolationSchemes
31
32Description
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 with both neighbouring
38 cell gradients and introduce small amounts of upwind in order to damp
39 these modes.
40
41 Used in conjunction with the template class LimitedScheme.
42
43SourceFiles
44 filteredLinear3.C
45
46\*---------------------------------------------------------------------------*/
47
48#ifndef filteredLinear3_H
49#define filteredLinear3_H
50
51#include "vector.H"
52
53// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54
55namespace Foam
56{
57
58/*---------------------------------------------------------------------------*\
59 Class filteredLinear3Limiter Declaration
60\*---------------------------------------------------------------------------*/
61
62template<class LimiterFunc>
64:
65 public LimiterFunc
66{
67 // Private data
68
69 // Scaling coefficient for the gradient ratio,
70 // 0 = linear
71 // 1 = fully limited
72 scalar k_;
73
74public:
77 :
78 k_(readScalar(is))
79 {
80 if (k_ < 0 || k_ > 1)
81 {
83 << "coefficient = " << k_
84 << " should be >= 0 and <= 1"
86 }
87 }
89 scalar limiter
90 (
91 const scalar cdWeight,
92 const scalar faceFlux,
93 const typename LimiterFunc::phiType& phiP,
94 const typename LimiterFunc::phiType& phiN,
95 const typename LimiterFunc::gradPhiType& gradcP,
96 const typename LimiterFunc::gradPhiType& gradcN,
97 const vector& d
98 ) const
99 {
100 // Difference across face
101 scalar df = phiN - phiP;
102
103 // Twice the differences across face-neighbour cells
104 scalar dP = 2*(d & gradcP);
105 scalar dN = 2*(d & gradcN);
106
107 // Calculate the limiter
108 scalar limiter = 1 - k_*(dN - df)*(dP - df)/max(sqr(dN + dP), SMALL);
109
110 // Limit the limiter between linear and upwind
111 return max(min(limiter, 1), 0);
112 }
113};
114
115
116// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117
118} // End namespace Foam
119
120// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121
122#endif
123
124// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
Class to generate weighting factors for the filteredLinear differencing scheme.
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
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
dimensionedSymmTensor sqr(const dimensionedVector &dv)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
IOerror FatalIOError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130