unitConversion.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 InNamespace
25  Foam
26 
27 Description
28  Unit conversion functions
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #ifndef unitConversion_H
33 #define unitConversion_H
34 
35 #include "mathematicalConstants.H"
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 //- Conversion from degrees to radians
45 inline scalar degToRad(const scalar deg)
46 {
47  return deg*constant::mathematical::pi/180.0;
48 }
49 
50 //- Conversion from radians to degrees
51 inline scalar radToDeg(const scalar rad)
52 {
53  return rad*180.0/constant::mathematical::pi;
54 }
55 
56 //- Conversion from atm to Pa
57 inline scalar atmToPa(const scalar atm)
58 {
59  return atm*101325.0;
60 }
61 
62 //- Conversion from atm to Pa
63 inline scalar paToAtm(const scalar pa)
64 {
65  return pa/101325.0;
66 }
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 } // End namespace Foam
71 
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73 
74 #endif
75 
76 // ************************************************************************* //
scalar radToDeg(const scalar rad)
Conversion from radians to degrees.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
scalar atmToPa(const scalar atm)
Conversion from atm to Pa.
scalar paToAtm(const scalar pa)
Conversion from atm to Pa.
Namespace for OpenFOAM.