1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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&);
82 // Function to check the argument is dimensionless
83 // for transcendental functions
84 dimensionSet trans(const dimensionSet&);
86 // Return the argument; transformations do not change the dimensions
87 dimensionSet transform(const dimensionSet&);
91 dimensionSet operator-(const dimensionSet&);
92 dimensionSet operator+(const dimensionSet&, 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&);
100 // IOstream operators
102 Istream& operator>>(Istream&, dimensionSet&);
103 Ostream& operator<<(Ostream&, const dimensionSet&);
106 /*---------------------------------------------------------------------------*\
107 Class dimensionSet Declaration
108 \*---------------------------------------------------------------------------*/
119 nDimensions = 7 // Number of dimensions in SI is 7
122 //- Define an enumeration for the names of the dimension exponents
128 TEMPERATURE, // Kelvin K
131 LUMINOUS_INTENSITY // Candela Cd
135 // Static data members
137 static const scalar smallExponent;
144 // dimensionSet stored as an array of dimension exponents
145 scalar exponents_[nDimensions];
150 // Declare name of the class and its debug switch
151 ClassName("dimensionSet");
156 //- Construct given individual dimension exponents for all
163 const scalar temperature,
165 const scalar current,
166 const scalar luminousIntensity
169 //- Construct given individual dimension exponents for first
176 const scalar temperature,
180 //- Construct from Istream
181 dimensionSet(Istream&);
186 bool dimensionless() const;
187 void reset(const dimensionSet&);
192 scalar operator[](const dimensionType) const;
193 scalar& operator[](const dimensionType);
194 bool operator==(const dimensionSet&) const;
195 bool operator!=(const dimensionSet&) const;
197 bool operator=(const dimensionSet&) const;
199 bool operator+=(const dimensionSet&) const;
200 bool operator-=(const dimensionSet&) const;
201 bool operator*=(const dimensionSet&);
202 bool operator/=(const dimensionSet&);
207 friend dimensionSet max(const dimensionSet&, const dimensionSet&);
208 friend dimensionSet min(const dimensionSet&, const dimensionSet&);
209 friend dimensionSet cmptMultiply
214 friend dimensionSet cmptDivide
220 friend dimensionSet pow(const dimensionSet&, const scalar);
221 friend dimensionSet pow(const dimensionSet&, const dimensionedScalar&);
222 friend dimensionSet pow(const dimensionedScalar&, const dimensionSet&);
224 friend dimensionSet sqr(const dimensionSet&);
225 friend dimensionSet pow3(const dimensionSet&);
226 friend dimensionSet pow4(const dimensionSet&);
227 friend dimensionSet pow5(const dimensionSet&);
228 friend dimensionSet pow6(const dimensionSet&);
230 friend dimensionSet sqrt(const dimensionSet&);
231 friend dimensionSet magSqr(const dimensionSet&);
232 friend dimensionSet mag(const dimensionSet&);
233 friend dimensionSet sign(const dimensionSet&);
234 friend dimensionSet pos(const dimensionSet&);
235 friend dimensionSet neg(const dimensionSet&);
236 friend dimensionSet inv(const dimensionSet&);
238 //- Function to check the argument is dimensionless
239 // for transcendental functions
240 friend dimensionSet trans(const dimensionSet&);
242 //- Return the argument; transformations do not change the dimensions
243 friend dimensionSet transform(const dimensionSet&);
248 friend dimensionSet operator-(const dimensionSet&);
250 friend dimensionSet operator+
256 friend dimensionSet operator-
262 friend dimensionSet operator*
268 friend dimensionSet operator/
274 friend dimensionSet operator&
280 friend dimensionSet operator^
286 friend dimensionSet operator&&
293 // IOstream operators
295 friend Istream& operator>>(Istream&, dimensionSet&);
296 friend Ostream& operator<<(Ostream&, const dimensionSet&);
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302 } // End namespace Foam
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 #include "dimensionSets.H"
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 // ************************************************************************* //