Commit 361398a6 authored by Mark Olesen's avatar Mark Olesen
Browse files

COMP: make mathematical constants constexpr

- these are compile-time constants and can be marked as such in C++11.
parent a4b826aa
......@@ -47,13 +47,13 @@ namespace mathematical
static const char* const group = "mathematical";
const scalar e(M_E);
const scalar pi(M_PI);
const scalar twoPi(2*pi);
const scalar piByTwo(0.5*pi);
constexpr scalar e(M_E);
constexpr scalar pi(M_PI);
constexpr scalar twoPi(2*M_PI);
constexpr scalar piByTwo(0.5*M_PI);
//- Euler's constant
const scalar Eu(0.57721566490153286060651209);
constexpr scalar Eu(0.57721566490153286060651209);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -44,14 +44,12 @@ namespace Foam
//- Conversion from degrees to radians
inline constexpr scalar degToRad(const scalar deg) noexcept
{
//return (deg*Foam::constant::mathematical::pi/180.0);
return (deg*M_PI/180.0);
}
//- Conversion from radians to degrees
inline constexpr scalar radToDeg(const scalar rad) noexcept
{
//return (rad*180.0/Foam::constant::mathematical::pi);
return (rad*180.0/M_PI);
}
......@@ -71,14 +69,12 @@ inline constexpr scalar paToAtm(const scalar pa) noexcept
//- User literal for degrees to radians conversion (integers)
inline constexpr scalar operator "" _deg(unsigned long long int deg) noexcept
{
//return (deg*Foam::constant::mathematical::pi/180.0);
return (deg*M_PI/180.0);
}
//- User literal for degrees to radians conversion (floats)
inline constexpr scalar operator "" _deg(long double deg) noexcept
{
//return (deg*Foam::constant::mathematical::pi/180.0);
return (deg*M_PI/180.0);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment