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