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 public:
62 
63  // Generated Methods
64 
65  //- No copy construct
66  linearUpwindWeight(const linearUpwindWeight&) = delete;
67 
68  //- No copy assignment
69  void operator=(const linearUpwindWeight&) = delete;
70 
71 
73  {}
74 
75  scalar weight
76  (
77  scalar cdWeight,
78  scalar faceFlux,
79  scalar phiP,
80  scalar phiN,
81  const vector& gradcP,
82  const vector& gradcN,
83  const vector& d
84  ) const
85  {
86  scalar phif;
87  if (faceFlux > 0)
88  {
89  phif = phiP + (1 - cdWeight)*(d & gradcP);
90  }
91  else
92  {
93  phif = phiN - cdWeight*(d & gradcN);
94  }
95 
96  // Limit the estimated face value between the upwind and downwind cell
97  // values
98  phif = min(phif, max(phiN, phiP));
99  phif = max(phif, min(phiN, phiP));
100 
101  return (phif - phiN)/stabilise(phiP - phiN, SMALL);
102  }
103 };
104 
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 } // End namespace Foam
109 
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 
112 #endif
113 
114 // ************************************************************************* //
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
dimensionedScalar stabilise(const dimensionedScalar &x, const dimensionedScalar &y)
scalar weight(scalar cdWeight, scalar faceFlux, scalar phiP, scalar phiN, const vector &gradcP, const vector &gradcN, const vector &d) const
Definition: linearUpwind.H:75
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
void operator=(const linearUpwindWeight &)=delete
No copy assignment.
Class with operator() which returns the weighting factors for the linear-upwind differencing scheme...
Definition: linearUpwind.H:54
linearUpwindWeight(const linearUpwindWeight &)=delete
No copy construct.
Namespace for OpenFOAM.