linearUpwind.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) 2016-2017 Wikki Ltd
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::linearUpwindWeight
28 
29 Description
30  Class with operator() which returns the weighting factors for the
31  linear-upwind differencing scheme. Note that the weighting factors are
32  not bounded between upwind and central-differencing, some downwind
33  contribution is possible although the interpolate is limited to be between
34  the upwind and downwind cell values.
35 
36  Used in conjunction with the template class NVDscheme although this scheme
37  is not NVD.
38 
39 SourceFiles
40  linearUpwindMake.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef linearUpwind_H
45 #define linearUpwind_H
46 
47 #include "scalar.H"
48 #include "vector.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class linearUpwindWeight Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 {
61 
62 public:
63 
65  {}
66 
67  scalar weight
68  (
69  scalar cdWeight,
70  scalar faceFlux,
71  scalar phiP,
72  scalar phiN,
73  const vector& gradcP,
74  const vector& gradcN,
75  const vector& d
76  ) const
77  {
78  scalar phif;
79  if (faceFlux > 0)
80  {
81  phif = phiP + (1 - cdWeight)*(d & gradcP);
82  }
83  else
84  {
85  phif = phiN - cdWeight*(d & gradcN);
86  }
87 
88  // Limit the estimated face value between the upwind and downwind cell
89  // values
90  phif = min(phif, max(phiN, phiP));
91  phif = max(phif, min(phiN, phiP));
92 
93  return (phif - phiN)/stabilise(phiP - phiN, SMALL);
94  }
95 };
96 
97 
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99 
100 } // End namespace Foam
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 
104 #endif
105 
106 // ************************************************************************* //
Foam::linearUpwindWeight::linearUpwindWeight
linearUpwindWeight(Istream &)
Definition: linearUpwind.H:63
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::stabilise
tmp< DimensionedField< scalar, GeoMesh > > stabilise(const DimensionedField< scalar, GeoMesh > &dsf, const dimensioned< scalar > &ds)
Definition: DimensionedScalarField.C:43
Foam::linearUpwindWeight
Class with operator() which returns the weighting factors for the linear-upwind differencing scheme....
Definition: linearUpwind.H:58
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
scalar.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Vector< scalar >
vector.H
Foam::linearUpwindWeight::weight
scalar weight(scalar cdWeight, scalar faceFlux, scalar phiP, scalar phiN, const vector &gradcP, const vector &gradcN, const vector &d) const
Definition: linearUpwind.H:67