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 -------------------------------------------------------------------------------
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::filteredLinear3Limiter
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 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 
43 SourceFiles
44  filteredLinear3.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef filteredLinear3_H
49 #define filteredLinear3_H
50 
51 #include "vector.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 /*---------------------------------------------------------------------------*\
59  Class filteredLinear3Limiter Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 template<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 
74 public:
75 
77  :
78  k_(readScalar(is))
79  {
80  if (k_ < 0 || k_ > 1)
81  {
83  << "coefficient = " << k_
84  << " should be >= 0 and <= 1"
85  << exit(FatalIOError);
86  }
87  }
88 
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 // ************************************************************************* //
Foam::FatalIOError
IOerror FatalIOError
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::filteredLinear3Limiter::filteredLinear3Limiter
filteredLinear3Limiter(Istream &is)
Definition: filteredLinear3.H:75
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
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
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::filteredLinear3Limiter::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: filteredLinear3.H:89
Foam::Vector< scalar >
vector.H
Foam::filteredLinear3Limiter
Class to generate weighting factors for the filteredLinear differencing scheme.
Definition: filteredLinear3.H:62
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473