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
00027
00028
00029
00030 #include "PstreamReduceOps.H"
00031
00032
00033
00034 namespace Foam
00035 {
00036
00037
00038
00039 template<template<class> class Field, class Type>
00040 void component
00041 (
00042 FieldField<Field, typename FieldField<Field, Type>::cmptType>& sf,
00043 const FieldField<Field, Type>& f,
00044 const direction d
00045 );
00046
00047 template<template<class> class Field, class Type>
00048 void T(FieldField<Field, Type>& f1, const FieldField<Field, Type>& f2);
00049
00050
00051 template<template<class> class Field, class Type, int r>
00052 void pow
00053 (
00054 FieldField<Field, typename powProduct<Type, r>::type>& f,
00055 const FieldField<Field, Type>& vf
00056 );
00057
00058 template<template<class> class Field, class Type, int r>
00059 tmp<FieldField<Field, typename powProduct<Type, r>::type> >
00060 pow
00061 (
00062 const FieldField<Field, Type>& f, typename powProduct<Type, r>::type
00063 = pTraits<typename powProduct<Type, r>::type>::zero
00064 );
00065
00066 template<template<class> class Field, class Type, int r>
00067 tmp<FieldField<Field, typename powProduct<Type, r>::type> >
00068 pow
00069 (
00070 const tmp<FieldField<Field, Type> >& tf, typename powProduct<Type, r>::type
00071 = pTraits<typename powProduct<Type, r>::type>::zero
00072 );
00073
00074
00075 template<template<class> class Field, class Type>
00076 void sqr
00077 (
00078 FieldField<Field, typename outerProduct<Type, Type>::type>& f,
00079 const FieldField<Field, Type>& vf
00080 );
00081
00082 template<template<class> class Field, class Type>
00083 tmp<FieldField<Field, typename outerProduct<Type, Type>::type> >
00084 sqr(const FieldField<Field, Type>& f);
00085
00086 template<template<class> class Field, class Type>
00087 tmp<FieldField<Field, typename outerProduct<Type, Type>::type> >
00088 sqr(const tmp<FieldField<Field, Type> >& tf);
00089
00090 template<template<class> class Field, class Type>
00091 void magSqr(FieldField<Field, scalar>& sf, const FieldField<Field, Type>& f);
00092
00093 template<template<class> class Field, class Type>
00094 tmp<FieldField<Field, scalar> > magSqr(const FieldField<Field, Type>& f);
00095
00096 template<template<class> class Field, class Type>
00097 tmp<FieldField<Field, scalar> > magSqr(const tmp<FieldField<Field, Type> >& tf);
00098
00099 template<template<class> class Field, class Type>
00100 void mag(FieldField<Field, scalar>& sf, const FieldField<Field, Type>& f);
00101
00102 template<template<class> class Field, class Type>
00103 tmp<FieldField<Field, scalar> > mag(const FieldField<Field, Type>& f);
00104
00105 template<template<class> class Field, class Type>
00106 tmp<FieldField<Field, scalar> > mag(const tmp<FieldField<Field, Type> >& tf);
00107
00108
00109 template<template<class> class Field, class Type>
00110 void cmptAv
00111 (
00112 FieldField<Field, typename FieldField<Field, Type>::cmptType>& cf,
00113 const FieldField<Field, Type>& f
00114 );
00115
00116 template<template<class> class Field, class Type>
00117 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptAv
00118 (
00119 const FieldField<Field, Type>& f
00120 );
00121
00122 template<template<class> class Field, class Type>
00123 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptAv
00124 (
00125 const tmp<FieldField<Field, Type> >& tf
00126 );
00127
00128 template<template<class> class Field, class Type>
00129 void cmptMag
00130 (
00131 FieldField<Field, Type>& cf,
00132 const FieldField<Field, Type>& f
00133 );
00134
00135 template<template<class> class Field, class Type>
00136 tmp<FieldField<Field, Type> > cmptMag
00137 (
00138 const FieldField<Field, Type>& f
00139 );
00140
00141 template<template<class> class Field, class Type>
00142 tmp<FieldField<Field, Type> > cmptMag
00143 (
00144 const tmp<FieldField<Field, Type> >& tf
00145 );
00146
00147 #define BINARY_FUNCTION(func) \
00148 \
00149 template<template<class> class Field, class Type> \
00150 void func \
00151 ( \
00152 FieldField<Field, Type>& f, \
00153 const FieldField<Field, Type>& f1, \
00154 const FieldField<Field, Type>& f2 \
00155 ); \
00156 \
00157 template<template<class> class Field, class Type> \
00158 tmp<FieldField<Field, Type> > func \
00159 ( \
00160 const FieldField<Field, Type>& f1, \
00161 const FieldField<Field, Type>& f2 \
00162 ); \
00163 \
00164 template<template<class> class Field, class Type> \
00165 tmp<FieldField<Field, Type> > func \
00166 ( \
00167 const FieldField<Field, Type>& f1, \
00168 const tmp<FieldField<Field, Type> >& tf2 \
00169 ); \
00170 \
00171 template<template<class> class Field, class Type> \
00172 tmp<FieldField<Field, Type> > func \
00173 ( \
00174 const tmp<FieldField<Field, Type> >& tf1, \
00175 const FieldField<Field, Type>& f2 \
00176 ); \
00177 \
00178 template<template<class> class Field, class Type> \
00179 tmp<FieldField<Field, Type> > func \
00180 ( \
00181 const tmp<FieldField<Field, Type> >& tf1, \
00182 const tmp<FieldField<Field, Type> >& tf2 \
00183 ); \
00184 \
00185 template<template<class> class Field, class Type> \
00186 void func \
00187 ( \
00188 FieldField<Field, Type>& f, \
00189 const FieldField<Field, Type>& f1, \
00190 const Type& s \
00191 ); \
00192 \
00193 template<template<class> class Field, class Type> \
00194 tmp<FieldField<Field, Type> > func \
00195 ( \
00196 const FieldField<Field, Type>& f1, \
00197 const Type& s \
00198 ); \
00199 \
00200 template<template<class> class Field, class Type> \
00201 tmp<FieldField<Field, Type> > func \
00202 ( \
00203 const tmp<FieldField<Field, Type> >& tf1, \
00204 const Type& s \
00205 );
00206
00207 BINARY_FUNCTION(max)
00208 BINARY_FUNCTION(min)
00209 BINARY_FUNCTION(scale)
00210
00211 #undef BINARY_FUNCTION
00212
00213
00214 #define TMP_UNARY_FUNCTION(returnType, func) \
00215 \
00216 template<template<class> class Field, class Type> \
00217 returnType func(const tmp<FieldField<Field, Type> >& tf1);
00218
00219 template<template<class> class Field, class Type>
00220 Type max(const FieldField<Field, Type>& f);
00221
00222 TMP_UNARY_FUNCTION(Type, max)
00223
00224 template<template<class> class Field, class Type>
00225 Type min(const FieldField<Field, Type>& f);
00226
00227 TMP_UNARY_FUNCTION(Type, min)
00228
00229 template<template<class> class Field, class Type>
00230 Type sum(const FieldField<Field, Type>& f);
00231
00232 TMP_UNARY_FUNCTION(Type, sum)
00233
00234 template<template<class> class Field, class Type>
00235 scalar sumMag(const FieldField<Field, Type>& f);
00236
00237 TMP_UNARY_FUNCTION(scalar, sumMag)
00238
00239 template<template<class> class Field, class Type>
00240 Type average(const FieldField<Field, Type>& f);
00241
00242 TMP_UNARY_FUNCTION(Type, average)
00243
00244
00245 #include "PstreamReduceOps.H"
00246
00247 #define G_UNARY_FUNCTION(returnType, gFunc, func, rFunc) \
00248 \
00249 template<template<class> class Field, class Type> \
00250 returnType gFunc(const FieldField<Field, Type>& f); \
00251 TMP_UNARY_FUNCTION(returnType, gFunc)
00252
00253 G_UNARY_FUNCTION(Type, gMax, max, max)
00254 G_UNARY_FUNCTION(Type, gMin, min, min)
00255 G_UNARY_FUNCTION(Type, gSum, sum, sum)
00256 G_UNARY_FUNCTION(scalar, gSumMag, sumMag, sum)
00257
00258 #undef G_UNARY_FUNCTION
00259
00260
00261 template<template<class> class Field, class Type>
00262 Type gAverage(const FieldField<Field, Type>& f);
00263
00264 TMP_UNARY_FUNCTION(Type, gAverage)
00265
00266 #undef TMP_UNARY_FUNCTION
00267
00268
00269
00270
00271 #define UNARY_OPERATOR(op, opFunc) \
00272 \
00273 template<template<class> class Field, class Type> \
00274 void opFunc \
00275 ( \
00276 FieldField<Field, Type>& f, \
00277 const FieldField<Field, Type>& f1 \
00278 ); \
00279 \
00280 template<template<class> class Field, class Type> \
00281 tmp<FieldField<Field, Type> > operator op \
00282 ( \
00283 const FieldField<Field, Type>& f1 \
00284 ); \
00285 \
00286 template<template<class> class Field, class Type> \
00287 tmp<FieldField<Field, Type> > operator op \
00288 ( \
00289 const tmp<FieldField<Field, Type> >& tf1 \
00290 );
00291
00292 UNARY_OPERATOR(-, negate)
00293
00294 #undef UNARY_OPERATOR
00295
00296
00297 #define BINARY_OPERATOR_FF(Type1, Type2, op, opFunc) \
00298 \
00299 template<template<class> class Field, class Type> \
00300 void opFunc \
00301 ( \
00302 FieldField<Field, Type>& f, \
00303 const FieldField<Field, Type1>& f1, \
00304 const FieldField<Field, Type2>& f2 \
00305 ); \
00306 \
00307 template<template<class> class Field, class Type> \
00308 tmp<FieldField<Field, Type> > operator op \
00309 ( \
00310 const FieldField<Field, Type1>& f1, \
00311 const FieldField<Field, Type2>& f2 \
00312 );
00313
00314 #define BINARY_OPERATOR_FTR(Type1, Type2, op, opFunc) \
00315 template<template<class> class Field, class Type> \
00316 tmp<FieldField<Field, Type> > operator op \
00317 ( \
00318 const FieldField<Field, Type1>& f1, \
00319 const tmp<FieldField<Field, Type2> >& tf2 \
00320 );
00321
00322 #define BINARY_OPERATOR_FT(Type1, Type2, op, opFunc) \
00323 template<template<class> class Field, class Type> \
00324 tmp<FieldField<Field, Type> > operator op \
00325 ( \
00326 const FieldField<Field, Type1>& f1, \
00327 const tmp<FieldField<Field, Type2> >& tf2 \
00328 );
00329
00330 #define BINARY_OPERATOR_TRF(Type1, Type2, op, opFunc) \
00331 template<template<class> class Field, class Type> \
00332 tmp<FieldField<Field, Type> > operator op \
00333 ( \
00334 const tmp<FieldField<Field, Type1> >& tf1, \
00335 const FieldField<Field, Type2>& f2 \
00336 );
00337
00338 #define BINARY_OPERATOR_TF(Type1, Type2, op, opFunc) \
00339 template<template<class> class Field, class Type> \
00340 tmp<FieldField<Field, Type> > operator op \
00341 ( \
00342 const tmp<FieldField<Field, Type1> >& tf1, \
00343 const FieldField<Field, Type2>& f2 \
00344 );
00345
00346 #define BINARY_OPERATOR_TRT(Type1, Type2, op, opFunc) \
00347 template<template<class> class Field, class Type> \
00348 tmp<FieldField<Field, Type> > operator op \
00349 ( \
00350 const tmp<FieldField<Field, Type1> >& tf1, \
00351 const tmp<FieldField<Field, Type2> >& tf2 \
00352 );
00353
00354 #define BINARY_OPERATOR_TTR(Type1, Type2, op, opFunc) \
00355 template<template<class> class Field, class Type> \
00356 tmp<FieldField<Field, Type> > operator op \
00357 ( \
00358 const tmp<FieldField<Field, Type1> >& tf1, \
00359 const tmp<FieldField<Field, Type2> >& tf2 \
00360 );
00361
00362 #define BINARY_OPERATOR_R(Type1, Type2, op, opFunc) \
00363 BINARY_OPERATOR_FF(Type1, Type2, op, opFunc) \
00364 BINARY_OPERATOR_FTR(Type1, Type2, op, opFunc) \
00365 BINARY_OPERATOR_TRF(Type1, Type2, op, opFunc) \
00366 BINARY_OPERATOR_TRT(Type1, Type2, op, opFunc)
00367
00368 BINARY_OPERATOR_R(Type, Type, +, add)
00369 BINARY_OPERATOR_R(Type, Type, -, subtract)
00370
00371 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
00372 BINARY_OPERATOR_FF(scalar, Type, *, multiply)
00373 BINARY_OPERATOR_FTR(scalar, Type, *, multiply)
00374 BINARY_OPERATOR_TF(scalar, Type, *, multiply)
00375 BINARY_OPERATOR_TTR(scalar, Type, *, multiply)
00376 #endif
00377
00378 BINARY_OPERATOR_FF(Type, scalar, /, divide)
00379 BINARY_OPERATOR_FT(Type, scalar, /, divide)
00380 BINARY_OPERATOR_TRF(Type, scalar, /, divide)
00381 BINARY_OPERATOR_TRT(Type, scalar, /, divide)
00382
00383 #undef BINARY_OPERATOR_R
00384 #undef BINARY_OPERATOR_FF
00385 #undef BINARY_OPERATOR_FTR
00386 #undef BINARY_OPERATOR_TF
00387 #undef BINARY_OPERATOR_TTR
00388 #undef BINARY_OPERATOR_FT
00389 #undef BINARY_OPERATOR_TRF
00390 #undef BINARY_OPERATOR_TRT
00391
00392
00393 #define BINARY_TYPE_OPERATOR_TF(TYPE, op, opFunc) \
00394 \
00395 template<template<class> class Field, class Type> \
00396 void opFunc \
00397 ( \
00398 FieldField<Field, Type>& f, \
00399 const TYPE& s, \
00400 const FieldField<Field, Type>& f1 \
00401 ); \
00402 \
00403 template<template<class> class Field, class Type> \
00404 tmp<FieldField<Field, Type> > operator op \
00405 ( \
00406 const TYPE& s, \
00407 const FieldField<Field, Type>& f1 \
00408 ); \
00409 \
00410 template<template<class> class Field, class Type> \
00411 tmp<FieldField<Field, Type> > operator op \
00412 ( \
00413 const TYPE& s, \
00414 const tmp<FieldField<Field, Type> >& tf1 \
00415 );
00416
00417 #define BINARY_TYPE_OPERATOR_FT(TYPE, op, opFunc) \
00418 \
00419 template<template<class> class Field, class Type> \
00420 void opFunc \
00421 ( \
00422 FieldField<Field, Type>& f, \
00423 const FieldField<Field, Type>& f1, \
00424 const TYPE& s \
00425 ); \
00426 \
00427 template<template<class> class Field, class Type> \
00428 tmp<FieldField<Field, Type> > operator op \
00429 ( \
00430 const FieldField<Field, Type>& f1, \
00431 const TYPE& s \
00432 ); \
00433 \
00434 template<template<class> class Field, class Type> \
00435 tmp<FieldField<Field, Type> > operator op \
00436 ( \
00437 const tmp<FieldField<Field, Type> >& tf1, \
00438 const TYPE& s \
00439 );
00440
00441 #define BINARY_TYPE_OPERATOR(TYPE, op, opFunc) \
00442 BINARY_TYPE_OPERATOR_TF(TYPE, op, opFunc) \
00443 BINARY_TYPE_OPERATOR_FT(TYPE, op, opFunc)
00444
00445 BINARY_TYPE_OPERATOR(Type, +, add)
00446 BINARY_TYPE_OPERATOR(Type, -, subtract)
00447
00448 BINARY_TYPE_OPERATOR(scalar, *, multiply)
00449 BINARY_TYPE_OPERATOR_FT(scalar, /, divide)
00450
00451 #undef BINARY_TYPE_OPERATOR
00452 #undef BINARY_TYPE_OPERATOR_TF
00453 #undef BINARY_TYPE_OPERATOR_FT
00454
00455
00456 #define PRODUCT_OPERATOR(product, op, opFunc) \
00457 \
00458 template<template<class> class Field, class Type1, class Type2> \
00459 void opFunc \
00460 ( \
00461 FieldField<Field, typename product<Type1, Type2>::type>& f, \
00462 const FieldField<Field, Type1>& f1, \
00463 const FieldField<Field, Type2>& f2 \
00464 ); \
00465 \
00466 template<template<class> class Field, class Type1, class Type2> \
00467 tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
00468 operator op \
00469 ( \
00470 const FieldField<Field, Type1>& f1, \
00471 const FieldField<Field, Type2>& f2 \
00472 ); \
00473 \
00474 template<template<class> class Field, class Type1, class Type2> \
00475 tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
00476 operator op \
00477 ( \
00478 const FieldField<Field, Type1>& f1, \
00479 const tmp<FieldField<Field, Type2> >& tf2 \
00480 ); \
00481 \
00482 template<template<class> class Field, class Type1, class Type2> \
00483 tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
00484 operator op \
00485 ( \
00486 const tmp<FieldField<Field, Type1> >& tf1, \
00487 const FieldField<Field, Type2>& f2 \
00488 ); \
00489 \
00490 template<template<class> class Field, class Type1, class Type2> \
00491 tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
00492 operator op \
00493 ( \
00494 const tmp<FieldField<Field, Type1> >& tf1, \
00495 const tmp<FieldField<Field, Type2> >& tf2 \
00496 ); \
00497 \
00498 template \
00499 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt> \
00500 void opFunc \
00501 ( \
00502 FieldField<Field, typename product<Type, Form>::type>& f, \
00503 const FieldField<Field, Type>& f1, \
00504 const VectorSpace<Form,Cmpt,nCmpt>& vs \
00505 ); \
00506 \
00507 template \
00508 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt> \
00509 tmp<FieldField<Field, typename product<Type, Form>::type> > \
00510 operator op \
00511 ( \
00512 const FieldField<Field, Type>& f1, \
00513 const VectorSpace<Form,Cmpt,nCmpt>& vs \
00514 ); \
00515 \
00516 template \
00517 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt> \
00518 tmp<FieldField<Field, typename product<Type, Form>::type> > \
00519 operator op \
00520 ( \
00521 const tmp<FieldField<Field, Type> >& tf1, \
00522 const VectorSpace<Form,Cmpt,nCmpt>& vs \
00523 ); \
00524 \
00525 template \
00526 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type> \
00527 void opFunc \
00528 ( \
00529 FieldField<Field, typename product<Form, Type>::type>& f, \
00530 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
00531 const FieldField<Field, Type>& f1 \
00532 ); \
00533 \
00534 template \
00535 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type> \
00536 tmp<FieldField<Field, typename product<Form, Type>::type> > \
00537 operator op \
00538 ( \
00539 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
00540 const FieldField<Field, Type>& f1 \
00541 ); \
00542 \
00543 template \
00544 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type> \
00545 tmp<FieldField<Field, typename product<Form, Type>::type> > \
00546 operator op \
00547 ( \
00548 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
00549 const tmp<FieldField<Field, Type> >& tf1 \
00550 );
00551
00552 PRODUCT_OPERATOR(outerProduct, *, outer)
00553 PRODUCT_OPERATOR(crossProduct, ^, cross)
00554 PRODUCT_OPERATOR(innerProduct, &, dot)
00555 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
00556
00557 #undef PRODUCT_OPERATOR
00558
00559
00560
00561
00562 }
00563
00564