1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "DimensionedScalarField.H"
28 #define TEMPLATE template<class GeoMesh>
29 #include "DimensionedFieldFunctionsM.C"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
38 template<class GeoMesh>
39 tmp<DimensionedField<scalar, GeoMesh> > stabilise
41 const DimensionedField<scalar, GeoMesh>& dsf,
42 const dimensioned<scalar>& ds
45 tmp<DimensionedField<scalar, GeoMesh> > tRes
47 new DimensionedField<scalar, GeoMesh>
51 "stabilise(" + dsf.name() + ',' + ds.name() + ')',
56 dsf.dimensions() + ds.dimensions()
60 stabilise(tRes().field(), dsf.field(), ds.value());
66 template<class GeoMesh>
67 tmp<DimensionedField<scalar, GeoMesh> > stabilise
69 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf,
70 const dimensioned<scalar>& ds
73 const DimensionedField<scalar, GeoMesh>& dsf = tdsf();
75 tmp<DimensionedField<scalar, GeoMesh> > tRes =
76 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
79 "stabilise(" + dsf.name() + ',' + ds.name() + ')',
80 dsf.dimensions() + ds.dimensions()
83 stabilise(tRes().field(), dsf.field(), ds.value());
85 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf);
91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
93 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, '+', add)
94 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, '-', subtract)
96 BINARY_OPERATOR(scalar, scalar, scalar, *, '*', multiply)
97 BINARY_OPERATOR(scalar, scalar, scalar, /, '|', divide)
99 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, '|', divide)
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 template<class GeoMesh>
104 tmp<DimensionedField<scalar, GeoMesh> > pow
106 const DimensionedField<scalar, GeoMesh>& dsf1,
107 const DimensionedField<scalar, GeoMesh>& dsf2
110 tmp<DimensionedField<scalar, GeoMesh> > tPow
112 new DimensionedField<scalar, GeoMesh>
116 "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
124 dimensionedScalar("1", 1.0, dsf2.dimensions())
129 pow(tPow().field(), dsf1.field(), dsf2.field());
135 template<class GeoMesh>
136 tmp<DimensionedField<scalar, GeoMesh> > pow
138 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf1,
139 const DimensionedField<scalar, GeoMesh>& dsf2
142 const DimensionedField<scalar, GeoMesh>& dsf1 = tdsf1();
144 tmp<DimensionedField<scalar, GeoMesh> > tPow =
145 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
148 "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
152 dimensionedScalar("1", 1.0, dsf2.dimensions())
156 pow(tPow().field(), dsf1.field(), dsf2.field());
158 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf1);
164 template<class GeoMesh>
165 tmp<DimensionedField<scalar, GeoMesh> > pow
167 const DimensionedField<scalar, GeoMesh>& dsf1,
168 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf2
171 const DimensionedField<scalar, GeoMesh>& dsf2 = tdsf2();
173 tmp<DimensionedField<scalar, GeoMesh> > tPow =
174 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
177 "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
181 dimensionedScalar("1", 1.0, dsf2.dimensions())
185 pow(tPow().field(), dsf1.field(), dsf2.field());
187 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf2);
192 template<class GeoMesh>
193 tmp<DimensionedField<scalar, GeoMesh> > pow
195 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf1,
196 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf2
199 const DimensionedField<scalar, GeoMesh>& dsf1 = tdsf1();
200 const DimensionedField<scalar, GeoMesh>& dsf2 = tdsf2();
202 tmp<DimensionedField<scalar, GeoMesh> > tPow =
203 reuseTmpTmpDimensionedField<scalar, scalar, scalar, scalar, GeoMesh>::
208 "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
212 dimensionedScalar("1", 1.0, dsf2.dimensions())
216 pow(tPow().field(), dsf1.field(), dsf2.field());
218 reuseTmpTmpDimensionedField<scalar, scalar, scalar, scalar, GeoMesh>::clear
228 template<class GeoMesh>
229 tmp<DimensionedField<scalar, GeoMesh> > pow
231 const DimensionedField<scalar, GeoMesh>& dsf,
232 const dimensionedScalar& ds
235 tmp<DimensionedField<scalar, GeoMesh> > tPow
237 new DimensionedField<scalar, GeoMesh>
241 "pow(" + dsf.name() + ',' + ds.name() + ')',
246 pow(dsf.dimensions(), ds)
250 pow(tPow().field(), dsf.field(), ds.value());
255 template<class GeoMesh>
256 tmp<DimensionedField<scalar, GeoMesh> > pow
258 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf,
259 const dimensionedScalar& ds
262 const DimensionedField<scalar, GeoMesh>& dsf = tdsf();
264 tmp<DimensionedField<scalar, GeoMesh> > tPow =
265 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
268 "pow(" + dsf.name() + ',' + ds.name() + ')',
269 pow(dsf.dimensions(), ds)
272 pow(tPow().field(), dsf.field(), ds.value());
274 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf);
279 template<class GeoMesh>
280 tmp<DimensionedField<scalar, GeoMesh> > pow
282 const DimensionedField<scalar, GeoMesh>& dsf,
286 return pow(dsf, dimensionedScalar(s));
289 template<class GeoMesh>
290 tmp<DimensionedField<scalar, GeoMesh> > pow
292 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf,
296 return pow(tdsf, dimensionedScalar(s));
300 template<class GeoMesh>
301 tmp<DimensionedField<scalar, GeoMesh> > pow
303 const dimensionedScalar& ds,
304 const DimensionedField<scalar, GeoMesh>& dsf
307 tmp<DimensionedField<scalar, GeoMesh> > tPow
309 new DimensionedField<scalar, GeoMesh>
313 "pow(" + ds.name() + ',' + dsf.name() + ')',
318 pow(ds, dsf.dimensions())
322 pow(tPow().field(), ds.value(), dsf.field());
328 template<class GeoMesh>
329 tmp<DimensionedField<scalar, GeoMesh> > pow
331 const dimensionedScalar& ds,
332 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf
335 const DimensionedField<scalar, GeoMesh>& dsf = tdsf();
337 tmp<DimensionedField<scalar, GeoMesh> > tPow =
338 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
341 "pow(" + ds.name() + ',' + dsf.name() + ')',
342 pow(ds, dsf.dimensions())
345 pow(tPow().field(), ds.value(), dsf.field());
347 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf);
352 template<class GeoMesh>
353 tmp<DimensionedField<scalar, GeoMesh> > pow
356 const DimensionedField<scalar, GeoMesh>& dsf
359 return pow(dimensionedScalar(s), dsf);
362 template<class GeoMesh>
363 tmp<DimensionedField<scalar, GeoMesh> > pow
366 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf
369 return pow(dimensionedScalar(s), tdsf);
372 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
374 UNARY_FUNCTION(scalar, scalar, pow3, pow3)
375 UNARY_FUNCTION(scalar, scalar, pow4, pow4)
376 UNARY_FUNCTION(scalar, scalar, pow5, pow5)
377 UNARY_FUNCTION(scalar, scalar, pow6, pow6)
378 UNARY_FUNCTION(scalar, scalar, pow025, pow025)
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 // ************************************************************************* //