Loading...
Searching...
No Matches
Gamma.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-------------------------------------------------------------------------------
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::GammaWeight
28
29Description
30 Class with operator() which returns the weighting factors for the
31 Gamma differencing scheme. Used in conjunction with the template class
32 NVDscheme.
33
34SourceFiles
35 GammaMake.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef Gamma_H
40#define Gamma_H
41
42#include "scalar.H"
43#include "vector.H"
44#include "Istream.H"
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48namespace Foam
49{
51/*---------------------------------------------------------------------------*\
52 Class GammaWeight Declaration
53\*---------------------------------------------------------------------------*/
54
55class GammaWeight
56{
57 // Private Data
58
59 //- Model coefficient [0,1]
60 scalar k_;
61
63public:
64
66 :
67 k_(readScalar(is))
68 {
69 if (k_ < 0 || k_ > 1)
70 {
72 << "coefficient = " << k_
73 << " should be >= 0 and <= 1"
75 }
76
77 // Rescale k_ to be >= 0 and <= 0.5 (TVD conformant)
78 // and avoid the /0 when k_ = 0
79 k_ = max(0.5*k_, SMALL);
80 }
81
82
83 scalar weight
84 (
85 scalar cdWeight,
86 scalar faceFlux,
87 scalar phiP,
88 scalar phiN,
89 const vector& gradcP,
90 const vector& gradcN,
91 const vector& d
92 ) const
93 {
94 const vector dHat(normalised(d));
95
96 // Choose gradc based on faceFlux
97 const vector& gradcPN = (faceFlux > 0) ? gradcP : gradcN;
98 const scalar udWeight = (faceFlux > 0) ? 1 : 0;
99
100 // Stabilise for division
101 const scalar gradcf = stabilise(dHat & gradcPN, SMALL);
102
103 const scalar gradf = (phiN - phiP)/mag(d);
104
105 const scalar phict = 1 - 0.5*gradf/gradcf;
106 const scalar limiter = clamp(phict/k_, zero_one{});
107
108 return lerp(udWeight, cdWeight, limiter);
109 }
110};
111
112
113// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114
115} // End namespace Foam
116
117// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118
119#endif
120
121// ************************************************************************* //
GammaWeight(Istream &is)
Definition Gamma.H:62
scalar weight(scalar cdWeight, scalar faceFlux, scalar phiP, scalar phiN, const vector &gradcP, const vector &gradcN, const vector &d) const
Definition Gamma.H:81
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
Represents 0/1 range or concept. Used for tagged dispatch or clamping.
Definition pTraits.H:51
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
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:40
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
dimensionedScalar stabilise(const dimensionedScalar &x, const dimensionedScalar &y)
Vector< scalar > vector
Definition vector.H:57
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
tmp< areaScalarField > limiter(const areaScalarField &phi)
Definition faNVDscheme.C:31