units.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-2026 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 Global
25  unitSets
26 
27 Description
28  Useful unit conversions
29 
30 SourceFiles
31  unitSets.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef units_H
36 #define units_H
37 
38 #include "unitSet.H"
39 #include "dimensions.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace units
49 {
50  extern const unitSet unitless;
51 
52  extern const unitSet any;
53  extern const unitSet none;
54 
55  extern const unitSet fraction;
56  extern const unitSet percent;
57 
58  extern const unitSet radians;
59  extern const unitSet rotations;
60  extern const unitSet degrees;
61 
62  extern const unitSet& length;
63 
64  //- Get the table of unit conversions
65  const HashTable<unitSet>& table();
66 
67  //- Add a unit conversion
68  void add(const word& name, const unitSet& unit);
69 
70  //- Lookup and return the named unit from the table
71  const unitSet& lookup(const word& unitName);
72 
73  //- Set the length scale to the given unit set
74  void setLength(const unitSet& length);
75 
76  //- Set the length scale to the given value
77  void setLength(const scalar length);
78 }
79 
80 
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 
83 //- Convert degrees to radians
84 scalar degToRad(const scalar deg);
85 
86 //- Convert radians to degrees
87 scalar radToDeg(const scalar rad);
88 
89 
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 
92 } // End namespace Foam
93 
94 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
95 
96 #endif
97 
98 // ************************************************************************* //
Predefined dimensions.
const unitSet & length
Definition: units.C:137
const unitSet percent
const unitSet radians
const unitSet unitless
void add(const word &name, const unitSet &unit)
Add a unit conversion.
Definition: units.C:331
const HashTable< unitSet > & table()
Get the table of unit conversions.
Definition: units.C:142
const unitSet none
void setLength(const unitSet &length)
Set the length scale to the given unit set.
Definition: units.C:352
const unitSet any
const unitSet fraction
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
const unitSet degrees
const unitSet rotations
Namespace for OpenFOAM.
scalar radToDeg(const scalar rad)
Convert radians to degrees.
Definition: units.C:370
scalar degToRad(const scalar deg)
Convert degrees to radians.
Definition: units.C:364
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.