00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <OpenFOAM/GeometricScalarField.H>
00027
00028 #define TEMPLATE template<template<class> class PatchField, class GeoMesh>
00029 #include <OpenFOAM/GeometricFieldFunctionsM.C>
00030
00031
00032
00033 namespace Foam
00034 {
00035
00036
00037
00038 template<template<class> class PatchField, class GeoMesh>
00039 void stabilise
00040 (
00041 GeometricField<scalar, PatchField, GeoMesh>& result,
00042 const GeometricField<scalar, PatchField, GeoMesh>& gsf,
00043 const dimensioned<scalar>& ds
00044 )
00045 {
00046 stabilise(result.internalField(), gsf.internalField(), ds.value());
00047 stabilise(result.boundaryField(), gsf.boundaryField(), ds.value());
00048 }
00049
00050
00051 template<template<class> class PatchField, class GeoMesh>
00052 tmp<GeometricField<scalar, PatchField, GeoMesh> > stabilise
00053 (
00054 const GeometricField<scalar, PatchField, GeoMesh>& gsf,
00055 const dimensioned<scalar>& ds
00056 )
00057 {
00058 tmp<GeometricField<scalar, PatchField, GeoMesh> > tRes
00059 (
00060 new GeometricField<scalar, PatchField, GeoMesh>
00061 (
00062 IOobject
00063 (
00064 "stabilise(" + gsf.name() + ',' + ds.name() + ')',
00065 gsf.instance(),
00066 gsf.db(),
00067 IOobject::NO_READ,
00068 IOobject::NO_WRITE
00069 ),
00070 gsf.mesh(),
00071 ds.dimensions() + gsf.dimensions()
00072 )
00073 );
00074
00075 stabilise(tRes(), gsf, ds);
00076
00077 return tRes;
00078 }
00079
00080
00081 template<template<class> class PatchField, class GeoMesh>
00082 tmp<GeometricField<scalar, PatchField, GeoMesh> > stabilise
00083 (
00084 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf,
00085 const dimensioned<scalar>& ds
00086 )
00087 {
00088 const GeometricField<scalar, PatchField, GeoMesh>& gsf = tgsf();
00089
00090 tmp<GeometricField<scalar, PatchField, GeoMesh> > tRes
00091 (
00092 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::New
00093 (
00094 tgsf,
00095 "stabilise(" + gsf.name() + ',' + ds.name() + ')',
00096 ds.dimensions() + gsf.dimensions()
00097 )
00098 );
00099
00100 stabilise(tRes(), gsf, ds);
00101
00102 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::clear(tgsf);
00103
00104 return tRes;
00105 }
00106
00107
00108
00109
00110 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, '+', add)
00111 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, '-', subtract)
00112
00113 BINARY_OPERATOR(scalar, scalar, scalar, *, '*', multiply)
00114 BINARY_OPERATOR(scalar, scalar, scalar, /, '|', divide)
00115
00116 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, '|', divide)
00117
00118
00119
00120 template<template<class> class PatchField, class GeoMesh>
00121 void pow
00122 (
00123 GeometricField<scalar, PatchField, GeoMesh>& Pow,
00124 const GeometricField<scalar, PatchField, GeoMesh>& gsf1,
00125 const GeometricField<scalar, PatchField, GeoMesh>& gsf2
00126 )
00127 {
00128 pow(Pow.internalField(), gsf1.internalField(), gsf2.internalField());
00129 pow(Pow.boundaryField(), gsf1.boundaryField(), gsf2.boundaryField());
00130 }
00131
00132
00133 template<template<class> class PatchField, class GeoMesh>
00134 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
00135 (
00136 const GeometricField<scalar, PatchField, GeoMesh>& gsf1,
00137 const GeometricField<scalar, PatchField, GeoMesh>& gsf2
00138 )
00139 {
00140 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
00141 (
00142 new GeometricField<scalar, PatchField, GeoMesh>
00143 (
00144 IOobject
00145 (
00146 "pow(" + gsf1.name() + ',' + gsf2.name() + ')',
00147 gsf1.instance(),
00148 gsf1.db(),
00149 IOobject::NO_READ,
00150 IOobject::NO_WRITE
00151 ),
00152 gsf1.mesh(),
00153 pow
00154 (
00155 gsf1.dimensions(),
00156 dimensionedScalar("1", gsf2.dimensions(), 1.0)
00157 )
00158 )
00159 );
00160
00161 pow(tPow(), gsf1, gsf2);
00162
00163 return tPow;
00164 }
00165
00166
00167 template<template<class> class PatchField, class GeoMesh>
00168 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
00169 (
00170 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf1,
00171 const GeometricField<scalar, PatchField, GeoMesh>& gsf2
00172 )
00173 {
00174 const GeometricField<scalar, PatchField, GeoMesh>& gsf1 = tgsf1();
00175
00176 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
00177 (
00178 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::New
00179 (
00180 tgsf1,
00181 "pow(" + gsf1.name() + ',' + gsf2.name() + ')',
00182 pow
00183 (
00184 gsf1.dimensions(),
00185 dimensionedScalar("1", gsf2.dimensions(), 1.0)
00186 )
00187 )
00188 );
00189
00190 pow(tPow(), gsf1, gsf2);
00191
00192 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::clear(tgsf1);
00193
00194 return tPow;
00195 }
00196
00197
00198 template<template<class> class PatchField, class GeoMesh>
00199 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
00200 (
00201 const GeometricField<scalar, PatchField, GeoMesh>& gsf1,
00202 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf2
00203 )
00204 {
00205 const GeometricField<scalar, PatchField, GeoMesh>& gsf2 = tgsf2();
00206
00207 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
00208 (
00209 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::New
00210 (
00211 tgsf2,
00212 "pow(" + gsf1.name() + ',' + gsf2.name() + ')',
00213 pow
00214 (
00215 gsf1.dimensions(),
00216 dimensionedScalar("1", gsf2.dimensions(), 1.0)
00217 )
00218 )
00219 );
00220
00221 pow(tPow(), gsf1, gsf2);
00222
00223 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::clear(tgsf2);
00224
00225 return tPow;
00226 }
00227
00228 template<template<class> class PatchField, class GeoMesh>
00229 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
00230 (
00231 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf1,
00232 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf2
00233 )
00234 {
00235 const GeometricField<scalar, PatchField, GeoMesh>& gsf1 = tgsf1();
00236 const GeometricField<scalar, PatchField, GeoMesh>& gsf2 = tgsf2();
00237
00238 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
00239 (
00240 reuseTmpTmpGeometricField
00241 <scalar, scalar, scalar, scalar, PatchField, GeoMesh>::New
00242 (
00243 tgsf1,
00244 tgsf2,
00245 "pow(" + gsf1.name() + ',' + gsf2.name() + ')',
00246 pow
00247 (
00248 gsf1.dimensions(),
00249 dimensionedScalar("1", gsf2.dimensions(), 1.0)
00250 )
00251 )
00252 );
00253
00254 pow(tPow(), gsf1, gsf2);
00255
00256 reuseTmpTmpGeometricField
00257 <scalar, scalar, scalar, scalar, PatchField, GeoMesh>
00258 ::clear(tgsf1, tgsf2);
00259
00260 return tPow;
00261 }
00262
00263
00264 template<template<class> class PatchField, class GeoMesh>
00265 void pow
00266 (
00267 GeometricField<scalar, PatchField, GeoMesh>& tPow,
00268 const GeometricField<scalar, PatchField, GeoMesh>& gsf,
00269 const dimensioned<scalar>& ds
00270 )
00271 {
00272 pow(tPow.internalField(), gsf.internalField(), ds.value());
00273 pow(tPow.boundaryField(), gsf.boundaryField(), ds.value());
00274 }
00275
00276
00277 template<template<class> class PatchField, class GeoMesh>
00278 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
00279 (
00280 const GeometricField<scalar, PatchField, GeoMesh>& gsf,
00281 const dimensionedScalar& ds
00282 )
00283 {
00284 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
00285 (
00286 new GeometricField<scalar, PatchField, GeoMesh>
00287 (
00288 IOobject
00289 (
00290 "pow(" + gsf.name() + ',' + ds.name() + ')',
00291 gsf.instance(),
00292 gsf.db(),
00293 IOobject::NO_READ,
00294 IOobject::NO_WRITE
00295 ),
00296 gsf.mesh(),
00297 pow(gsf.dimensions(), ds)
00298 )
00299 );
00300
00301 pow(tPow(), gsf, ds);
00302
00303 return tPow;
00304 }
00305
00306 template<template<class> class PatchField, class GeoMesh>
00307 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
00308 (
00309 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf,
00310 const dimensionedScalar& ds
00311 )
00312 {
00313 const GeometricField<scalar, PatchField, GeoMesh>& gsf = tgsf();
00314
00315 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
00316 (
00317 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::New
00318 (
00319 tgsf,
00320 "pow(" + gsf.name() + ',' + ds.name() + ')',
00321 pow(gsf.dimensions(), ds)
00322 )
00323 );
00324
00325 pow(tPow(), gsf, ds);
00326
00327 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::clear(tgsf);
00328
00329 return tPow;
00330 }
00331
00332 template<template<class> class PatchField, class GeoMesh>
00333 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
00334 (
00335 const GeometricField<scalar, PatchField, GeoMesh>& gsf,
00336 const scalar& s
00337 )
00338 {
00339 return pow(gsf, dimensionedScalar(s));
00340 }
00341
00342 template<template<class> class PatchField, class GeoMesh>
00343 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
00344 (
00345 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf,
00346 const scalar& s
00347 )
00348 {
00349 return pow(tgsf, dimensionedScalar(s));
00350 }
00351
00352
00353 template<template<class> class PatchField, class GeoMesh>
00354 void pow
00355 (
00356 GeometricField<scalar, PatchField, GeoMesh>& tPow,
00357 const dimensioned<scalar>& ds,
00358 const GeometricField<scalar, PatchField, GeoMesh>& gsf
00359 )
00360 {
00361 pow(tPow.internalField(), ds.value(), gsf.internalField());
00362 pow(tPow.boundaryField(), ds.value(), gsf.boundaryField());
00363 }
00364
00365
00366 template<template<class> class PatchField, class GeoMesh>
00367 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
00368 (
00369 const dimensionedScalar& ds,
00370 const GeometricField<scalar, PatchField, GeoMesh>& gsf
00371 )
00372 {
00373 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
00374 (
00375 new GeometricField<scalar, PatchField, GeoMesh>
00376 (
00377 IOobject
00378 (
00379 "pow(" + ds.name() + ',' + gsf.name() + ')',
00380 gsf.instance(),
00381 gsf.db(),
00382 IOobject::NO_READ,
00383 IOobject::NO_WRITE
00384 ),
00385 gsf.mesh(),
00386 pow(ds, gsf.dimensions())
00387 )
00388 );
00389
00390 pow(tPow(), ds, gsf);
00391
00392 return tPow;
00393 }
00394
00395
00396 template<template<class> class PatchField, class GeoMesh>
00397 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
00398 (
00399 const dimensionedScalar& ds,
00400 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf
00401 )
00402 {
00403 const GeometricField<scalar, PatchField, GeoMesh>& gsf = tgsf();
00404
00405 tmp<GeometricField<scalar, PatchField, GeoMesh> > tPow
00406 (
00407 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::New
00408 (
00409 tgsf,
00410 "pow(" + ds.name() + ',' + gsf.name() + ')',
00411 pow(ds, gsf.dimensions())
00412 )
00413 );
00414
00415 pow(tPow(), ds, gsf);
00416
00417 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::clear(tgsf);
00418
00419 return tPow;
00420 }
00421
00422 template<template<class> class PatchField, class GeoMesh>
00423 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
00424 (
00425 const scalar& s,
00426 const GeometricField<scalar, PatchField, GeoMesh>& gsf
00427 )
00428 {
00429 return pow(dimensionedScalar(s), gsf);
00430 }
00431
00432 template<template<class> class PatchField, class GeoMesh>
00433 tmp<GeometricField<scalar, PatchField, GeoMesh> > pow
00434 (
00435 const scalar& s,
00436 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf
00437 )
00438 {
00439 return pow(dimensionedScalar(s), tgsf);
00440 }
00441
00442
00443
00444
00445 UNARY_FUNCTION(scalar, scalar, pow3, pow3)
00446 UNARY_FUNCTION(scalar, scalar, pow4, pow4)
00447 UNARY_FUNCTION(scalar, scalar, pow5, pow5)
00448 UNARY_FUNCTION(scalar, scalar, pow6, pow6)
00449 UNARY_FUNCTION(scalar, scalar, sqrt, sqrt)
00450 UNARY_FUNCTION(scalar, scalar, sign, sign)
00451 UNARY_FUNCTION(scalar, scalar, pos, pos)
00452 UNARY_FUNCTION(scalar, scalar, neg, neg)
00453
00454 UNARY_FUNCTION(scalar, scalar, exp, trans)
00455 UNARY_FUNCTION(scalar, scalar, log, trans)
00456 UNARY_FUNCTION(scalar, scalar, log10, trans)
00457 UNARY_FUNCTION(scalar, scalar, sin, trans)
00458 UNARY_FUNCTION(scalar, scalar, cos, trans)
00459 UNARY_FUNCTION(scalar, scalar, tan, trans)
00460 UNARY_FUNCTION(scalar, scalar, asin, trans)
00461 UNARY_FUNCTION(scalar, scalar, acos, trans)
00462 UNARY_FUNCTION(scalar, scalar, atan, trans)
00463 UNARY_FUNCTION(scalar, scalar, sinh, trans)
00464 UNARY_FUNCTION(scalar, scalar, cosh, trans)
00465 UNARY_FUNCTION(scalar, scalar, tanh, trans)
00466 UNARY_FUNCTION(scalar, scalar, asinh, trans)
00467 UNARY_FUNCTION(scalar, scalar, acosh, trans)
00468 UNARY_FUNCTION(scalar, scalar, atanh, trans)
00469 UNARY_FUNCTION(scalar, scalar, erf, trans)
00470 UNARY_FUNCTION(scalar, scalar, erfc, trans)
00471 UNARY_FUNCTION(scalar, scalar, lgamma, trans)
00472 UNARY_FUNCTION(scalar, scalar, j0, trans)
00473 UNARY_FUNCTION(scalar, scalar, j1, trans)
00474 UNARY_FUNCTION(scalar, scalar, y0, trans)
00475 UNARY_FUNCTION(scalar, scalar, y1, trans)
00476
00477
00478
00479
00480 #define BesselFunc(func) \
00481 \
00482 template<template<class> class PatchField, class GeoMesh> \
00483 void func \
00484 ( \
00485 GeometricField<scalar, PatchField, GeoMesh>& gsf, \
00486 const int n, \
00487 const GeometricField<scalar, PatchField, GeoMesh>& gsf1 \
00488 ) \
00489 { \
00490 func(gsf.internalField(), n, gsf1.internalField()); \
00491 func(gsf.boundaryField(), n, gsf1.boundaryField()); \
00492 } \
00493 \
00494 template<template<class> class PatchField, class GeoMesh> \
00495 tmp<GeometricField<scalar, PatchField, GeoMesh> > func \
00496 ( \
00497 const int n, \
00498 const GeometricField<scalar, PatchField, GeoMesh>& gsf \
00499 ) \
00500 { \
00501 if (!gsf.dimensions().dimensionless()) \
00502 { \
00503 FatalErrorIn \
00504 ( \
00505 #func"(const int n, " \
00506 "const GeometricField<scalar, PatchField, GeoMesh>& gsf)" \
00507 ) << "gsf not dimensionless" \
00508 << abort(FatalError); \
00509 } \
00510 \
00511 tmp<GeometricField<scalar, PatchField, GeoMesh> > tFunc \
00512 ( \
00513 new GeometricField<scalar, PatchField, GeoMesh> \
00514 ( \
00515 IOobject \
00516 ( \
00517 #func "(" + gsf.name() + ')', \
00518 gsf.instance(), \
00519 gsf.db(), \
00520 IOobject::NO_READ, \
00521 IOobject::NO_WRITE \
00522 ), \
00523 gsf.mesh(), \
00524 dimless \
00525 ) \
00526 ); \
00527 \
00528 func(tFunc(), n, gsf); \
00529 \
00530 return tFunc; \
00531 } \
00532 \
00533 template<template<class> class PatchField, class GeoMesh> \
00534 tmp<GeometricField<scalar, PatchField, GeoMesh> > func \
00535 ( \
00536 const int n, \
00537 const tmp<GeometricField<scalar, PatchField, GeoMesh> >& tgsf \
00538 ) \
00539 { \
00540 const GeometricField<scalar, PatchField, GeoMesh>& gsf = tgsf(); \
00541 \
00542 if (!gsf.dimensions().dimensionless()) \
00543 { \
00544 FatalErrorIn \
00545 ( \
00546 #func"(const int n, " \
00547 "const tmp<GeometricField<scalar, PatchField, GeoMesh> >& gsf)" \
00548 ) << " : gsf not dimensionless" \
00549 << abort(FatalError); \
00550 } \
00551 \
00552 tmp<GeometricField<scalar, PatchField, GeoMesh> > tFunc \
00553 ( \
00554 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh>::New \
00555 ( \
00556 tgsf, \
00557 #func "(" + gsf.name() + ')', \
00558 dimless \
00559 ) \
00560 ); \
00561 \
00562 func(tFunc(), n, gsf); \
00563 \
00564 reuseTmpGeometricField<scalar, scalar, PatchField, GeoMesh> \
00565 ::clear(tgsf); \
00566 \
00567 return tFunc; \
00568 }
00569
00570 BesselFunc(jn)
00571 BesselFunc(yn)
00572
00573 #undef BesselFunc
00574
00575
00576
00577
00578 }
00579
00580
00581
00582 #include <OpenFOAM/undefFieldFunctionsM.H>
00583
00584