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 "GeometricScalarField.H"
29 #define TEMPLATE template<template<class> class PatchField, class GeoMesh>
30 #include "GeometricFieldFunctionsM.C"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
39 template<template<class> class PatchField, class GeoMesh>
42 GeometricField<scalar, PatchField, GeoMesh>& result,
43 const GeometricField<scalar, PatchField, GeoMesh>& gsf,
44 const dimensioned<scalar>& ds
47 stabilise(result.internalField(), gsf.internalField(), ds.value());
48 stabilise(result.boundaryField(), gsf.boundaryField(), ds.value());
52 template<template<class> class PatchField, class GeoMesh>
53 tmp<GeometricField<scalar, PatchField, GeoMesh> > stabilise
55 const GeometricField<scalar, PatchField, GeoMesh>& gsf,
56 const dimensioned<scalar>& ds
59 tmp<GeometricField<scalar, PatchField, GeoMesh> > tRes
61 new GeometricField<scalar, PatchField, GeoMesh>
65 "stabilise(" + gsf.name() + ',' + ds.name() + ')',
72 ds.dimensions() + gsf.dimensions()
76 stabilise(tRes(), gsf, ds);
82 template<template<class> class PatchField, class GeoMesh>
83 tmp<GeometricField<scalar, PatchField, GeoMesh> > stabilise
85 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf,
86 const dimensioned<scalar>& ds
89 const GeometricField<scalar, PatchField, GeoMesh>& gsf = tgsf();
91 tmp<GeometricField<scalar, PatchField, GeoMesh> > tRes
93 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::New
96 "stabilise(" + gsf.name() + ',' + ds.name() + ')',
97 ds.dimensions() + gsf.dimensions()
101 stabilise(tRes(), gsf, ds);
103 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::clear(tgsf);
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, '+', add)
112 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, '-', subtract)
114 BINARY_OPERATOR(scalar, scalar, scalar, *, '*', multiply)
115 BINARY_OPERATOR(scalar, scalar, scalar, /, '|', divide)
117 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, '|', divide)
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 template<template<class> class PatchField, class GeoMesh>
124 GeometricField<scalar, PatchField, GeoMesh>& Pow,
125 const GeometricField<scalar, PatchField, GeoMesh>& gsf1,
126 const GeometricField<scalar, PatchField, GeoMesh>& gsf2
129 pow(Pow.internalField(), gsf1.internalField(), gsf2.internalField());
130 pow(Pow.boundaryField(), gsf1.boundaryField(), gsf2.boundaryField());
134 template<template<class> class PatchField, class GeoMesh>
135 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
137 const GeometricField<scalar, PatchField, GeoMesh>& gsf1,
138 const GeometricField<scalar, PatchField, GeoMesh>& gsf2
141 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
143 new GeometricField<scalar, PatchField, GeoMesh>
147 "pow(" + gsf1.name() + ',' + gsf2.name() + ')',
157 dimensionedScalar("1", gsf2.dimensions(), 1.0)
162 pow(tPow(), gsf1, gsf2);
168 template<template<class> class PatchField, class GeoMesh>
169 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
171 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf1,
172 const GeometricField<scalar, PatchField, GeoMesh>& gsf2
175 const GeometricField<scalar, PatchField, GeoMesh>& gsf1 = tgsf1();
177 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
179 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::New
182 "pow(" + gsf1.name() + ',' + gsf2.name() + ')',
186 dimensionedScalar("1", gsf2.dimensions(), 1.0)
191 pow(tPow(), gsf1, gsf2);
193 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::clear(tgsf1);
199 template<template<class> class PatchField, class GeoMesh>
200 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
202 const GeometricField<scalar, PatchField, GeoMesh>& gsf1,
203 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf2
206 const GeometricField<scalar, PatchField, GeoMesh>& gsf2 = tgsf2();
208 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
210 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::New
213 "pow(" + gsf1.name() + ',' + gsf2.name() + ')',
217 dimensionedScalar("1", gsf2.dimensions(), 1.0)
222 pow(tPow(), gsf1, gsf2);
224 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::clear(tgsf2);
229 template<template<class> class PatchField, class GeoMesh>
230 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
232 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf1,
233 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf2
236 const GeometricField<scalar, PatchField, GeoMesh>& gsf1 = tgsf1();
237 const GeometricField<scalar, PatchField, GeoMesh>& gsf2 = tgsf2();
239 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
241 reuseTmpTmpGeometricField
242 <scalar, scalar, scalar, scalar, PatchField, GeoMesh>::New
246 "pow(" + gsf1.name() + ',' + gsf2.name() + ')',
250 dimensionedScalar("1", gsf2.dimensions(), 1.0)
255 pow(tPow(), gsf1, gsf2);
257 reuseTmpTmpGeometricField
258 <scalar, scalar, scalar, scalar, PatchField, GeoMesh>
259 ::clear(tgsf1, tgsf2);
265 template<template<class> class PatchField, class GeoMesh>
268 GeometricField<scalar, PatchField, GeoMesh>& tPow,
269 const GeometricField<scalar, PatchField, GeoMesh>& gsf,
270 const dimensioned<scalar>& ds
273 pow(tPow.internalField(), gsf.internalField(), ds.value());
274 pow(tPow.boundaryField(), gsf.boundaryField(), ds.value());
278 template<template<class> class PatchField, class GeoMesh>
279 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
281 const GeometricField<scalar, PatchField, GeoMesh>& gsf,
282 const dimensionedScalar& ds
285 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
287 new GeometricField<scalar, PatchField, GeoMesh>
291 "pow(" + gsf.name() + ',' + ds.name() + ')',
298 pow(gsf.dimensions(), ds)
302 pow(tPow(), gsf, ds);
307 template<template<class> class PatchField, class GeoMesh>
308 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
310 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf,
311 const dimensionedScalar& ds
314 const GeometricField<scalar, PatchField, GeoMesh>& gsf = tgsf();
316 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
318 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::New
321 "pow(" + gsf.name() + ',' + ds.name() + ')',
322 pow(gsf.dimensions(), ds)
326 pow(tPow(), gsf, ds);
328 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::clear(tgsf);
333 template<template<class> class PatchField, class GeoMesh>
334 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
336 const GeometricField<scalar, PatchField, GeoMesh>& gsf,
340 return pow(gsf, dimensionedScalar(s));
343 template<template<class> class PatchField, class GeoMesh>
344 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
346 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf,
350 return pow(tgsf, dimensionedScalar(s));
354 template<template<class> class PatchField, class GeoMesh>
357 GeometricField<scalar, PatchField, GeoMesh>& tPow,
358 const dimensioned<scalar>& ds,
359 const GeometricField<scalar, PatchField, GeoMesh>& gsf
362 pow(tPow.internalField(), ds.value(), gsf.internalField());
363 pow(tPow.boundaryField(), ds.value(), gsf.boundaryField());
367 template<template<class> class PatchField, class GeoMesh>
368 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
370 const dimensionedScalar& ds,
371 const GeometricField<scalar, PatchField, GeoMesh>& gsf
374 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
376 new GeometricField<scalar, PatchField, GeoMesh>
380 "pow(" + ds.name() + ',' + gsf.name() + ')',
387 pow(ds, gsf.dimensions())
391 pow(tPow(), ds, gsf);
397 template<template<class> class PatchField, class GeoMesh>
398 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
400 const dimensionedScalar& ds,
401 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf
404 const GeometricField<scalar, PatchField, GeoMesh>& gsf = tgsf();
406 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
408 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::New
411 "pow(" + ds.name() + ',' + gsf.name() + ')',
412 pow(ds, gsf.dimensions())
416 pow(tPow(), ds, gsf);
418 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::clear(tgsf);
423 template<template<class> class PatchField, class GeoMesh>
424 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
427 const GeometricField<scalar, PatchField, GeoMesh>& gsf
430 return pow(dimensionedScalar(s), gsf);
433 template<template<class> class PatchField, class GeoMesh>
434 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
437 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf
440 return pow(dimensionedScalar(s), tgsf);
444 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
446 UNARY_FUNCTION(scalar, scalar, pow3, pow3)
447 UNARY_FUNCTION(scalar, scalar, pow4, pow4)
448 UNARY_FUNCTION(scalar, scalar, pow5, pow5)
449 UNARY_FUNCTION(scalar, scalar, pow6, pow6)
450 UNARY_FUNCTION(scalar, scalar, sqrt, sqrt)
451 UNARY_FUNCTION(scalar, scalar, sign, sign)
452 UNARY_FUNCTION(scalar, scalar, pos, pos)
453 UNARY_FUNCTION(scalar, scalar, neg, neg)
455 UNARY_FUNCTION(scalar, scalar, exp, trans)
456 UNARY_FUNCTION(scalar, scalar, log, trans)
457 UNARY_FUNCTION(scalar, scalar, log10, trans)
458 UNARY_FUNCTION(scalar, scalar, sin, trans)
459 UNARY_FUNCTION(scalar, scalar, cos, trans)
460 UNARY_FUNCTION(scalar, scalar, tan, trans)
461 UNARY_FUNCTION(scalar, scalar, asin, trans)
462 UNARY_FUNCTION(scalar, scalar, acos, trans)
463 UNARY_FUNCTION(scalar, scalar, atan, trans)
464 UNARY_FUNCTION(scalar, scalar, sinh, trans)
465 UNARY_FUNCTION(scalar, scalar, cosh, trans)
466 UNARY_FUNCTION(scalar, scalar, tanh, trans)
467 UNARY_FUNCTION(scalar, scalar, asinh, trans)
468 UNARY_FUNCTION(scalar, scalar, acosh, trans)
469 UNARY_FUNCTION(scalar, scalar, atanh, trans)
470 UNARY_FUNCTION(scalar, scalar, erf, trans)
471 UNARY_FUNCTION(scalar, scalar, erfc, trans)
472 UNARY_FUNCTION(scalar, scalar, lgamma, trans)
473 UNARY_FUNCTION(scalar, scalar, j0, trans)
474 UNARY_FUNCTION(scalar, scalar, j1, trans)
475 UNARY_FUNCTION(scalar, scalar, y0, trans)
476 UNARY_FUNCTION(scalar, scalar, y1, trans)
479 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
481 #define BesselFunc(func) \
483 template<template<class> class PatchField, class GeoMesh> \
486 GeometricField<scalar, PatchField, GeoMesh>& gsf, \
488 const GeometricField<scalar, PatchField, GeoMesh>& gsf1 \
491 func(gsf.internalField(), n, gsf1.internalField()); \
492 func(gsf.boundaryField(), n, gsf1.boundaryField()); \
495 template<template<class> class PatchField, class GeoMesh> \
496 tmp<GeometricField<scalar, PatchField, GeoMesh> > func \
499 const GeometricField<scalar, PatchField, GeoMesh>& gsf \
502 if (!gsf.dimensions().dimensionless()) \
506 #func"(const int n, " \
507 "const GeometricField<scalar, PatchField, GeoMesh>& gsf)" \
508 ) << "gsf not dimensionless" \
509 << abort(FatalError); \
512 tmp<GeometricField<scalar, PatchField, GeoMesh> > tFunc \
514 new GeometricField<scalar, PatchField, GeoMesh> \
518 #func "(" + gsf.name() + ')', \
529 func(tFunc(), n, gsf); \
534 template<template<class> class PatchField, class GeoMesh> \
535 tmp<GeometricField<scalar, PatchField, GeoMesh> > func \
538 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf \
541 const GeometricField<scalar, PatchField, GeoMesh>& gsf = tgsf(); \
543 if (!gsf.dimensions().dimensionless()) \
547 #func"(const int n, " \
548 "const tmp<GeometricField<scalar, PatchField, GeoMesh> >& gsf)" \
549 ) << " : gsf not dimensionless" \
550 << abort(FatalError); \
553 tmp<GeometricField<scalar, PatchField, GeoMesh> > tFunc \
555 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::New \
558 #func "(" + gsf.name() + ')', \
563 func(tFunc(), n, gsf); \
565 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh> \
577 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
579 } // End namespace Foam
581 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
583 #include "undefFieldFunctionsM.H"
585 // ************************************************************************* //