src/OpenFOAM: Added posPart and negPart functions
posPart returns a value or field in which the value or values are set to 0 if negative negPart returns a value or field in which the value or values are set to 0 if positive
This commit is contained in:
parent
89bce95441
commit
43030b7fbc
14 changed files with 90 additions and 13 deletions
|
|
@ -2,7 +2,7 @@
|
|||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
|
@ -417,6 +417,18 @@ Foam::dimensionSet Foam::neg(const dimensionSet&)
|
|||
}
|
||||
|
||||
|
||||
Foam::dimensionSet Foam::posPart(const dimensionSet& ds)
|
||||
{
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
||||
Foam::dimensionSet Foam::negPart(const dimensionSet& ds)
|
||||
{
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
||||
Foam::dimensionSet Foam::inv(const dimensionSet& ds)
|
||||
{
|
||||
return dimless/ds;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
|
@ -82,6 +82,8 @@ dimensionSet mag(const dimensionSet&);
|
|||
dimensionSet sign(const dimensionSet&);
|
||||
dimensionSet pos(const dimensionSet&);
|
||||
dimensionSet neg(const dimensionSet&);
|
||||
dimensionSet posPart(const dimensionSet&);
|
||||
dimensionSet negPart(const dimensionSet&);
|
||||
dimensionSet inv(const dimensionSet&);
|
||||
|
||||
// Function to check the argument is dimensionless
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
|
@ -209,6 +209,28 @@ dimensionedScalar neg(const dimensionedScalar& ds)
|
|||
}
|
||||
|
||||
|
||||
dimensionedScalar posPart(const dimensionedScalar& ds)
|
||||
{
|
||||
return dimensionedScalar
|
||||
(
|
||||
"posPart(" + ds.name() + ')',
|
||||
posPart(ds.dimensions()),
|
||||
::Foam::pos(ds.value())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
dimensionedScalar negPart(const dimensionedScalar& ds)
|
||||
{
|
||||
return dimensionedScalar
|
||||
(
|
||||
"negPart(" + ds.name() + ')',
|
||||
negPart(ds.dimensions()),
|
||||
::Foam::neg(ds.value())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#define transFunc(func) \
|
||||
dimensionedScalar func(const dimensionedScalar& ds) \
|
||||
{ \
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
|
@ -69,6 +69,8 @@ dimensionedScalar hypot(const dimensionedScalar&, const dimensionedScalar&);
|
|||
dimensionedScalar sign(const dimensionedScalar&);
|
||||
dimensionedScalar pos(const dimensionedScalar&);
|
||||
dimensionedScalar neg(const dimensionedScalar&);
|
||||
dimensionedScalar posPart(const dimensionedScalar&);
|
||||
dimensionedScalar negPart(const dimensionedScalar&);
|
||||
|
||||
dimensionedScalar exp(const dimensionedScalar&);
|
||||
dimensionedScalar log(const dimensionedScalar&);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
|
@ -638,6 +638,8 @@ UNARY_FUNCTION(scalar, scalar, cbrt, cbrt)
|
|||
UNARY_FUNCTION(scalar, scalar, sign, sign)
|
||||
UNARY_FUNCTION(scalar, scalar, pos, pos)
|
||||
UNARY_FUNCTION(scalar, scalar, neg, neg)
|
||||
UNARY_FUNCTION(scalar, scalar, posPart, posPart)
|
||||
UNARY_FUNCTION(scalar, scalar, negPart, negPart)
|
||||
|
||||
UNARY_FUNCTION(scalar, scalar, exp, trans)
|
||||
UNARY_FUNCTION(scalar, scalar, log, trans)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
|
@ -92,6 +92,8 @@ UNARY_FUNCTION(scalar, scalar, cbrt, cbrt)
|
|||
UNARY_FUNCTION(scalar, scalar, sign, sign)
|
||||
UNARY_FUNCTION(scalar, scalar, pos, pos)
|
||||
UNARY_FUNCTION(scalar, scalar, neg, neg)
|
||||
UNARY_FUNCTION(scalar, scalar, posPart, posPart)
|
||||
UNARY_FUNCTION(scalar, scalar, negPart, negPart)
|
||||
|
||||
UNARY_FUNCTION(scalar, scalar, exp, trans)
|
||||
UNARY_FUNCTION(scalar, scalar, log, trans)
|
||||
|
|
|
|||
|
|
@ -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-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
|
@ -109,6 +109,8 @@ UNARY_FUNCTION(scalar, scalar, cbrt)
|
|||
UNARY_FUNCTION(scalar, scalar, sign)
|
||||
UNARY_FUNCTION(scalar, scalar, pos)
|
||||
UNARY_FUNCTION(scalar, scalar, neg)
|
||||
UNARY_FUNCTION(scalar, scalar, posPart)
|
||||
UNARY_FUNCTION(scalar, scalar, negPart)
|
||||
UNARY_FUNCTION(scalar, scalar, exp)
|
||||
UNARY_FUNCTION(scalar, scalar, log)
|
||||
UNARY_FUNCTION(scalar, scalar, log10)
|
||||
|
|
|
|||
|
|
@ -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-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
|
@ -102,6 +102,8 @@ UNARY_FUNCTION(scalar, scalar, cbrt)
|
|||
UNARY_FUNCTION(scalar, scalar, sign)
|
||||
UNARY_FUNCTION(scalar, scalar, pos)
|
||||
UNARY_FUNCTION(scalar, scalar, neg)
|
||||
UNARY_FUNCTION(scalar, scalar, posPart)
|
||||
UNARY_FUNCTION(scalar, scalar, negPart)
|
||||
UNARY_FUNCTION(scalar, scalar, exp)
|
||||
UNARY_FUNCTION(scalar, scalar, log)
|
||||
UNARY_FUNCTION(scalar, scalar, log10)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
|
@ -133,6 +133,8 @@ UNARY_FUNCTION(scalar, scalar, cbrt)
|
|||
UNARY_FUNCTION(scalar, scalar, sign)
|
||||
UNARY_FUNCTION(scalar, scalar, pos)
|
||||
UNARY_FUNCTION(scalar, scalar, neg)
|
||||
UNARY_FUNCTION(scalar, scalar, posPart)
|
||||
UNARY_FUNCTION(scalar, scalar, negPart)
|
||||
UNARY_FUNCTION(scalar, scalar, exp)
|
||||
UNARY_FUNCTION(scalar, scalar, log)
|
||||
UNARY_FUNCTION(scalar, scalar, log10)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
|
@ -107,6 +107,8 @@ UNARY_FUNCTION(scalar, scalar, cbrt)
|
|||
UNARY_FUNCTION(scalar, scalar, sign)
|
||||
UNARY_FUNCTION(scalar, scalar, pos)
|
||||
UNARY_FUNCTION(scalar, scalar, neg)
|
||||
UNARY_FUNCTION(scalar, scalar, posPart)
|
||||
UNARY_FUNCTION(scalar, scalar, negPart)
|
||||
UNARY_FUNCTION(scalar, scalar, exp)
|
||||
UNARY_FUNCTION(scalar, scalar, log)
|
||||
UNARY_FUNCTION(scalar, scalar, log10)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
|
@ -762,6 +762,8 @@ UNARY_FUNCTION(scalar, scalar, cbrt, cbrt)
|
|||
UNARY_FUNCTION(scalar, scalar, sign, sign)
|
||||
UNARY_FUNCTION(scalar, scalar, pos, pos)
|
||||
UNARY_FUNCTION(scalar, scalar, neg, neg)
|
||||
UNARY_FUNCTION(scalar, scalar, posPart, posPart)
|
||||
UNARY_FUNCTION(scalar, scalar, negPart, negPart)
|
||||
|
||||
UNARY_FUNCTION(scalar, scalar, exp, trans)
|
||||
UNARY_FUNCTION(scalar, scalar, log, trans)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
|
@ -100,6 +100,8 @@ UNARY_FUNCTION(scalar, scalar, cbrt, cbrt)
|
|||
UNARY_FUNCTION(scalar, scalar, sign, sign)
|
||||
UNARY_FUNCTION(scalar, scalar, pos, pos)
|
||||
UNARY_FUNCTION(scalar, scalar, neg, neg)
|
||||
UNARY_FUNCTION(scalar, scalar, posPart, posPart)
|
||||
UNARY_FUNCTION(scalar, scalar, negPart, negPart)
|
||||
|
||||
UNARY_FUNCTION(scalar, scalar, exp, trans)
|
||||
UNARY_FUNCTION(scalar, scalar, log, trans)
|
||||
|
|
|
|||
|
|
@ -131,6 +131,18 @@ inline Scalar neg(const Scalar s)
|
|||
}
|
||||
|
||||
|
||||
inline Scalar posPart(const Scalar s)
|
||||
{
|
||||
return (s > 0)? s: 0;
|
||||
}
|
||||
|
||||
|
||||
inline Scalar negPart(const Scalar s)
|
||||
{
|
||||
return (s < 0)? s: 0;
|
||||
}
|
||||
|
||||
|
||||
inline bool equal(const Scalar& s1, const Scalar& s2)
|
||||
{
|
||||
return mag(s1 - s2) <= ScalarVSMALL;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
|
@ -60,6 +60,17 @@ inline label neg(const label s)
|
|||
return (s < 0)? 1: 0;
|
||||
}
|
||||
|
||||
inline label posPart(const label s)
|
||||
{
|
||||
return (s > 0)? s: 0;
|
||||
}
|
||||
|
||||
inline label negPart(const label s)
|
||||
{
|
||||
return (s < 0)? s: 0;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue