unitSetI.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) 2024-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 \*---------------------------------------------------------------------------*/
25 
26 #include "unitSet.H"
27 
28 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
29 
31 {
32  return unitSet(dimensionSet(0, 0, 0, 0, 0), 0, 0, 1);
33 }
34 
35 
37 {
38  return unitSet(dimensionSet(0, 0, 0, 0, 0), 0, 0, 0);
39 }
40 
41 
43 {
44  return unitSet(dimensionSet(0, 0, 0, 0, 0), 0, 0, -1);
45 }
46 
47 
48 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
49 
51 {
52  return dimensions_;
53 }
54 
55 
56 inline bool Foam::unitSet::dimensionless() const
57 {
58  return dimensions_.dimensionless();
59 }
60 
61 
62 inline bool Foam::unitSet::any() const
63 {
64  return multiplier_ == 0;
65 }
66 
67 
68 inline bool Foam::unitSet::none() const
69 {
70  return multiplier_ == -1;
71 }
72 
73 
74 inline bool Foam::unitSet::standard() const
75 {
76  return multiplier_ == 1 || any() || none();
77 }
78 
79 
80 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
81 
82 inline Foam::scalar Foam::unitSet::operator[]
83 (
85 ) const
86 {
87  return dimensions_[type];
88 }
89 
90 
91 inline Foam::scalar Foam::unitSet::operator[]
92 (
93  const dimlessUnitType type
94 ) const
95 {
96  return exponents_[static_cast<int>(type)];
97 }
98 
99 
100 // ************************************************************************* //
Dimension set for the base types.
Definition: dimensionSet.H:125
dimensionType
Define an enumeration for the names of the dimension exponents.
Definition: dimensionSet.H:139
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
Definition: unitSet.H:68
static unitSet newAny()
Return a new "any" unit set.
Definition: unitSetI.H:36
bool none() const
Return whether this is the "none" unit. I.e., the case where unit.
Definition: unitSetI.H:68
const dimensionSet & dimensions() const
Access the dimensions.
Definition: unitSetI.H:50
static unitSet newNone()
Return a new "none" unit set.
Definition: unitSetI.H:42
bool standard() const
Return whether this unit is standard. I.e., is its multiplier one?
Definition: unitSetI.H:74
static unitSet newUnitless()
Return a new "unitless" unit set.
Definition: unitSetI.H:30
unitSet(const dimensionSet &, const scalar fraction, const scalar angle, const scalar multiplier)
Construct from components.
Definition: unitSet.C:90
bool dimensionless() const
Return true if it is dimensionless.
Definition: unitSetI.H:56
dimlessUnitType
Define an enumeration for the names of the dimensionless unit.
Definition: unitSet.H:82
bool any() const
Return whether this is the "any" unit. I.e., the case where.
Definition: unitSetI.H:62
bool any(const boolList &l)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488