FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

DimensionedFieldFunctionsM.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include <OpenFOAM/DimensionedFieldReuseFunctions.H>
00027 
00028 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00029 
00030 #define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc)                        \
00031                                                                               \
00032 TEMPLATE                                                                      \
00033 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00034 (                                                                             \
00035     const DimensionedField<Type1, GeoMesh>& df1                               \
00036 )                                                                             \
00037 {                                                                             \
00038     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00039     (                                                                         \
00040         new DimensionedField<ReturnType, GeoMesh>                             \
00041         (                                                                     \
00042             IOobject                                                          \
00043             (                                                                 \
00044                 #Func "(" + df1.name() + ')',                                 \
00045                 df1.instance(),                                               \
00046                 df1.db()                                                      \
00047             ),                                                                \
00048             df1.mesh(),                                                       \
00049             Dfunc(df1.dimensions())                                           \
00050         )                                                                     \
00051     );                                                                        \
00052                                                                               \
00053     Func(tRes().field(), df1.field());                                        \
00054                                                                               \
00055     return tRes;                                                              \
00056 }                                                                             \
00057                                                                               \
00058 TEMPLATE                                                                      \
00059 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00060 (                                                                             \
00061     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1                        \
00062 )                                                                             \
00063 {                                                                             \
00064     const DimensionedField<Type1, GeoMesh>& df1 = tdf1();                     \
00065                                                                               \
00066     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00067     (                                                                         \
00068         reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::New             \
00069         (                                                                     \
00070             tdf1,                                                             \
00071             #Func "(" + df1.name() + ')',                                     \
00072             Dfunc(df1.dimensions())                                           \
00073         )                                                                     \
00074     );                                                                        \
00075                                                                               \
00076     Func(tRes().field(), df1.field());                                        \
00077                                                                               \
00078     reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::clear(tdf1);        \
00079                                                                               \
00080     return tRes;                                                              \
00081 }
00082 
00083 
00084 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00085 
00086 #define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)                  \
00087                                                                               \
00088 TEMPLATE                                                                      \
00089 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00090 (                                                                             \
00091     const DimensionedField<Type1, GeoMesh>& df1                               \
00092 )                                                                             \
00093 {                                                                             \
00094     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00095     (                                                                         \
00096         new DimensionedField<ReturnType, GeoMesh>                             \
00097         (                                                                     \
00098             IOobject                                                          \
00099             (                                                                 \
00100                 #Op + df1.name(),                                             \
00101                 df1.instance(),                                               \
00102                 df1.db()                                                      \
00103             ),                                                                \
00104             df1.mesh(),                                                       \
00105             Dfunc(df1.dimensions())                                           \
00106         )                                                                     \
00107     );                                                                        \
00108                                                                               \
00109     Foam::OpFunc(tRes().field(), df1.field());                                \
00110                                                                               \
00111     return tRes;                                                              \
00112 }                                                                             \
00113                                                                               \
00114 TEMPLATE                                                                      \
00115 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00116 (                                                                             \
00117     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1                        \
00118 )                                                                             \
00119 {                                                                             \
00120     const DimensionedField<Type1, GeoMesh>& df1 = tdf1();                     \
00121                                                                               \
00122     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00123     (                                                                         \
00124         reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::New             \
00125         (                                                                     \
00126             tdf1,                                                             \
00127             #Op + df1.name(),                                                 \
00128             Dfunc(df1.dimensions())                                           \
00129         )                                                                     \
00130     );                                                                        \
00131                                                                               \
00132     Foam::OpFunc(tRes().field(), df1.field());                                \
00133                                                                               \
00134     reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::clear(tdf1);        \
00135                                                                               \
00136     return tRes;                                                              \
00137 }
00138 
00139 
00140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00141 
00142 #define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)                       \
00143                                                                               \
00144 TEMPLATE                                                                      \
00145 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00146 (                                                                             \
00147     const DimensionedField<Type1, GeoMesh>& df1,                              \
00148     const DimensionedField<Type2, GeoMesh>& df2                               \
00149 )                                                                             \
00150 {                                                                             \
00151     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00152     (                                                                         \
00153         new DimensionedField<ReturnType, GeoMesh>                             \
00154         (                                                                     \
00155             IOobject                                                          \
00156             (                                                                 \
00157                 #Func "(" + df1.name() + ',' + df2.name() + ')',              \
00158                 df1.instance(),                                               \
00159                 df1.db()                                                      \
00160             ),                                                                \
00161             df1.mesh(),                                                       \
00162             Func(df1.dimensions(), df2.dimensions())                          \
00163         )                                                                     \
00164     );                                                                        \
00165                                                                               \
00166     Func(tRes().field(), df1.field(), df2.field());                           \
00167                                                                               \
00168     return tRes;                                                              \
00169 }                                                                             \
00170                                                                               \
00171 TEMPLATE                                                                      \
00172 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00173 (                                                                             \
00174     const DimensionedField<Type1, GeoMesh>& df1,                              \
00175     const tmp<DimensionedField<Type2, GeoMesh> >& tdf2                        \
00176 )                                                                             \
00177 {                                                                             \
00178     const DimensionedField<Type2, GeoMesh>& df2 = tdf2();                     \
00179                                                                               \
00180     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00181     (                                                                         \
00182         reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::New             \
00183         (                                                                     \
00184             tdf2,                                                             \
00185             #Func "(" + df1.name() + ',' + df2.name() + ')',                  \
00186             Func(df1.dimensions(), df2.dimensions())                          \
00187         )                                                                     \
00188     );                                                                        \
00189                                                                               \
00190     Func(tRes().field(), df1.field(), df2.field());                           \
00191                                                                               \
00192     reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::clear(tdf2);        \
00193                                                                               \
00194     return tRes;                                                              \
00195 }                                                                             \
00196                                                                               \
00197 TEMPLATE                                                                      \
00198 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00199 (                                                                             \
00200     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,                       \
00201     const DimensionedField<Type2, GeoMesh>& df2                               \
00202 )                                                                             \
00203 {                                                                             \
00204     const DimensionedField<Type1, GeoMesh>& df1 = tdf1();                     \
00205                                                                               \
00206     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00207     (                                                                         \
00208         reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::New             \
00209         (                                                                     \
00210             tdf1,                                                             \
00211             #Func "(" + df1.name() + ',' + df2.name() + ')',                  \
00212             Func(df1.dimensions(), df2.dimensions())                          \
00213         )                                                                     \
00214     );                                                                        \
00215                                                                               \
00216     Func(tRes().field(), df1.field(), df2.field());                           \
00217                                                                               \
00218     reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::clear(tdf1);        \
00219                                                                               \
00220     return tRes;                                                              \
00221 }                                                                             \
00222                                                                               \
00223 TEMPLATE                                                                      \
00224 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00225 (                                                                             \
00226     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,                       \
00227     const tmp<DimensionedField<Type2, GeoMesh> >& tdf2                        \
00228 )                                                                             \
00229 {                                                                             \
00230     const DimensionedField<Type1, GeoMesh>& df1 = tdf1();                     \
00231     const DimensionedField<Type2, GeoMesh>& df2 = tdf2();                     \
00232                                                                               \
00233     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00234     (                                                                         \
00235         reuseTmpTmpDimensionedField                                           \
00236             <ReturnType, Type1, Type1, Type2, GeoMesh>::New                   \
00237         (                                                                     \
00238             tdf1,                                                             \
00239             tdf2,                                                             \
00240             #Func "(" + df1.name() + ',' + df2.name() + ')',                  \
00241             Func(df1.dimensions(), df2.dimensions())                          \
00242         )                                                                     \
00243     );                                                                        \
00244                                                                               \
00245     Func(tRes().field(), df1.field(), df2.field());                           \
00246                                                                               \
00247     reuseTmpTmpDimensionedField<ReturnType, Type1, Type1, Type2, GeoMesh>     \
00248     ::clear(tdf1, tdf2);                                                      \
00249                                                                               \
00250     return tRes;                                                              \
00251 }
00252 
00253 
00254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00255 
00256 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)               \
00257                                                                               \
00258 TEMPLATE                                                                      \
00259 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00260 (                                                                             \
00261     const dimensioned<Type1>& dt1,                                            \
00262     const DimensionedField<Type2, GeoMesh>& df2                               \
00263 )                                                                             \
00264 {                                                                             \
00265     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00266     (                                                                         \
00267         new DimensionedField<ReturnType, GeoMesh>                             \
00268         (                                                                     \
00269             IOobject                                                          \
00270             (                                                                 \
00271                 #Func "(" + dt1.name() + ',' + df2.name() + ')',              \
00272                 df2.instance(),                                               \
00273                 df2.db()                                                      \
00274             ),                                                                \
00275             df2.mesh(),                                                       \
00276             Func(dt1.dimensions(), df2.dimensions())                          \
00277         )                                                                     \
00278     );                                                                        \
00279                                                                               \
00280     Func(tRes().field(), dt1.value(), df2.field());                           \
00281                                                                               \
00282     return tRes;                                                              \
00283 }                                                                             \
00284                                                                               \
00285 TEMPLATE                                                                      \
00286 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00287 (                                                                             \
00288     const Type1& t1,                                                          \
00289     const DimensionedField<Type2, GeoMesh>& df2                               \
00290 )                                                                             \
00291 {                                                                             \
00292     return Func(dimensioned<Type1>(t1), df2);                                 \
00293 }                                                                             \
00294                                                                               \
00295                                                                               \
00296 TEMPLATE                                                                      \
00297 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00298 (                                                                             \
00299     const dimensioned<Type1>& dt1,                                            \
00300     const tmp<DimensionedField<Type2, GeoMesh> >& tdf2                        \
00301 )                                                                             \
00302 {                                                                             \
00303     const DimensionedField<Type2, GeoMesh>& df2 = tdf2();                     \
00304                                                                               \
00305     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00306     (                                                                         \
00307         reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::New             \
00308         (                                                                     \
00309             tdf2,                                                             \
00310             #Func "(" + dt1.name() + ',' + df2.name() + ')',                  \
00311             Func(dt1.dimensions(), df2.dimensions())                          \
00312         )                                                                     \
00313     );                                                                        \
00314                                                                               \
00315     Func(tRes().field(), dt1.value(), df2.field());                           \
00316                                                                               \
00317     reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::clear(tdf2);        \
00318                                                                               \
00319     return tRes;                                                              \
00320 }                                                                             \
00321                                                                               \
00322 TEMPLATE                                                                      \
00323 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00324 (                                                                             \
00325     const Type1& t1,                                                          \
00326     const tmp<DimensionedField<Type2, GeoMesh> >& tdf2                        \
00327 )                                                                             \
00328 {                                                                             \
00329     return Func(dimensioned<Type2>(t1), tdf2);                                \
00330 }
00331 
00332 
00333 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)               \
00334                                                                               \
00335 TEMPLATE                                                                      \
00336 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00337 (                                                                             \
00338     const DimensionedField<Type1, GeoMesh>& df1,                              \
00339     const dimensioned<Type2>& dt2                                             \
00340 )                                                                             \
00341 {                                                                             \
00342     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00343     (                                                                         \
00344         new DimensionedField<ReturnType, GeoMesh>                             \
00345         (                                                                     \
00346             IOobject                                                          \
00347             (                                                                 \
00348                 #Func "(" + df1.name() + ',' + dt2.name() + ')',              \
00349                 df1.instance(),                                               \
00350                 df1.db()                                                      \
00351             ),                                                                \
00352             df1.mesh(),                                                       \
00353             Func(df1.dimensions(), dt2.dimensions())                          \
00354         )                                                                     \
00355     );                                                                        \
00356                                                                               \
00357     Func(tRes().field(), df1.field(), dt2.value());                           \
00358                                                                               \
00359     return tRes;                                                              \
00360 }                                                                             \
00361                                                                               \
00362 TEMPLATE                                                                      \
00363 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00364 (                                                                             \
00365     const DimensionedField<Type1, GeoMesh>& df1,                              \
00366     const Type2& t2                                                           \
00367 )                                                                             \
00368 {                                                                             \
00369     return Func(df1, dimensioned<Type2>(t2));                                 \
00370 }                                                                             \
00371                                                                               \
00372                                                                               \
00373 TEMPLATE                                                                      \
00374 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00375 (                                                                             \
00376     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,                       \
00377     const dimensioned<Type2>& dt2                                             \
00378 )                                                                             \
00379 {                                                                             \
00380     const DimensionedField<Type1, GeoMesh>& df1 = tdf1();                     \
00381                                                                               \
00382     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00383     (                                                                         \
00384         reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::New             \
00385         (                                                                     \
00386             tdf1,                                                             \
00387             #Func "(" + df1.name() + ',' + dt2.name() + ')',                  \
00388             Func(df1.dimensions(), dt2.dimensions())                          \
00389         )                                                                     \
00390     );                                                                        \
00391                                                                               \
00392     Func(tRes().field(), df1.field(), dt2.value());                           \
00393                                                                               \
00394     reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::clear(tdf1);        \
00395                                                                               \
00396     return tRes;                                                              \
00397 }                                                                             \
00398                                                                               \
00399 TEMPLATE                                                                      \
00400 tmp<DimensionedField<ReturnType, GeoMesh> > Func                              \
00401 (                                                                             \
00402     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,                       \
00403     const Type2& t2                                                           \
00404 )                                                                             \
00405 {                                                                             \
00406     return Func(tdf1, dimensioned<Type2>(t2));                                \
00407 }
00408 
00409 
00410 #define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)                  \
00411     BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)                   \
00412     BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
00413 
00414 
00415 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00416 
00417 #define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)         \
00418                                                                               \
00419 TEMPLATE                                                                      \
00420 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00421 (                                                                             \
00422     const DimensionedField<Type1, GeoMesh>& df1,                              \
00423     const DimensionedField<Type2, GeoMesh>& df2                               \
00424 )                                                                             \
00425 {                                                                             \
00426     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00427     (                                                                         \
00428         new DimensionedField<ReturnType, GeoMesh>                             \
00429         (                                                                     \
00430             IOobject                                                          \
00431             (                                                                 \
00432                 '(' + df1.name() + OpName + df2.name() + ')',                 \
00433                 df1.instance(),                                               \
00434                 df1.db()                                                      \
00435             ),                                                                \
00436             df1.mesh(),                                                       \
00437             df1.dimensions() Op df2.dimensions()                              \
00438         )                                                                     \
00439     );                                                                        \
00440                                                                               \
00441     Foam::OpFunc(tRes().field(), df1.field(), df2.field());                   \
00442                                                                               \
00443     return tRes;                                                              \
00444 }                                                                             \
00445                                                                               \
00446 TEMPLATE                                                                      \
00447 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00448 (                                                                             \
00449     const DimensionedField<Type1, GeoMesh>& df1,                              \
00450     const tmp<DimensionedField<Type2, GeoMesh> >& tdf2                        \
00451 )                                                                             \
00452 {                                                                             \
00453     const DimensionedField<Type2, GeoMesh>& df2 = tdf2();                     \
00454                                                                               \
00455     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00456     (                                                                         \
00457         reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::New             \
00458         (                                                                     \
00459             tdf2,                                                             \
00460             '(' + df1.name() + OpName + df2.name() + ')',                     \
00461             df1.dimensions() Op df2.dimensions()                              \
00462         )                                                                     \
00463     );                                                                        \
00464                                                                               \
00465     Foam::OpFunc(tRes().field(), df1.field(), df2.field());                   \
00466                                                                               \
00467     reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::clear(tdf2);        \
00468                                                                               \
00469     return tRes;                                                              \
00470 }                                                                             \
00471                                                                               \
00472 TEMPLATE                                                                      \
00473 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00474 (                                                                             \
00475     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,                       \
00476     const DimensionedField<Type2, GeoMesh>& df2                               \
00477 )                                                                             \
00478 {                                                                             \
00479     const DimensionedField<Type1, GeoMesh>& df1 = tdf1();                     \
00480                                                                               \
00481     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00482     (                                                                         \
00483         reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::New             \
00484         (                                                                     \
00485             tdf1,                                                             \
00486             '(' + df1.name() + OpName + df2.name() + ')',                     \
00487             df1.dimensions() Op df2.dimensions()                              \
00488         )                                                                     \
00489     );                                                                        \
00490                                                                               \
00491     Foam::OpFunc(tRes().field(), df1.field(), df2.field());                   \
00492                                                                               \
00493     reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::clear(tdf1);        \
00494                                                                               \
00495     return tRes;                                                              \
00496 }                                                                             \
00497                                                                               \
00498 TEMPLATE                                                                      \
00499 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00500 (                                                                             \
00501     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,                       \
00502     const tmp<DimensionedField<Type2, GeoMesh> >& tdf2                        \
00503 )                                                                             \
00504 {                                                                             \
00505     const DimensionedField<Type1, GeoMesh>& df1 = tdf1();                     \
00506     const DimensionedField<Type2, GeoMesh>& df2 = tdf2();                     \
00507                                                                               \
00508     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00509     (                                                                         \
00510         reuseTmpTmpDimensionedField                                           \
00511             <ReturnType, Type1, Type1, Type2, GeoMesh>::New                   \
00512         (                                                                     \
00513             tdf1,                                                             \
00514             tdf2,                                                             \
00515             '(' + df1.name() + OpName + df2.name() + ')',                     \
00516             df1.dimensions() Op df2.dimensions()                              \
00517         )                                                                     \
00518     );                                                                        \
00519                                                                               \
00520     Foam::OpFunc(tRes().field(), df1.field(), df2.field());                   \
00521                                                                               \
00522     reuseTmpTmpDimensionedField<ReturnType, Type1, Type1, Type2, GeoMesh>::   \
00523         clear(tdf1, tdf2);                                                    \
00524                                                                               \
00525     return tRes;                                                              \
00526 }
00527 
00528 
00529 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00530 
00531 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
00532                                                                               \
00533 TEMPLATE                                                                      \
00534 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00535 (                                                                             \
00536     const dimensioned<Type1>& dt1,                                            \
00537     const DimensionedField<Type2, GeoMesh>& df2                               \
00538 )                                                                             \
00539 {                                                                             \
00540     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00541     (                                                                         \
00542         new DimensionedField<ReturnType, GeoMesh>                             \
00543         (                                                                     \
00544             IOobject                                                          \
00545             (                                                                 \
00546                 '(' + dt1.name() + OpName + df2.name() + ')',                 \
00547                 df2.instance(),                                               \
00548                 df2.db()                                                      \
00549             ),                                                                \
00550             df2.mesh(),                                                       \
00551             dt1.dimensions() Op df2.dimensions()                              \
00552         )                                                                     \
00553     );                                                                        \
00554                                                                               \
00555     Foam::OpFunc(tRes().field(), dt1.value(), df2.field());                   \
00556                                                                               \
00557     return tRes;                                                              \
00558 }                                                                             \
00559                                                                               \
00560 TEMPLATE                                                                      \
00561 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00562 (                                                                             \
00563     const Type1& t1,                                                          \
00564     const DimensionedField<Type2, GeoMesh>& df2                               \
00565 )                                                                             \
00566 {                                                                             \
00567     return dimensioned<Type1>(t1) Op df2;                                     \
00568 }                                                                             \
00569                                                                               \
00570                                                                               \
00571 TEMPLATE                                                                      \
00572 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00573 (                                                                             \
00574     const dimensioned<Type1>& dt1,                                            \
00575     const tmp<DimensionedField<Type2, GeoMesh> >& tdf2                        \
00576 )                                                                             \
00577 {                                                                             \
00578     const DimensionedField<Type2, GeoMesh>& df2 = tdf2();                     \
00579                                                                               \
00580     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00581     (                                                                         \
00582         reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::New             \
00583         (                                                                     \
00584             tdf2,                                                             \
00585             '(' + dt1.name() + OpName + df2.name() + ')',                     \
00586             dt1.dimensions() Op df2.dimensions()                              \
00587         )                                                                     \
00588     );                                                                        \
00589                                                                               \
00590     Foam::OpFunc(tRes().field(), dt1.value(), tdf2().field());                \
00591                                                                               \
00592     reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::clear(tdf2);        \
00593                                                                               \
00594     return tRes;                                                              \
00595 }                                                                             \
00596                                                                               \
00597 TEMPLATE                                                                      \
00598 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00599 (                                                                             \
00600     const Type1& t1,                                                          \
00601     const tmp<DimensionedField<Type2, GeoMesh> >& tdf2                        \
00602 )                                                                             \
00603 {                                                                             \
00604     return dimensioned<Type1>(t1) Op tdf2;                                    \
00605 }
00606 
00607 
00608 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
00609                                                                               \
00610 TEMPLATE                                                                      \
00611 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00612 (                                                                             \
00613     const DimensionedField<Type1, GeoMesh>& df1,                              \
00614     const dimensioned<Type2>& dt2                                             \
00615 )                                                                             \
00616 {                                                                             \
00617     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00618     (                                                                         \
00619         new DimensionedField<ReturnType, GeoMesh>                             \
00620         (                                                                     \
00621             IOobject                                                          \
00622             (                                                                 \
00623                 '(' + df1.name() + OpName + dt2.name() + ')',                 \
00624                 df1.instance(),                                               \
00625                 df1.db()                                                      \
00626             ),                                                                \
00627             df1.mesh(),                                                       \
00628             df1.dimensions() Op dt2.dimensions()                              \
00629         )                                                                     \
00630     );                                                                        \
00631                                                                               \
00632     Foam::OpFunc(tRes().field(), df1.field(), dt2.value());                   \
00633                                                                               \
00634     return tRes;                                                              \
00635 }                                                                             \
00636                                                                               \
00637 TEMPLATE                                                                      \
00638 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00639 (                                                                             \
00640     const DimensionedField<Type1, GeoMesh>& df1,                              \
00641     const Type2& t2                                                           \
00642 )                                                                             \
00643 {                                                                             \
00644     return df1 Op dimensioned<Type2>(t2);                                     \
00645 }                                                                             \
00646                                                                               \
00647                                                                               \
00648 TEMPLATE                                                                      \
00649 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00650 (                                                                             \
00651     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,                       \
00652     const dimensioned<Type2>& dt2                                             \
00653 )                                                                             \
00654 {                                                                             \
00655     const DimensionedField<Type1, GeoMesh>& df1 = tdf1();                     \
00656                                                                               \
00657     tmp<DimensionedField<ReturnType, GeoMesh> > tRes                          \
00658     (                                                                         \
00659         reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::New             \
00660         (                                                                     \
00661             tdf1,                                                             \
00662             '(' + df1.name() + OpName + dt2.name() + ')',                     \
00663             df1.dimensions() Op dt2.dimensions()                              \
00664         )                                                                     \
00665     );                                                                        \
00666                                                                               \
00667     Foam::OpFunc(tRes().field(), tdf1().field(), dt2.value());                \
00668                                                                               \
00669     reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::clear(tdf1);        \
00670                                                                               \
00671     return tRes;                                                              \
00672 }                                                                             \
00673                                                                               \
00674 TEMPLATE                                                                      \
00675 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op                       \
00676 (                                                                             \
00677     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,                       \
00678     const Type2& t2                                                           \
00679 )                                                                             \
00680 {                                                                             \
00681     return tdf1 Op dimensioned<Type2>(t2);                                    \
00682 }
00683 
00684 #define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)    \
00685     BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)     \
00686     BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
00687 
00688 
00689 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines