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/DimensionedScalarField.H>
00027
00028 #define TEMPLATE template<class GeoMesh>
00029 #include <OpenFOAM/DimensionedFieldFunctionsM.C>
00030
00031
00032
00033 namespace Foam
00034 {
00035
00036
00037
00038 template<class GeoMesh>
00039 tmp<DimensionedField<scalar, GeoMesh> > stabilise
00040 (
00041 const DimensionedField<scalar, GeoMesh>& dsf,
00042 const dimensioned<scalar>& ds
00043 )
00044 {
00045 tmp<DimensionedField<scalar, GeoMesh> > tRes
00046 (
00047 new DimensionedField<scalar, GeoMesh>
00048 (
00049 IOobject
00050 (
00051 "stabilise(" + dsf.name() + ',' + ds.name() + ')',
00052 dsf.instance(),
00053 dsf.db()
00054 ),
00055 dsf.mesh(),
00056 dsf.dimensions() + ds.dimensions()
00057 )
00058 );
00059
00060 stabilise(tRes().field(), dsf.field(), ds.value());
00061
00062 return tRes;
00063 }
00064
00065
00066 template<class GeoMesh>
00067 tmp<DimensionedField<scalar, GeoMesh> > stabilise
00068 (
00069 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf,
00070 const dimensioned<scalar>& ds
00071 )
00072 {
00073 const DimensionedField<scalar, GeoMesh>& dsf = tdsf();
00074
00075 tmp<DimensionedField<scalar, GeoMesh> > tRes =
00076 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
00077 (
00078 tdsf,
00079 "stabilise(" + dsf.name() + ',' + ds.name() + ')',
00080 dsf.dimensions() + ds.dimensions()
00081 );
00082
00083 stabilise(tRes().field(), dsf.field(), ds.value());
00084
00085 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf);
00086
00087 return tRes;
00088 }
00089
00090
00091
00092
00093 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, '+', add)
00094 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, '-', subtract)
00095
00096 BINARY_OPERATOR(scalar, scalar, scalar, *, '*', multiply)
00097 BINARY_OPERATOR(scalar, scalar, scalar, /, '|', divide)
00098
00099 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, '|', divide)
00100
00101
00102
00103 template<class GeoMesh>
00104 tmp<DimensionedField<scalar, GeoMesh> > pow
00105 (
00106 const DimensionedField<scalar, GeoMesh>& dsf1,
00107 const DimensionedField<scalar, GeoMesh>& dsf2
00108 )
00109 {
00110 tmp<DimensionedField<scalar, GeoMesh> > tPow
00111 (
00112 new DimensionedField<scalar, GeoMesh>
00113 (
00114 IOobject
00115 (
00116 "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
00117 dsf1.instance(),
00118 dsf1.db()
00119 ),
00120 dsf1.mesh(),
00121 pow
00122 (
00123 dsf1.dimensions(),
00124 dimensionedScalar("1", 1.0, dsf2.dimensions())
00125 )
00126 )
00127 );
00128
00129 pow(tPow().field(), dsf1.field(), dsf2.field());
00130
00131 return tPow;
00132 }
00133
00134
00135 template<class GeoMesh>
00136 tmp<DimensionedField<scalar, GeoMesh> > pow
00137 (
00138 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf1,
00139 const DimensionedField<scalar, GeoMesh>& dsf2
00140 )
00141 {
00142 const DimensionedField<scalar, GeoMesh>& dsf1 = tdsf1();
00143
00144 tmp<DimensionedField<scalar, GeoMesh> > tPow =
00145 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
00146 (
00147 tdsf1,
00148 "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
00149 pow
00150 (
00151 dsf1.dimensions(),
00152 dimensionedScalar("1", 1.0, dsf2.dimensions())
00153 )
00154 );
00155
00156 pow(tPow().field(), dsf1.field(), dsf2.field());
00157
00158 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf1);
00159
00160 return tPow;
00161 }
00162
00163
00164 template<class GeoMesh>
00165 tmp<DimensionedField<scalar, GeoMesh> > pow
00166 (
00167 const DimensionedField<scalar, GeoMesh>& dsf1,
00168 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf2
00169 )
00170 {
00171 const DimensionedField<scalar, GeoMesh>& dsf2 = tdsf2();
00172
00173 tmp<DimensionedField<scalar, GeoMesh> > tPow =
00174 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
00175 (
00176 tdsf2,
00177 "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
00178 pow
00179 (
00180 dsf1.dimensions(),
00181 dimensionedScalar("1", 1.0, dsf2.dimensions())
00182 )
00183 );
00184
00185 pow(tPow().field(), dsf1.field(), dsf2.field());
00186
00187 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf2);
00188
00189 return tPow;
00190 }
00191
00192 template<class GeoMesh>
00193 tmp<DimensionedField<scalar, GeoMesh> > pow
00194 (
00195 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf1,
00196 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf2
00197 )
00198 {
00199 const DimensionedField<scalar, GeoMesh>& dsf1 = tdsf1();
00200 const DimensionedField<scalar, GeoMesh>& dsf2 = tdsf2();
00201
00202 tmp<DimensionedField<scalar, GeoMesh> > tPow =
00203 reuseTmpTmpDimensionedField<scalar, scalar, scalar, scalar, GeoMesh>::
00204 New
00205 (
00206 tdsf1,
00207 tdsf2,
00208 "pow(" + dsf1.name() + ',' + dsf2.name() + ')',
00209 pow
00210 (
00211 dsf1.dimensions(),
00212 dimensionedScalar("1", 1.0, dsf2.dimensions())
00213 )
00214 );
00215
00216 pow(tPow().field(), dsf1.field(), dsf2.field());
00217
00218 reuseTmpTmpDimensionedField<scalar, scalar, scalar, scalar, GeoMesh>::clear
00219 (
00220 tdsf1,
00221 tdsf2
00222 );
00223
00224 return tPow;
00225 }
00226
00227
00228 template<class GeoMesh>
00229 tmp<DimensionedField<scalar, GeoMesh> > pow
00230 (
00231 const DimensionedField<scalar, GeoMesh>& dsf,
00232 const dimensionedScalar& ds
00233 )
00234 {
00235 tmp<DimensionedField<scalar, GeoMesh> > tPow
00236 (
00237 new DimensionedField<scalar, GeoMesh>
00238 (
00239 IOobject
00240 (
00241 "pow(" + dsf.name() + ',' + ds.name() + ')',
00242 dsf.instance(),
00243 dsf.db()
00244 ),
00245 dsf.mesh(),
00246 pow(dsf.dimensions(), ds)
00247 )
00248 );
00249
00250 pow(tPow().field(), dsf.field(), ds.value());
00251
00252 return tPow;
00253 }
00254
00255 template<class GeoMesh>
00256 tmp<DimensionedField<scalar, GeoMesh> > pow
00257 (
00258 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf,
00259 const dimensionedScalar& ds
00260 )
00261 {
00262 const DimensionedField<scalar, GeoMesh>& dsf = tdsf();
00263
00264 tmp<DimensionedField<scalar, GeoMesh> > tPow =
00265 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
00266 (
00267 tdsf,
00268 "pow(" + dsf.name() + ',' + ds.name() + ')',
00269 pow(dsf.dimensions(), ds)
00270 );
00271
00272 pow(tPow().field(), dsf.field(), ds.value());
00273
00274 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf);
00275
00276 return tPow;
00277 }
00278
00279 template<class GeoMesh>
00280 tmp<DimensionedField<scalar, GeoMesh> > pow
00281 (
00282 const DimensionedField<scalar, GeoMesh>& dsf,
00283 const scalar& s
00284 )
00285 {
00286 return pow(dsf, dimensionedScalar(s));
00287 }
00288
00289 template<class GeoMesh>
00290 tmp<DimensionedField<scalar, GeoMesh> > pow
00291 (
00292 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf,
00293 const scalar& s
00294 )
00295 {
00296 return pow(tdsf, dimensionedScalar(s));
00297 }
00298
00299
00300 template<class GeoMesh>
00301 tmp<DimensionedField<scalar, GeoMesh> > pow
00302 (
00303 const dimensionedScalar& ds,
00304 const DimensionedField<scalar, GeoMesh>& dsf
00305 )
00306 {
00307 tmp<DimensionedField<scalar, GeoMesh> > tPow
00308 (
00309 new DimensionedField<scalar, GeoMesh>
00310 (
00311 IOobject
00312 (
00313 "pow(" + ds.name() + ',' + dsf.name() + ')',
00314 dsf.instance(),
00315 dsf.db()
00316 ),
00317 dsf.mesh(),
00318 pow(ds, dsf.dimensions())
00319 )
00320 );
00321
00322 pow(tPow().field(), ds.value(), dsf.field());
00323
00324 return tPow;
00325 }
00326
00327
00328 template<class GeoMesh>
00329 tmp<DimensionedField<scalar, GeoMesh> > pow
00330 (
00331 const dimensionedScalar& ds,
00332 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf
00333 )
00334 {
00335 const DimensionedField<scalar, GeoMesh>& dsf = tdsf();
00336
00337 tmp<DimensionedField<scalar, GeoMesh> > tPow =
00338 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New
00339 (
00340 tdsf,
00341 "pow(" + ds.name() + ',' + dsf.name() + ')',
00342 pow(ds, dsf.dimensions())
00343 );
00344
00345 pow(tPow().field(), ds.value(), dsf.field());
00346
00347 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf);
00348
00349 return tPow;
00350 }
00351
00352 template<class GeoMesh>
00353 tmp<DimensionedField<scalar, GeoMesh> > pow
00354 (
00355 const scalar& s,
00356 const DimensionedField<scalar, GeoMesh>& dsf
00357 )
00358 {
00359 return pow(dimensionedScalar(s), dsf);
00360 }
00361
00362 template<class GeoMesh>
00363 tmp<DimensionedField<scalar, GeoMesh> > pow
00364 (
00365 const scalar& s,
00366 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf
00367 )
00368 {
00369 return pow(dimensionedScalar(s), tdsf);
00370 }
00371
00372
00373
00374 UNARY_FUNCTION(scalar, scalar, pow3, pow3)
00375 UNARY_FUNCTION(scalar, scalar, pow4, pow4)
00376 UNARY_FUNCTION(scalar, scalar, pow5, pow5)
00377 UNARY_FUNCTION(scalar, scalar, pow6, pow6)
00378 UNARY_FUNCTION(scalar, scalar, sqrt, sqrt)
00379 UNARY_FUNCTION(scalar, scalar, sign, sign)
00380 UNARY_FUNCTION(scalar, scalar, pos, pos)
00381 UNARY_FUNCTION(scalar, scalar, neg, neg)
00382
00383 UNARY_FUNCTION(scalar, scalar, exp, trans)
00384 UNARY_FUNCTION(scalar, scalar, log, trans)
00385 UNARY_FUNCTION(scalar, scalar, log10, trans)
00386 UNARY_FUNCTION(scalar, scalar, sin, trans)
00387 UNARY_FUNCTION(scalar, scalar, cos, trans)
00388 UNARY_FUNCTION(scalar, scalar, tan, trans)
00389 UNARY_FUNCTION(scalar, scalar, asin, trans)
00390 UNARY_FUNCTION(scalar, scalar, acos, trans)
00391 UNARY_FUNCTION(scalar, scalar, atan, trans)
00392 UNARY_FUNCTION(scalar, scalar, sinh, trans)
00393 UNARY_FUNCTION(scalar, scalar, cosh, trans)
00394 UNARY_FUNCTION(scalar, scalar, tanh, trans)
00395 UNARY_FUNCTION(scalar, scalar, asinh, trans)
00396 UNARY_FUNCTION(scalar, scalar, acosh, trans)
00397 UNARY_FUNCTION(scalar, scalar, atanh, trans)
00398 UNARY_FUNCTION(scalar, scalar, erf, trans)
00399 UNARY_FUNCTION(scalar, scalar, erfc, trans)
00400 UNARY_FUNCTION(scalar, scalar, lgamma, trans)
00401 UNARY_FUNCTION(scalar, scalar, j0, trans)
00402 UNARY_FUNCTION(scalar, scalar, j1, trans)
00403 UNARY_FUNCTION(scalar, scalar, y0, trans)
00404 UNARY_FUNCTION(scalar, scalar, y1, trans)
00405
00406
00407
00408
00409 #define BesselFunc(func) \
00410 \
00411 template<class GeoMesh> \
00412 tmp<DimensionedField<scalar, GeoMesh> > func \
00413 ( \
00414 const int n, \
00415 const DimensionedField<scalar, GeoMesh>& dsf \
00416 ) \
00417 { \
00418 if (!dsf.dimensions().dimensionless()) \
00419 { \
00420 FatalErrorIn \
00421 ( \
00422 #func"(const int n, " \
00423 "const DimensionedField<scalar, GeoMesh>& dsf)" \
00424 ) << "dsf not dimensionless" \
00425 << abort(FatalError); \
00426 } \
00427 \
00428 tmp<DimensionedField<scalar, GeoMesh> > tFunc \
00429 ( \
00430 new DimensionedField<scalar, GeoMesh> \
00431 ( \
00432 IOobject \
00433 ( \
00434 #func "(" + name(n) + ',' + dsf.name() + ')', \
00435 dsf.instance(), \
00436 dsf.db() \
00437 ), \
00438 dsf.mesh(), \
00439 dimless \
00440 ) \
00441 ); \
00442 \
00443 func(tFunc().field(), n, dsf.field()); \
00444 \
00445 return tFunc; \
00446 } \
00447 \
00448 template<class GeoMesh> \
00449 tmp<DimensionedField<scalar, GeoMesh> > func \
00450 ( \
00451 const int n, \
00452 const tmp<DimensionedField<scalar, GeoMesh> >& tdsf \
00453 ) \
00454 { \
00455 const DimensionedField<scalar, GeoMesh>& dsf = tdsf(); \
00456 \
00457 if (!dsf.dimensions().dimensionless()) \
00458 { \
00459 FatalErrorIn \
00460 ( \
00461 #func"(const int n, " \
00462 "const tmp<DimensionedField<scalar, GeoMesh> >& dsf)" \
00463 ) << " : dsf not dimensionless" \
00464 << abort(FatalError); \
00465 } \
00466 \
00467 tmp<DimensionedField<scalar, GeoMesh> > tFunc \
00468 ( \
00469 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New \
00470 ( \
00471 tdsf, \
00472 #func "(" + name(n) + ',' + dsf.name() + ')', \
00473 dimless \
00474 ) \
00475 ); \
00476 \
00477 func(tFunc().field(), n, dsf.field()); \
00478 \
00479 reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf); \
00480 \
00481 return tFunc; \
00482 }
00483
00484 BesselFunc(jn)
00485 BesselFunc(yn)
00486
00487 #undef BesselFunc
00488
00489
00490
00491
00492 }
00493
00494
00495
00496 #include <OpenFOAM/undefFieldFunctionsM.H>
00497
00498