1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 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&);
74 dimensionSet sqrt(const dimensionSet&);
75 dimensionSet magSqr(const dimensionSet&);
76 dimensionSet mag(const dimensionSet&);
77 dimensionSet sign(const dimensionSet&);
78 dimensionSet pos(const dimensionSet&);
79 dimensionSet neg(const dimensionSet&);
80 dimensionSet inv(const dimensionSet&);
81 dimensionSet hinv(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 bool dimensionless() const;
188 void reset(const dimensionSet&);
193 scalar operator[](const dimensionType) const;
194 scalar& operator[](const dimensionType);
195 bool operator==(const dimensionSet&) const;
196 bool operator!=(const dimensionSet&) const;
198 bool operator=(const dimensionSet&) const;
200 bool operator+=(const dimensionSet&) const;
201 bool operator-=(const dimensionSet&) const;
202 bool operator*=(const dimensionSet&);
203 bool operator/=(const dimensionSet&);
208 friend dimensionSet max(const dimensionSet&, const dimensionSet&);
209 friend dimensionSet min(const dimensionSet&, const dimensionSet&);
210 friend dimensionSet cmptMultiply
215 friend dimensionSet cmptDivide
221 friend dimensionSet pow(const dimensionSet&, const scalar);
222 friend dimensionSet pow(const dimensionSet&, const dimensionedScalar&);
223 friend dimensionSet pow(const dimensionedScalar&, const dimensionSet&);
225 friend dimensionSet sqr(const dimensionSet&);
226 friend dimensionSet pow3(const dimensionSet&);
227 friend dimensionSet pow4(const dimensionSet&);
228 friend dimensionSet pow5(const dimensionSet&);
229 friend dimensionSet pow6(const dimensionSet&);
231 friend dimensionSet sqrt(const dimensionSet&);
232 friend dimensionSet magSqr(const dimensionSet&);
233 friend dimensionSet mag(const dimensionSet&);
234 friend dimensionSet sign(const dimensionSet&);
235 friend dimensionSet pos(const dimensionSet&);
236 friend dimensionSet neg(const dimensionSet&);
237 friend dimensionSet inv(const dimensionSet&);
239 //- Function to check the argument is dimensionless
240 // for transcendental functions
241 friend dimensionSet trans(const dimensionSet&);
243 //- Return the argument; transformations do not change the dimensions
244 friend dimensionSet transform(const dimensionSet&);
249 friend dimensionSet operator-(const dimensionSet&);
251 friend dimensionSet operator+
257 friend dimensionSet operator-
263 friend dimensionSet operator*
269 friend dimensionSet operator/
275 friend dimensionSet operator&
281 friend dimensionSet operator^
287 friend dimensionSet operator&&
294 // IOstream operators
296 friend Istream& operator>>(Istream&, dimensionSet&);
297 friend Ostream& operator<<(Ostream&, const dimensionSet&);
301 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 } // End namespace Foam
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 #include "dimensionSets.H"
309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 // ************************************************************************* //