1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | 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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "dimensionedScalar.H"
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 dimensionedScalar operator+(const dimensionedScalar& ds1, const scalar s2)
37 return ds1 + dimensionedScalar(s2);
40 dimensionedScalar operator+(const scalar s1, const dimensionedScalar& ds2)
42 return dimensionedScalar(s1) + ds2;
45 dimensionedScalar operator-(const dimensionedScalar& ds1, const scalar s2)
47 return ds1 - dimensionedScalar(s2);
50 dimensionedScalar operator-(const scalar s1, const dimensionedScalar& ds2)
52 return dimensionedScalar(s1) - ds2;
55 dimensionedScalar operator*(const dimensionedScalar& ds1, const scalar s2)
57 return ds1 * dimensionedScalar(s2);
60 dimensionedScalar operator/(const scalar s1, const dimensionedScalar& ds2)
62 return dimensionedScalar(s1)/ds2;
68 const dimensionedScalar& ds,
69 const dimensionedScalar& expt
72 return dimensionedScalar
74 "pow(" + ds.name() + ',' + expt.name() + ')',
75 pow(ds.dimensions(), expt),
76 ::pow(ds.value(), expt.value())
80 dimensionedScalar pow3(const dimensionedScalar& ds)
82 return dimensionedScalar
84 "pow3(" + ds.name() + ')',
85 pow3(ds.dimensions()),
90 dimensionedScalar pow4(const dimensionedScalar& ds)
92 return dimensionedScalar
94 "pow4(" + ds.name() + ')',
95 pow4(ds.dimensions()),
100 dimensionedScalar pow5(const dimensionedScalar& ds)
102 return dimensionedScalar
104 "pow5(" + ds.name() + ')',
105 pow5(ds.dimensions()),
110 dimensionedScalar pow6(const dimensionedScalar& ds)
112 return dimensionedScalar
114 "pow6(" + ds.name() + ')',
115 pow6(ds.dimensions()),
120 dimensionedScalar sqrt(const dimensionedScalar& ds)
122 return dimensionedScalar
124 "sqrt(" + ds.name() + ')',
125 pow(ds.dimensions(), dimensionedScalar("0.5", dimless, 0.5)),
130 dimensionedScalar cbrt(const dimensionedScalar& ds)
132 return dimensionedScalar
134 "cbrt(" + ds.name() + ')',
135 pow(ds.dimensions(), dimensionedScalar("(1|3)", dimless, 1.0/3.0)),
140 dimensionedScalar hypot
142 const dimensionedScalar& x,
143 const dimensionedScalar& y
146 return dimensionedScalar
148 "hypot(" + x.name() + ',' + y.name() + ')',
149 x.dimensions() + y.dimensions(),
150 ::hypot(x.value(), y.value())
154 dimensionedScalar sign(const dimensionedScalar& ds)
156 return dimensionedScalar
158 "sign(" + ds.name() + ')',
159 sign(ds.dimensions()),
160 ::Foam::sign(ds.value())
164 dimensionedScalar pos(const dimensionedScalar& ds)
166 return dimensionedScalar
168 "pos(" + ds.name() + ')',
169 pos(ds.dimensions()),
170 ::Foam::pos(ds.value())
174 dimensionedScalar neg(const dimensionedScalar& ds)
176 return dimensionedScalar
178 "neg(" + ds.name() + ')',
179 neg(ds.dimensions()),
180 ::Foam::neg(ds.value())
185 #define transFunc(func) \
186 dimensionedScalar func(const dimensionedScalar& ds) \
188 if (!ds.dimensions().dimensionless()) \
190 FatalErrorIn(#func "(const dimensionedScalar& ds)") \
191 << "ds not dimensionless" \
192 << abort(FatalError); \
195 return dimensionedScalar \
197 #func "(" + ds.name() + ')', \
229 #define transFunc(func) \
230 dimensionedScalar func(const int n, const dimensionedScalar& ds) \
232 if (!ds.dimensions().dimensionless()) \
234 FatalErrorIn(#func "(const int n, const dimensionedScalar& ds)") \
235 << "ds not dimensionless" \
236 << abort(FatalError); \
239 return dimensionedScalar \
241 #func "(" + name(n) + ',' + ds.name() + ')', \
243 ::func(n, ds.value()) \
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 } // End namespace Foam
257 // ************************************************************************* //