unitConversion.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011 OpenFOAM Foundation
9 Copyright (C) 2017-2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27InNamespace
28 Foam
29
30Description
31 Unit conversion functions
32
33\*---------------------------------------------------------------------------*/
34
35#ifndef unitConversion_H
36#define unitConversion_H
37
39
40// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41
42namespace Foam
43{
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47//- Conversion from degrees to radians
48inline constexpr scalar degToRad(const scalar deg) noexcept
49{
50 return (deg*M_PI/180.0);
51}
52
53//- Conversion from radians to degrees
54inline constexpr scalar radToDeg(const scalar rad) noexcept
55{
56 return (rad*180.0/M_PI);
57}
58
59//- Multiplication factor for degrees to radians conversion
60inline constexpr scalar degToRad() noexcept
61{
62 return (M_PI/180.0);
63}
64
65//- Multiplication factor for radians to degrees conversion
66inline constexpr scalar radToDeg() noexcept
67{
68 return (180.0/M_PI);
69}
70
71
72//- Conversion from revolutions/minute to radians/sec
73inline constexpr scalar rpmToRads(const scalar rpm) noexcept
74{
75 return (rpm*M_PI/30.0);
76}
77
78//- Conversion from radians/sec to revolutions/minute
79inline constexpr scalar radsToRpm(const scalar rads) noexcept
80{
81 return (rads*30.0/M_PI);
82}
83
84//- Multiplication factor for revolutions/minute to radians/sec
85inline constexpr scalar rpmToRads() noexcept
86{
87 return (M_PI/30.0);
88}
89
90//- Multiplication factor for radians/sec to revolutions/minute
91inline constexpr scalar radsToRpm() noexcept
92{
93 return (30.0/M_PI);
94}
95
96
97//- Conversion from atm to Pa
98inline constexpr scalar atmToPa(const scalar atm) noexcept
99{
100 return (atm*101325.0);
101}
102
103//- Conversion from bar to Pa
104inline constexpr scalar barToPa(const scalar bar) noexcept
105{
106 return (bar*100000.0);
107}
108
109
110//- Conversion from Pa to atm
111inline constexpr scalar paToAtm(const scalar pa) noexcept
112{
113 return (pa/101325.0);
114}
115
116//- Conversion from Pa to bar
117inline constexpr scalar paToBar(const scalar pa) noexcept
118{
119 return (pa/100000.0);
120}
121
122
123//- User literal for degrees to radians conversion (integers)
124inline constexpr scalar operator "" _deg(unsigned long long int deg) noexcept
125{
126 return (deg*M_PI/180.0);
127}
128
129//- User literal for degrees to radians conversion (floats)
130inline constexpr scalar operator "" _deg(long double deg) noexcept
131{
132 return (deg*M_PI/180.0);
133}
134
135
136// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137
138} // End namespace Foam
139
140// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141
142#endif
143
144// ************************************************************************* //
radiation::radiationModel & rad
Namespace for OpenFOAM.
constexpr scalar radsToRpm() noexcept
Multiplication factor for radians/sec to revolutions/minute.
constexpr scalar barToPa(const scalar bar) noexcept
Conversion from bar to Pa.
constexpr scalar rpmToRads() noexcept
Multiplication factor for revolutions/minute to radians/sec.
constexpr scalar degToRad() noexcept
Multiplication factor for degrees to radians conversion.
constexpr scalar radToDeg() noexcept
Multiplication factor for radians to degrees conversion.
const direction noexcept
Definition: Scalar.H:223
constexpr scalar paToBar(const scalar pa) noexcept
Conversion from Pa to bar.
constexpr scalar paToAtm(const scalar pa) noexcept
Conversion from Pa to atm.
constexpr scalar atmToPa(const scalar atm) noexcept
Conversion from atm to Pa.