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
25 \*---------------------------------------------------------------------------*/
27 #include "DimensionedScalarField.H"
29 #define TEMPLATE template<class GeoMesh>
30 #include "DimensionedFieldFunctionsM.C"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
39 template<class GeoMesh>
40 tmp<DimensionedField<scalar, GeoMesh> > stabilise
42 const DimensionedField<scalar, GeoMesh>& dsf,
43 const dimensioned<scalar>& ds
46 tmp<DimensionedField<scalar, GeoMesh> > tRes
48 new DimensionedField<scalar, GeoMesh>
52 "stabilise(" + dsf.name() + ',' + ds.name() + ')',
57 dsf.dimensions() + ds.dimensions()
61 stabilise(tRes().field(), dsf.field(), ds.value());
67 template<class GeoMesh>
68 tmp<DimensionedField<scalar, GeoMesh> > stabilise
70 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf,
71 const dimensioned<scalar>& ds
74 const DimensionedField<scalar, GeoMesh>& dsf = tdsf();
76 tmp<DimensionedField<scalar, GeoMesh> > tRes =
77 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
80 "stabilise(" + dsf.name() + ',' + ds.name() + ')',
81 dsf.dimensions() + ds.dimensions()
84 stabilise(tRes().field(), dsf.field(), ds.value());
86 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf);
92 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, '+', add)
95 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, '-', subtract)
97 BINARY_OPERATOR(scalar, scalar, scalar, *, '*', multiply)
98 BINARY_OPERATOR(scalar, scalar, scalar, /, '|', divide)
100 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, '|', divide)
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104 template<class GeoMesh>
105 tmp<DimensionedField<scalar, GeoMesh> > pow
107 const DimensionedField<scalar, GeoMesh>& dsf1,
108 const DimensionedField<scalar, GeoMesh>& dsf2
111 tmp<DimensionedField<scalar, GeoMesh> > tPow
113 new DimensionedField<scalar, GeoMesh>
117 "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
125 dimensionedScalar("1", 1.0, dsf2.dimensions())
130 pow(tPow().field(), dsf1.field(), dsf2.field());
136 template<class GeoMesh>
137 tmp<DimensionedField<scalar, GeoMesh> > pow
139 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf1,
140 const DimensionedField<scalar, GeoMesh>& dsf2
143 const DimensionedField<scalar, GeoMesh>& dsf1 = tdsf1();
145 tmp<DimensionedField<scalar, GeoMesh> > tPow =
146 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
149 "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
153 dimensionedScalar("1", 1.0, dsf2.dimensions())
157 pow(tPow().field(), dsf1.field(), dsf2.field());
159 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf1);
165 template<class GeoMesh>
166 tmp<DimensionedField<scalar, GeoMesh> > pow
168 const DimensionedField<scalar, GeoMesh>& dsf1,
169 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf2
172 const DimensionedField<scalar, GeoMesh>& dsf2 = tdsf2();
174 tmp<DimensionedField<scalar, GeoMesh> > tPow =
175 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
178 "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
182 dimensionedScalar("1", 1.0, dsf2.dimensions())
186 pow(tPow().field(), dsf1.field(), dsf2.field());
188 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf2);
193 template<class GeoMesh>
194 tmp<DimensionedField<scalar, GeoMesh> > pow
196 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf1,
197 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf2
200 const DimensionedField<scalar, GeoMesh>& dsf1 = tdsf1();
201 const DimensionedField<scalar, GeoMesh>& dsf2 = tdsf2();
203 tmp<DimensionedField<scalar, GeoMesh> > tPow =
204 reuseTmpTmpDimensionedField<scalar, scalar, scalar, scalar, GeoMesh>::
209 "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
213 dimensionedScalar("1", 1.0, dsf2.dimensions())
217 pow(tPow().field(), dsf1.field(), dsf2.field());
219 reuseTmpTmpDimensionedField<scalar, scalar, scalar, scalar, GeoMesh>::clear
229 template<class GeoMesh>
230 tmp<DimensionedField<scalar, GeoMesh> > pow
232 const DimensionedField<scalar, GeoMesh>& dsf,
233 const dimensionedScalar& ds
236 tmp<DimensionedField<scalar, GeoMesh> > tPow
238 new DimensionedField<scalar, GeoMesh>
242 "pow(" + dsf.name() + ',' + ds.name() + ')',
247 pow(dsf.dimensions(), ds)
251 pow(tPow().field(), dsf.field(), ds.value());
256 template<class GeoMesh>
257 tmp<DimensionedField<scalar, GeoMesh> > pow
259 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf,
260 const dimensionedScalar& ds
263 const DimensionedField<scalar, GeoMesh>& dsf = tdsf();
265 tmp<DimensionedField<scalar, GeoMesh> > tPow =
266 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
269 "pow(" + dsf.name() + ',' + ds.name() + ')',
270 pow(dsf.dimensions(), ds)
273 pow(tPow().field(), dsf.field(), ds.value());
275 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf);
280 template<class GeoMesh>
281 tmp<DimensionedField<scalar, GeoMesh> > pow
283 const DimensionedField<scalar, GeoMesh>& dsf,
287 return pow(dsf, dimensionedScalar(s));
290 template<class GeoMesh>
291 tmp<DimensionedField<scalar, GeoMesh> > pow
293 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf,
297 return pow(tdsf, dimensionedScalar(s));
301 template<class GeoMesh>
302 tmp<DimensionedField<scalar, GeoMesh> > pow
304 const dimensionedScalar& ds,
305 const DimensionedField<scalar, GeoMesh>& dsf
308 tmp<DimensionedField<scalar, GeoMesh> > tPow
310 new DimensionedField<scalar, GeoMesh>
314 "pow(" + ds.name() + ',' + dsf.name() + ')',
319 pow(ds, dsf.dimensions())
323 pow(tPow().field(), ds.value(), dsf.field());
329 template<class GeoMesh>
330 tmp<DimensionedField<scalar, GeoMesh> > pow
332 const dimensionedScalar& ds,
333 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf
336 const DimensionedField<scalar, GeoMesh>& dsf = tdsf();
338 tmp<DimensionedField<scalar, GeoMesh> > tPow =
339 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
342 "pow(" + ds.name() + ',' + dsf.name() + ')',
343 pow(ds, dsf.dimensions())
346 pow(tPow().field(), ds.value(), dsf.field());
348 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf);
353 template<class GeoMesh>
354 tmp<DimensionedField<scalar, GeoMesh> > pow
357 const DimensionedField<scalar, GeoMesh>& dsf
360 return pow(dimensionedScalar(s), dsf);
363 template<class GeoMesh>
364 tmp<DimensionedField<scalar, GeoMesh> > pow
367 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf
370 return pow(dimensionedScalar(s), tdsf);
373 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
375 UNARY_FUNCTION(scalar, scalar, pow3, pow3)
376 UNARY_FUNCTION(scalar, scalar, pow4, pow4)
377 UNARY_FUNCTION(scalar, scalar, pow5, pow5)
378 UNARY_FUNCTION(scalar, scalar, pow6, pow6)
379 UNARY_FUNCTION(scalar, scalar, sqrt, sqrt)
380 UNARY_FUNCTION(scalar, scalar, sign, sign)
381 UNARY_FUNCTION(scalar, scalar, pos, pos)
382 UNARY_FUNCTION(scalar, scalar, neg, neg)
384 UNARY_FUNCTION(scalar, scalar, exp, trans)
385 UNARY_FUNCTION(scalar, scalar, log, trans)
386 UNARY_FUNCTION(scalar, scalar, log10, trans)
387 UNARY_FUNCTION(scalar, scalar, sin, trans)
388 UNARY_FUNCTION(scalar, scalar, cos, trans)
389 UNARY_FUNCTION(scalar, scalar, tan, trans)
390 UNARY_FUNCTION(scalar, scalar, asin, trans)
391 UNARY_FUNCTION(scalar, scalar, acos, trans)
392 UNARY_FUNCTION(scalar, scalar, atan, trans)
393 UNARY_FUNCTION(scalar, scalar, sinh, trans)
394 UNARY_FUNCTION(scalar, scalar, cosh, trans)
395 UNARY_FUNCTION(scalar, scalar, tanh, trans)
396 UNARY_FUNCTION(scalar, scalar, asinh, trans)
397 UNARY_FUNCTION(scalar, scalar, acosh, trans)
398 UNARY_FUNCTION(scalar, scalar, atanh, trans)
399 UNARY_FUNCTION(scalar, scalar, erf, trans)
400 UNARY_FUNCTION(scalar, scalar, erfc, trans)
401 UNARY_FUNCTION(scalar, scalar, lgamma, trans)
402 UNARY_FUNCTION(scalar, scalar, j0, trans)
403 UNARY_FUNCTION(scalar, scalar, j1, trans)
404 UNARY_FUNCTION(scalar, scalar, y0, trans)
405 UNARY_FUNCTION(scalar, scalar, y1, trans)
408 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
410 #define BesselFunc(func) \
412 template<class GeoMesh> \
413 tmp<DimensionedField<scalar, GeoMesh> > func \
416 const DimensionedField<scalar, GeoMesh>& dsf \
419 if (!dsf.dimensions().dimensionless()) \
423 #func"(const int n, " \
424 "const DimensionedField<scalar, GeoMesh>& dsf)" \
425 ) << "dsf not dimensionless" \
426 << abort(FatalError); \
429 tmp<DimensionedField<scalar, GeoMesh> > tFunc \
431 new DimensionedField<scalar, GeoMesh> \
435 #func "(" + name(n) + ',' + dsf.name() + ')', \
444 func(tFunc().field(), n, dsf.field()); \
449 template<class GeoMesh> \
450 tmp<DimensionedField<scalar, GeoMesh> > func \
453 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf \
456 const DimensionedField<scalar, GeoMesh>& dsf = tdsf(); \
458 if (!dsf.dimensions().dimensionless()) \
462 #func"(const int n, " \
463 "const tmp<DimensionedField<scalar, GeoMesh> >& dsf)" \
464 ) << " : dsf not dimensionless" \
465 << abort(FatalError); \
468 tmp<DimensionedField<scalar, GeoMesh> > tFunc \
470 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New \
473 #func "(" + name(n) + ',' + dsf.name() + ')', \
478 func(tFunc().field(), n, dsf.field()); \
480 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf); \
491 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
493 } // End namespace Foam
495 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
497 #include "undefFieldFunctionsM.H"
499 // ************************************************************************* //