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 -------------------------------------------------------------------------------
11 License
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 
27 InNamespace
28  Foam
29 
30 Description
31  Unit conversion functions
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef unitConversion_H
36 #define unitConversion_H
37 
38 #include "mathematicalConstants.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 //- Conversion from degrees to radians
48 inline constexpr scalar degToRad(const scalar deg) noexcept
49 {
50  return (deg*M_PI/180.0);
51 }
52 
53 //- Conversion from radians to degrees
54 inline 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
60 inline constexpr scalar degToRad() noexcept
61 {
62  return (M_PI/180.0);
63 }
64 
65 //- Multiplication factor for radians to degrees conversion
66 inline constexpr scalar radToDeg() noexcept
67 {
68  return (180.0/M_PI);
69 }
70 
71 
72 //- Conversion from revolutions/minute to radians/sec
73 inline 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
79 inline 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
85 inline constexpr scalar rpmToRads() noexcept
86 {
87  return (M_PI/30.0);
88 }
89 
90 //- Multiplication factor for radians/sec to revolutions/minute
91 inline constexpr scalar radsToRpm() noexcept
92 {
93  return (30.0/M_PI);
94 }
95 
96 
97 //- Conversion from atm to Pa
98 inline constexpr scalar atmToPa(const scalar atm) noexcept
99 {
100  return (atm*101325.0);
101 }
102 
103 //- Conversion from bar to Pa
104 inline constexpr scalar barToPa(const scalar bar) noexcept
105 {
106  return (bar*100000.0);
107 }
108 
109 
110 //- Conversion from Pa to atm
111 inline constexpr scalar paToAtm(const scalar pa) noexcept
112 {
113  return (pa/101325.0);
114 }
115 
116 //- Conversion from Pa to bar
117 inline 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)
124 inline 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)
130 inline 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 // ************************************************************************* //
mathematicalConstants.H
Foam::atmToPa
constexpr scalar atmToPa(const scalar atm) noexcept
Conversion from atm to Pa.
Definition: unitConversion.H:98
Foam::paToAtm
constexpr scalar paToAtm(const scalar pa) noexcept
Conversion from Pa to atm.
Definition: unitConversion.H:111
Foam::radToDeg
constexpr scalar radToDeg(const scalar rad) noexcept
Conversion from radians to degrees.
Definition: unitConversion.H:54
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::degToRad
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Definition: unitConversion.H:48
Foam::rpmToRads
constexpr scalar rpmToRads(const scalar rpm) noexcept
Conversion from revolutions/minute to radians/sec.
Definition: unitConversion.H:73
Foam::radsToRpm
constexpr scalar radsToRpm(const scalar rads) noexcept
Conversion from radians/sec to revolutions/minute.
Definition: unitConversion.H:79
Foam::barToPa
constexpr scalar barToPa(const scalar bar) noexcept
Conversion from bar to Pa.
Definition: unitConversion.H:104
rad
radiation::radiationModel & rad
Definition: setRegionFluidFields.H:20
Foam::paToBar
constexpr scalar paToBar(const scalar pa) noexcept
Conversion from Pa to bar.
Definition: unitConversion.H:117