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