1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Dimension set for the base types.
29 This type may be used to implement rigorous dimension checking
30 for algebraic manipulation.
37 \*---------------------------------------------------------------------------*/
39 #ifndef dimensionSet_H
40 #define dimensionSet_H
44 #include "dimensionedScalarFwd.H"
45 #include "className.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 // Forward declaration of friend functions and operators
58 dimensionSet max(const dimensionSet&, const dimensionSet&);
59 dimensionSet min(const dimensionSet&, const dimensionSet&);
60 dimensionSet cmptMultiply(const dimensionSet&, const dimensionSet&);
61 dimensionSet cmptDivide(const dimensionSet&, const dimensionSet&);
63 dimensionSet pow(const dimensionSet&, const scalar);
64 dimensionSet pow(const dimensionSet&, const dimensionedScalar&);
65 dimensionSet pow(const dimensionedScalar&, const dimensionSet&);
67 dimensionSet sqr(const dimensionSet&);
68 dimensionSet pow3(const dimensionSet&);
69 dimensionSet pow4(const dimensionSet&);
70 dimensionSet pow5(const dimensionSet&);
71 dimensionSet pow6(const dimensionSet&);
73 dimensionSet sqrt(const dimensionSet&);
74 dimensionSet magSqr(const dimensionSet&);
75 dimensionSet mag(const dimensionSet&);
76 dimensionSet sign(const dimensionSet&);
77 dimensionSet pos(const dimensionSet&);
78 dimensionSet neg(const dimensionSet&);
79 dimensionSet inv(const dimensionSet&);
80 dimensionSet hinv(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 // ************************************************************************* //