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