Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openfoam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
openfoam
Commits
361398a6
Commit
361398a6
authored
8 years ago
by
Mark OLESEN
Browse files
Options
Downloads
Patches
Plain Diff
COMP: make mathematical constants constexpr
- these are compile-time constants and can be marked as such in C++11.
parent
a4b826aa
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H
+5
-5
5 additions, 5 deletions
...OAM/global/constants/mathematical/mathematicalConstants.H
src/OpenFOAM/global/unitConversion/unitConversion.H
+0
-4
0 additions, 4 deletions
src/OpenFOAM/global/unitConversion/unitConversion.H
with
5 additions
and
9 deletions
src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H
+
5
−
5
View file @
361398a6
...
@@ -47,13 +47,13 @@ namespace mathematical
...
@@ -47,13 +47,13 @@ namespace mathematical
static
const
char
*
const
group
=
"mathematical"
;
static
const
char
*
const
group
=
"mathematical"
;
const
scalar
e
(
M_E
);
const
expr
scalar
e
(
M_E
);
const
scalar
pi
(
M_PI
);
const
expr
scalar
pi
(
M_PI
);
const
scalar
twoPi
(
2
*
pi
);
const
expr
scalar
twoPi
(
2
*
M_PI
);
const
scalar
piByTwo
(
0.5
*
pi
);
const
expr
scalar
piByTwo
(
0.5
*
M_PI
);
//- Euler's constant
//- Euler's constant
const
scalar
Eu
(
0.57721566490153286060651209
);
const
expr
scalar
Eu
(
0.57721566490153286060651209
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
...
...
This diff is collapsed.
Click to expand it.
src/OpenFOAM/global/unitConversion/unitConversion.H
+
0
−
4
View file @
361398a6
...
@@ -44,14 +44,12 @@ namespace Foam
...
@@ -44,14 +44,12 @@ namespace Foam
//- Conversion from degrees to radians
//- Conversion from degrees to radians
inline
constexpr
scalar
degToRad
(
const
scalar
deg
)
noexcept
inline
constexpr
scalar
degToRad
(
const
scalar
deg
)
noexcept
{
{
//return (deg*Foam::constant::mathematical::pi/180.0);
return
(
deg
*
M_PI
/
180.0
);
return
(
deg
*
M_PI
/
180.0
);
}
}
//- Conversion from radians to degrees
//- Conversion from radians to degrees
inline
constexpr
scalar
radToDeg
(
const
scalar
rad
)
noexcept
inline
constexpr
scalar
radToDeg
(
const
scalar
rad
)
noexcept
{
{
//return (rad*180.0/Foam::constant::mathematical::pi)
;
return
(
rad
*
180.0
/
M_PI
);
return
(
rad
*
180.0
/
M_PI
);
}
}
...
@@ -71,14 +69,12 @@ inline constexpr scalar paToAtm(const scalar pa) noexcept
...
@@ -71,14 +69,12 @@ inline constexpr scalar paToAtm(const scalar pa) noexcept
//- User literal for degrees to radians conversion (integers)
//- User literal for degrees to radians conversion (integers)
inline
constexpr
scalar
operator
""
_deg
(
unsigned
long
long
int
deg
)
noexcept
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
);
return
(
deg
*
M_PI
/
180.0
);
}
}
//- User literal for degrees to radians conversion (floats)
//- User literal for degrees to radians conversion (floats)
inline
constexpr
scalar
operator
""
_deg
(
long
double
deg
)
noexcept
inline
constexpr
scalar
operator
""
_deg
(
long
double
deg
)
noexcept
{
{
//return (deg*Foam::constant::mathematical::pi/180.0);
return
(
deg
*
M_PI
/
180.0
);
return
(
deg
*
M_PI
/
180.0
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment