Rationalize the "pos" function

"pos" now returns 1 if the argument is greater than 0, otherwise it returns 0.
This is consistent with the common mathematical definition of the "pos" function:

https://en.wikipedia.org/wiki/Sign_(mathematics)

However the previous implementation in which 1 was also returned for a 0
argument is useful in many situations so the "pos0" has been added which returns
1 if the argument is greater or equal to 0.  Additionally the "neg0" has been
added which returns 1 if if the argument is less than or equal to 0.
This commit is contained in:
Henry Weller
2017-06-22 14:32:18 +01:00
committed by Andrew Heather
parent 639305e960
commit 56bfc75949
96 changed files with 269 additions and 196 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -78,13 +78,13 @@ Foam::tmp<Foam::volScalarField> Foam::dragModels::GidaspowErgunWenYu::K
volScalarField Cds
(
neg(Re - 1000)*(24.0*(1.0 + 0.15*pow(Re, 0.687))/Re)
+ pos(Re - 1000)*0.44
+ pos0(Re - 1000)*0.44
);
// Wen and Yu (1966)
return
(
pos(alpha2 - 0.8)
pos0(alpha2 - 0.8)
*(0.75*Cds*phase2_.rho()*Ur*bp/d)
+ neg(alpha2 - 0.8)
*(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -77,7 +77,7 @@ Foam::tmp<Foam::volScalarField> Foam::dragModels::GidaspowSchillerNaumann::K
volScalarField Cds
(
neg(Re - 1000)*(24.0*(1.0 + 0.15*pow(Re, 0.687))/Re)
+ pos(Re - 1000)*0.44
+ pos0(Re - 1000)*0.44
);
return 0.75*Cds*phase2_.rho()*Ur*bp/phase1_.d();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,7 +74,7 @@ Foam::tmp<Foam::volScalarField> Foam::dragModels::SchillerNaumann::K
volScalarField Cds
(
neg(Re - 1000)*(24.0*(1.0 + 0.15*pow(Re, 0.687))/Re)
+ pos(Re - 1000)*0.44
+ pos0(Re - 1000)*0.44
);
return 0.75*Cds*phase2_.rho()*Ur/phase1_.d();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -75,7 +75,7 @@ Foam::tmp<Foam::volScalarField> Foam::dragModels::SyamlalOBrien::K
volScalarField B
(
neg(alpha2 - 0.85)*(0.8*pow(alpha2, 1.28))
+ pos(alpha2 - 0.85)*(pow(alpha2, 2.65))
+ pos0(alpha2 - 0.85)*(pow(alpha2, 2.65))
);
volScalarField Re(max(Ur*phase1_.d()/phase2_.nu(), scalar(1.0e-3)));

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -77,7 +77,7 @@ Foam::tmp<Foam::volScalarField> Foam::dragModels::WenYu::K
volScalarField Cds
(
neg(Re - 1000)*(24.0*(1.0 + 0.15*pow(Re, 0.687))/Re)
+ pos(Re - 1000)*0.44
+ pos0(Re - 1000)*0.44
);
return 0.75*Cds*phase2_.rho()*Ur*bp/phase1_.d();