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
25 \*---------------------------------------------------------------------------*/
27 #include "dimensionedScalar.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 dimensionedScalar operator+(const dimensionedScalar& ds1, const scalar s2)
38 return ds1 + dimensionedScalar(s2);
41 dimensionedScalar operator+(const scalar s1, const dimensionedScalar& ds2)
43 return dimensionedScalar(s1) + ds2;
46 dimensionedScalar operator-(const dimensionedScalar& ds1, const scalar s2)
48 return ds1 - dimensionedScalar(s2);
51 dimensionedScalar operator-(const scalar s1, const dimensionedScalar& ds2)
53 return dimensionedScalar(s1) - ds2;
56 dimensionedScalar operator*(const dimensionedScalar& ds1, const scalar s2)
58 return ds1 * dimensionedScalar(s2);
61 dimensionedScalar operator/(const scalar s1, const dimensionedScalar& ds2)
63 return dimensionedScalar(s1)/ds2;
69 const dimensionedScalar& ds,
70 const dimensionedScalar& expt
73 return dimensionedScalar
75 "pow(" + ds.name() + ',' + expt.name() + ')',
76 pow(ds.dimensions(), expt),
77 ::pow(ds.value(), expt.value())
81 dimensionedScalar pow3(const dimensionedScalar& ds)
83 return dimensionedScalar
85 "pow3(" + ds.name() + ')',
86 pow3(ds.dimensions()),
91 dimensionedScalar pow4(const dimensionedScalar& ds)
93 return dimensionedScalar
95 "pow4(" + ds.name() + ')',
96 pow4(ds.dimensions()),
101 dimensionedScalar pow5(const dimensionedScalar& ds)
103 return dimensionedScalar
105 "pow5(" + ds.name() + ')',
106 pow5(ds.dimensions()),
111 dimensionedScalar pow6(const dimensionedScalar& ds)
113 return dimensionedScalar
115 "pow6(" + ds.name() + ')',
116 pow6(ds.dimensions()),
121 dimensionedScalar sqrt(const dimensionedScalar& ds)
123 return dimensionedScalar
125 "sqrt(" + ds.name() + ')',
126 pow(ds.dimensions(), dimensionedScalar("0.5", dimless, 0.5)),
131 dimensionedScalar cbrt(const dimensionedScalar& ds)
133 return dimensionedScalar
135 "cbrt(" + ds.name() + ')',
136 pow(ds.dimensions(), dimensionedScalar("(1/3)", dimless, 1.0/3.0)),
141 dimensionedScalar hypot
143 const dimensionedScalar& x,
144 const dimensionedScalar& y
147 return dimensionedScalar
149 "hypot(" + x.name() + ',' + y.name() + ')',
150 x.dimensions() + y.dimensions(),
151 ::hypot(x.value(), y.value())
155 dimensionedScalar sign(const dimensionedScalar& ds)
157 return dimensionedScalar
159 "sign(" + ds.name() + ')',
160 sign(ds.dimensions()),
161 ::Foam::sign(ds.value())
165 dimensionedScalar pos(const dimensionedScalar& ds)
167 return dimensionedScalar
169 "pos(" + ds.name() + ')',
170 pos(ds.dimensions()),
171 ::Foam::pos(ds.value())
175 dimensionedScalar neg(const dimensionedScalar& ds)
177 return dimensionedScalar
179 "neg(" + ds.name() + ')',
180 neg(ds.dimensions()),
181 ::Foam::neg(ds.value())
186 #define transFunc(func) \
187 dimensionedScalar func(const dimensionedScalar& ds) \
189 if (!ds.dimensions().dimensionless()) \
191 FatalErrorIn(#func "(const dimensionedScalar& ds)") \
192 << "ds not dimensionless" \
193 << abort(FatalError); \
196 return dimensionedScalar \
198 #func "(" + ds.name() + ')', \
230 #define transFunc(func) \
231 dimensionedScalar func(const int n, const dimensionedScalar& ds) \
233 if (!ds.dimensions().dimensionless()) \
235 FatalErrorIn(#func "(const int n, const dimensionedScalar& ds)") \
236 << "ds not dimensionless" \
237 << abort(FatalError); \
240 return dimensionedScalar \
242 #func "(" + name(n) + ',' + ds.name() + ')', \
244 ::func(n, ds.value()) \
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 } // End namespace Foam
258 // ************************************************************************* //