1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
28 Dimension set for the base types.
30 This type may be used to implement rigorous dimension checking
31 for algebraic manipulation.
38 \*---------------------------------------------------------------------------*/
40 #ifndef dimensionSet_H
41 #define dimensionSet_H
45 #include "dimensionedScalarFwd.H"
46 #include "className.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 // Forward declaration of friend functions and operators
59 dimensionSet max(const dimensionSet&, const dimensionSet&);
60 dimensionSet min(const dimensionSet&, const dimensionSet&);
61 dimensionSet cmptMultiply(const dimensionSet&, const dimensionSet&);
62 dimensionSet cmptDivide(const dimensionSet&, const dimensionSet&);
64 dimensionSet pow(const dimensionSet&, const scalar);
65 dimensionSet pow(const dimensionSet&, const dimensionedScalar&);
66 dimensionSet pow(const dimensionedScalar&, const dimensionSet&);
68 dimensionSet sqr(const dimensionSet&);
69 dimensionSet pow3(const dimensionSet&);
70 dimensionSet pow4(const dimensionSet&);
71 dimensionSet pow5(const dimensionSet&);
72 dimensionSet pow6(const dimensionSet&);
73 dimensionSet pow025(const dimensionSet&);
75 dimensionSet sqrt(const dimensionSet&);
76 dimensionSet magSqr(const dimensionSet&);
77 dimensionSet mag(const dimensionSet&);
78 dimensionSet sign(const dimensionSet&);
79 dimensionSet pos(const dimensionSet&);
80 dimensionSet neg(const dimensionSet&);
81 dimensionSet inv(const dimensionSet&);
83 // Function to check the argument is dimensionless
84 // for transcendental functions
85 dimensionSet trans(const dimensionSet&);
87 // Return the argument; transformations do not change the dimensions
88 dimensionSet transform(const dimensionSet&);
92 dimensionSet operator-(const dimensionSet&);
93 dimensionSet operator+(const dimensionSet&, const dimensionSet&);
94 dimensionSet operator-(const dimensionSet&, const dimensionSet&);
95 dimensionSet operator*(const dimensionSet&, const dimensionSet&);
96 dimensionSet operator/(const dimensionSet&, const dimensionSet&);
97 dimensionSet operator&(const dimensionSet&, const dimensionSet&);
98 dimensionSet operator^(const dimensionSet&, const dimensionSet&);
99 dimensionSet operator&&(const dimensionSet&, const dimensionSet&);
101 // IOstream operators
103 Istream& operator>>(Istream&, dimensionSet&);
104 Ostream& operator<<(Ostream&, const dimensionSet&);
107 /*---------------------------------------------------------------------------*\
108 Class dimensionSet Declaration
109 \*---------------------------------------------------------------------------*/
120 nDimensions = 7 // Number of dimensions in SI is 7
123 //- Define an enumeration for the names of the dimension exponents
129 TEMPERATURE, // Kelvin K
132 LUMINOUS_INTENSITY // Candela Cd
136 // Static data members
138 static const scalar smallExponent;
145 // dimensionSet stored as an array of dimension exponents
146 scalar exponents_[nDimensions];
151 // Declare name of the class and its debug switch
152 ClassName("dimensionSet");
157 //- Construct given individual dimension exponents for all
164 const scalar temperature,
166 const scalar current,
167 const scalar luminousIntensity
170 //- Construct given individual dimension exponents for first
177 const scalar temperature,
181 //- Construct from Istream
182 dimensionSet(Istream&);
187 //- Return true if it is dimensionless
188 bool dimensionless() const;
190 void reset(const dimensionSet&);
192 //- Return a text representation for added readability
193 string asText() const;
198 scalar operator[](const dimensionType) const;
199 scalar& operator[](const dimensionType);
200 bool operator==(const dimensionSet&) const;
201 bool operator!=(const dimensionSet&) const;
203 bool operator=(const dimensionSet&) const;
205 bool operator+=(const dimensionSet&) const;
206 bool operator-=(const dimensionSet&) const;
207 bool operator*=(const dimensionSet&);
208 bool operator/=(const dimensionSet&);
213 friend dimensionSet max(const dimensionSet&, const dimensionSet&);
214 friend dimensionSet min(const dimensionSet&, const dimensionSet&);
215 friend dimensionSet cmptMultiply
220 friend dimensionSet cmptDivide
226 friend dimensionSet pow(const dimensionSet&, const scalar);
227 friend dimensionSet pow(const dimensionSet&, const dimensionedScalar&);
228 friend dimensionSet pow(const dimensionedScalar&, const dimensionSet&);
230 friend dimensionSet sqr(const dimensionSet&);
231 friend dimensionSet pow3(const dimensionSet&);
232 friend dimensionSet pow4(const dimensionSet&);
233 friend dimensionSet pow5(const dimensionSet&);
234 friend dimensionSet pow6(const dimensionSet&);
235 friend dimensionSet pow025(const dimensionSet&);
237 friend dimensionSet sqrt(const dimensionSet&);
238 friend dimensionSet magSqr(const dimensionSet&);
239 friend dimensionSet mag(const dimensionSet&);
240 friend dimensionSet sign(const dimensionSet&);
241 friend dimensionSet pos(const dimensionSet&);
242 friend dimensionSet neg(const dimensionSet&);
243 friend dimensionSet inv(const dimensionSet&);
245 //- Function to check the argument is dimensionless
246 // for transcendental functions
247 friend dimensionSet trans(const dimensionSet&);
249 //- Return the argument; transformations do not change the dimensions
250 friend dimensionSet transform(const dimensionSet&);
255 friend dimensionSet operator-(const dimensionSet&);
257 friend dimensionSet operator+
263 friend dimensionSet operator-
269 friend dimensionSet operator*
275 friend dimensionSet operator/
281 friend dimensionSet operator&
287 friend dimensionSet operator^
293 friend dimensionSet operator&&
300 // IOstream operators
302 friend Istream& operator>>(Istream&, dimensionSet&);
303 friend Ostream& operator<<(Ostream&, const dimensionSet&);
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
309 } // End namespace Foam
311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 #include "dimensionSets.H"
315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
319 // ************************************************************************* //