mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
COMP: make mathematical constants constexpr
- these are compile-time constants and can be marked as such in C++11.
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user