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:
@ -582,14 +582,14 @@ processValues
|
||||
case opSumDirection:
|
||||
{
|
||||
vector n(dict_.lookup("direction"));
|
||||
return sum(pos(values*(Sf & n))*mag(values));
|
||||
return sum(pos0(values*(Sf & n))*mag(values));
|
||||
}
|
||||
case opSumDirectionBalance:
|
||||
{
|
||||
vector n(dict_.lookup("direction"));
|
||||
const scalarField nv(values*(Sf & n));
|
||||
|
||||
return sum(pos(nv)*mag(values) - neg(nv)*mag(values));
|
||||
return sum(pos0(nv)*mag(values) - neg(nv)*mag(values));
|
||||
}
|
||||
default:
|
||||
{
|
||||
@ -617,7 +617,7 @@ processValues
|
||||
n /= mag(n) + ROOTVSMALL;
|
||||
const scalarField nv(n & values);
|
||||
|
||||
return sum(pos(nv)*n*(nv));
|
||||
return sum(pos0(nv)*n*(nv));
|
||||
}
|
||||
case opSumDirectionBalance:
|
||||
{
|
||||
@ -625,7 +625,7 @@ processValues
|
||||
n /= mag(n) + ROOTVSMALL;
|
||||
const scalarField nv(n & values);
|
||||
|
||||
return sum(pos(nv)*n*(nv));
|
||||
return sum(pos0(nv)*n*(nv));
|
||||
}
|
||||
case opAreaNormalAverage:
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user