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
00031 #ifndef FieldM_H
00032 #define FieldM_H
00033
00034 #include <OpenFOAM/error.H>
00035 #include <OpenFOAM/ListLoopM.H>
00036
00037
00038
00039 namespace Foam
00040 {
00041
00042
00043
00044 #ifdef FULLDEBUG
00045
00046 template<class Type1, class Type2>
00047 void checkFields
00048 (
00049 const UList<Type1>& f1,
00050 const UList<Type2>& f2,
00051 const char* op
00052 )
00053 {
00054 if (f1.size() != f2.size())
00055 {
00056 FatalErrorIn
00057 (
00058 "checkFields(const UList<Type1>&, "
00059 "const UList<Type2>&, const char*)"
00060 ) << " incompatible fields"
00061 << " Field<"<<pTraits<Type1>::typeName<<"> f1("<<f1.size()<<')'
00062 << " and Field<"<<pTraits<Type2>::typeName<<"> f2("<<f2.size()<<')'
00063 << endl << " for operation " << op
00064 << abort(FatalError);
00065 }
00066 }
00067
00068 template<class Type1, class Type2, class Type3>
00069 void checkFields
00070 (
00071 const UList<Type1>& f1,
00072 const UList<Type2>& f2,
00073 const UList<Type3>& f3,
00074 const char* op
00075 )
00076 {
00077 if (f1.size() != f2.size() || f1.size() != f3.size())
00078 {
00079 FatalErrorIn
00080 (
00081 "checkFields(const UList<Type1>&, "
00082 "const UList<Type2>&, const UList<Type3>&, "
00083 "const char*)"
00084 ) << " incompatible fields"
00085 << " Field<"<<pTraits<Type1>::typeName<<"> f1("<<f1.size()<<')'
00086 << ", Field<"<<pTraits<Type2>::typeName<<"> f2("<<f2.size()<<')'
00087 << " and Field<"<<pTraits<Type3>::typeName<<"> f3("<<f3.size()<<')'
00088 << endl << " for operation " << op
00089 << abort(FatalError);
00090 }
00091 }
00092
00093 #else
00094
00095 template<class Type1, class Type2>
00096 void checkFields
00097 (
00098 const UList<Type1>&,
00099 const UList<Type2>&,
00100 const char*
00101 )
00102 {}
00103
00104 template<class Type1, class Type2, class Type3>
00105 void checkFields
00106 (
00107 const UList<Type1>&,
00108 const UList<Type2>&,
00109 const UList<Type3>&,
00110 const char*
00111 )
00112 {}
00113
00114 #endif
00115
00116
00117
00118
00119
00120
00121 #define TFOR_ALL_F_OP_FUNC_F(typeF1, f1, OP, FUNC, typeF2, f2) \
00122 \
00123 \
00124 checkFields(f1, f2, "f1 " #OP " " #FUNC "(f2)"); \
00125 \
00126 \
00127 List_ACCESS(typeF1, f1, f1P); \
00128 List_CONST_ACCESS(typeF2, f2, f2P); \
00129 \
00130 \
00131 List_FOR_ALL(f1, i) \
00132 List_ELEM(f1, f1P, i) OP FUNC(List_ELEM(f2, f2P, i)); \
00133 List_END_FOR_ALL \
00134
00135
00136 #define TFOR_ALL_F_OP_F_FUNC(typeF1, f1, OP, typeF2, f2, FUNC) \
00137 \
00138 \
00139 checkFields(f1, f2, "f1 " #OP " f2" #FUNC); \
00140 \
00141 \
00142 List_ACCESS(typeF1, f1, f1P); \
00143 List_CONST_ACCESS(typeF2, f2, f2P); \
00144 \
00145 \
00146 List_FOR_ALL(f1, i) \
00147 List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i).FUNC(); \
00148 List_END_FOR_ALL \
00149
00150
00151
00152
00153 #define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3)\
00154 \
00155 \
00156 checkFields(f1, f2, f3, "f1 " #OP " " #FUNC "(f2, f3)"); \
00157 \
00158 \
00159 List_ACCESS(typeF1, f1, f1P); \
00160 List_CONST_ACCESS(typeF2, f2, f2P); \
00161 List_CONST_ACCESS(typeF3, f3, f3P); \
00162 \
00163 \
00164 List_FOR_ALL(f1, i) \
00165 List_ELEM(f1, f1P, i) \
00166 OP FUNC(List_ELEM(f2, f2P, i), List_ELEM(f3, f3P, i)); \
00167 List_END_FOR_ALL \
00168
00169
00170
00171
00172 #define TFOR_ALL_S_OP_FUNC_F_F(typeS, s, OP, FUNC, typeF1, f1, typeF2, f2) \
00173 \
00174 \
00175 checkFields(f1, f2, "s " #OP " " #FUNC "(f1, f2)"); \
00176 \
00177 \
00178 List_CONST_ACCESS(typeF1, f1, f1P); \
00179 List_CONST_ACCESS(typeF2, f2, f2P); \
00180 \
00181 \
00182 List_FOR_ALL(f1, i) \
00183 (s) OP FUNC(List_ELEM(f1, f1P, i), List_ELEM(f2, f2P, i)); \
00184 List_END_FOR_ALL \
00185
00186
00187
00188
00189 #define TFOR_ALL_F_OP_FUNC_F_S(typeF1, f1, OP, FUNC, typeF2, f2, typeS, s) \
00190 \
00191 \
00192 checkFields(f1, f2, "f1 " #OP " " #FUNC "(f2, s)"); \
00193 \
00194 \
00195 List_ACCESS(typeF1, f1, f1P); \
00196 List_CONST_ACCESS(typeF2, f2, f2P); \
00197 \
00198 \
00199 List_FOR_ALL(f1, i) \
00200 List_ELEM(f1, f1P, i) OP FUNC(List_ELEM(f2, f2P, i), (s)); \
00201 List_END_FOR_ALL
00202
00203
00204
00205
00206 #define TFOR_ALL_S_OP_FUNC_F_S(typeS1, s1, OP, FUNC, typeF, f, typeS2, s2) \
00207 \
00208 \
00209 List_CONST_ACCESS(typeF, f, fP); \
00210 \
00211 \
00212 List_FOR_ALL(f, i) \
00213 (s1) OP FUNC(List_ELEM(f, fP, i), (s2)); \
00214 List_END_FOR_ALL \
00215
00216
00217
00218
00219 #define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2) \
00220 \
00221 \
00222 checkFields(f1, f2, "f1 " #OP " " #FUNC "(s, f2)"); \
00223 \
00224 \
00225 List_ACCESS(typeF1, f1, f1P); \
00226 List_CONST_ACCESS(typeF2, f2, f2P); \
00227 \
00228 \
00229 List_FOR_ALL(f1, i) \
00230 List_ELEM(f1, f1P, i) OP FUNC((s), List_ELEM(f2, f2P, i)); \
00231 List_END_FOR_ALL \
00232
00233
00234
00235
00236 #define TFOR_ALL_F_OP_FUNC_S_S(typeF1, f1, OP, FUNC, typeS1, s1, typeS2, s2)\
00237 \
00238 \
00239 List_ACCESS(typeF1, f1, f1P); \
00240 \
00241 \
00242 List_FOR_ALL(f1, i) \
00243 List_ELEM(f1, f1P, i) OP FUNC((s1), (s2)); \
00244 List_END_FOR_ALL \
00245
00246
00247
00248
00249 #define TFOR_ALL_F_OP_F_FUNC_S(typeF1, f1, OP, typeF2, f2, FUNC, typeS, s) \
00250 \
00251 \
00252 checkFields(f1, f2, "f1 " #OP " f2 " #FUNC "(s)"); \
00253 \
00254 \
00255 List_ACCESS(typeF1, f1, f1P); \
00256 List_CONST_ACCESS(typeF2, f2, f2P); \
00257 \
00258 \
00259 List_FOR_ALL(f1, i) \
00260 List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i) FUNC((s)); \
00261 List_END_FOR_ALL \
00262
00263
00264
00265
00266
00267
00268 #define TFOR_ALL_F_OP_F_OP_F(typeF1, f1, OP1, typeF2, f2, OP2, typeF3, f3) \
00269 \
00270 \
00271 checkFields(f1, f2, f3, "f1 " #OP1 " f2 " #OP2 " f3"); \
00272 \
00273 \
00274 List_ACCESS(typeF1, f1, f1P); \
00275 List_CONST_ACCESS(typeF2, f2, f2P); \
00276 List_CONST_ACCESS(typeF3, f3, f3P); \
00277 \
00278 \
00279 List_FOR_ALL(f1, i) \
00280 List_ELEM(f1, f1P, i) OP1 List_ELEM(f2, f2P, i) \
00281 OP2 List_ELEM(f3, f3P, i); \
00282 List_END_FOR_ALL \
00283
00284
00285
00286
00287 #define TFOR_ALL_F_OP_S_OP_F(typeF1, f1, OP1, typeS, s, OP2, typeF2, f2) \
00288 \
00289 \
00290 checkFields(f1, f2, "f1 " #OP1 " s " #OP2 " f2"); \
00291 \
00292 \
00293 List_ACCESS(typeF1, f1, f1P); \
00294 List_CONST_ACCESS(typeF2, f2, f2P); \
00295 \
00296 \
00297 List_FOR_ALL(f1, i) \
00298 List_ELEM(f1, f1P, i) OP1 (s) OP2 List_ELEM(f2, f2P, i); \
00299 List_END_FOR_ALL \
00300
00301
00302
00303
00304 #define TFOR_ALL_F_OP_F_OP_S(typeF1, f1, OP1, typeF2, f2, OP2, typeS, s) \
00305 \
00306 \
00307 checkFields(f1, f2, "f1 " #OP1 " f2 " #OP2 " s"); \
00308 \
00309 \
00310 List_ACCESS(typeF1, f1, f1P); \
00311 List_CONST_ACCESS(typeF2, f2, f2P); \
00312 \
00313 \
00314 List_FOR_ALL(f1, i) \
00315 List_ELEM(f1, f1P, i) OP1 List_ELEM(f2, f2P, i) OP2 (s); \
00316 List_END_FOR_ALL \
00317
00318
00319
00320
00321 #define TFOR_ALL_F_OP_F(typeF1, f1, OP, typeF2, f2) \
00322 \
00323 \
00324 checkFields(f1, f2, "f1 " #OP " f2"); \
00325 \
00326 \
00327 \
00328 List_ACCESS(typeF1, f1, f1P); \
00329 List_CONST_ACCESS(typeF2, f2, f2P); \
00330 \
00331 \
00332 List_FOR_ALL(f1, i) \
00333 List_ELEM(f1, f1P, i) OP List_ELEM(f2, f2P, i); \
00334 List_END_FOR_ALL \
00335
00336
00337
00338 #define TFOR_ALL_F_OP_OP_F(typeF1, f1, OP1, OP2, typeF2, f2) \
00339 \
00340 \
00341 checkFields(f1, f2, #OP1 " " #OP2 " f2"); \
00342 \
00343 \
00344 \
00345 List_ACCESS(typeF1, f1, f1P); \
00346 List_CONST_ACCESS(typeF2, f2, f2P); \
00347 \
00348 \
00349 List_FOR_ALL(f1, i) \
00350 List_ELEM(f1, f1P, i) OP1 OP2 List_ELEM(f2, f2P, i); \
00351 List_END_FOR_ALL \
00352
00353
00354
00355
00356 #define TFOR_ALL_F_OP_S(typeF, f, OP, typeS, s) \
00357 \
00358 \
00359 List_ACCESS(typeF, f, fP); \
00360 \
00361 \
00362 List_FOR_ALL(f, i) \
00363 List_ELEM(f, fP, i) OP (s); \
00364 List_END_FOR_ALL \
00365
00366
00367
00368
00369
00370
00371
00372 #define TFOR_ALL_S_OP_F(typeS, s, OP, typeF, f) \
00373 \
00374 \
00375 List_CONST_ACCESS(typeF, f, fP); \
00376 \
00377 \
00378 List_FOR_ALL(f, i) \
00379 (s) OP List_ELEM(f, fP, i); \
00380 List_END_FOR_ALL
00381
00382
00383
00384
00385 #define TFOR_ALL_S_OP_F_OP_F(typeS, s, OP1, typeF1, f1, OP2, typeF2, f2) \
00386 \
00387 \
00388 List_CONST_ACCESS(typeF1, f1, f1P); \
00389 List_CONST_ACCESS(typeF2, f2, f2P); \
00390 \
00391 \
00392 List_FOR_ALL(f1, i) \
00393 (s) OP1 List_ELEM(f1, f1P, i) OP2 List_ELEM(f2, f2P, i); \
00394 List_END_FOR_ALL
00395
00396
00397
00398
00399 #define TFOR_ALL_S_OP_FUNC_F(typeS, s, OP, FUNC, typeF, f) \
00400 \
00401 \
00402 List_CONST_ACCESS(typeF, f, fP); \
00403 \
00404 \
00405 List_FOR_ALL(f, i) \
00406 (s) OP FUNC(List_ELEM(f, fP, i)); \
00407 List_END_FOR_ALL
00408
00409
00410
00411
00412 }
00413
00414
00415
00416 #endif
00417
00418