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

GeometricFieldFunctionsM.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/GeometricFieldReuseFunctions.H>
00027 
00028 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00029 
00030 namespace Foam
00031 {
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 #define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc)                        \
00036                                                                               \
00037 TEMPLATE                                                                      \
00038 void Func                                                                     \
00039 (                                                                             \
00040     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
00041     const GeometricField<Type1, PatchField, GeoMesh>& gf1                     \
00042 )                                                                             \
00043 {                                                                             \
00044     Foam::Func(res.internalField(), gf1.internalField());                     \
00045     Foam::Func(res.boundaryField(), gf1.boundaryField());                     \
00046 }                                                                             \
00047                                                                               \
00048 TEMPLATE                                                                      \
00049 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00050 (                                                                             \
00051     const GeometricField<Type1, PatchField, GeoMesh>& gf1                     \
00052 )                                                                             \
00053 {                                                                             \
00054     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00055     (                                                                         \
00056         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
00057         (                                                                     \
00058             IOobject                                                          \
00059             (                                                                 \
00060                 #Func "(" + gf1.name() + ')',                                 \
00061                 gf1.instance(),                                               \
00062                 gf1.db(),                                                     \
00063                 IOobject::NO_READ,                                            \
00064                 IOobject::NO_WRITE                                            \
00065             ),                                                                \
00066             gf1.mesh(),                                                       \
00067             Dfunc(gf1.dimensions())                                           \
00068         )                                                                     \
00069     );                                                                        \
00070                                                                               \
00071     Foam::Func(tRes(), gf1);                                                  \
00072                                                                               \
00073     return tRes;                                                              \
00074 }                                                                             \
00075                                                                               \
00076 TEMPLATE                                                                      \
00077 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00078 (                                                                             \
00079     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1              \
00080 )                                                                             \
00081 {                                                                             \
00082     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
00083                                                                               \
00084     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00085     (                                                                         \
00086         reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New   \
00087         (                                                                     \
00088             tgf1,                                                             \
00089             #Func "(" + gf1.name() + ')',                                     \
00090             Dfunc(gf1.dimensions())                                           \
00091         )                                                                     \
00092     );                                                                        \
00093                                                                               \
00094     Foam::Func(tRes(), gf1);                                                  \
00095                                                                               \
00096     reuseTmpGeometricField                                                    \
00097         <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1);                \
00098                                                                               \
00099     return tRes;                                                              \
00100 }
00101 
00102 
00103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00104 
00105 #define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)                  \
00106                                                                               \
00107 TEMPLATE                                                                      \
00108 void OpFunc                                                                   \
00109 (                                                                             \
00110     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
00111     const GeometricField<Type1, PatchField, GeoMesh>& gf1                     \
00112 )                                                                             \
00113 {                                                                             \
00114     Foam::OpFunc(res.internalField(), gf1.internalField());                   \
00115     Foam::OpFunc(res.boundaryField(), gf1.boundaryField());                   \
00116 }                                                                             \
00117                                                                               \
00118 TEMPLATE                                                                      \
00119 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00120 (                                                                             \
00121     const GeometricField<Type1, PatchField, GeoMesh>& gf1                     \
00122 )                                                                             \
00123 {                                                                             \
00124     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00125     (                                                                         \
00126         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
00127         (                                                                     \
00128             IOobject                                                          \
00129             (                                                                 \
00130                 #Op + gf1.name(),                                             \
00131                 gf1.instance(),                                               \
00132                 gf1.db(),                                                     \
00133                 IOobject::NO_READ,                                            \
00134                 IOobject::NO_WRITE                                            \
00135             ),                                                                \
00136             gf1.mesh(),                                                       \
00137             Dfunc(gf1.dimensions())                                           \
00138         )                                                                     \
00139     );                                                                        \
00140                                                                               \
00141     Foam::OpFunc(tRes(), gf1);                                                \
00142                                                                               \
00143     return tRes;                                                              \
00144 }                                                                             \
00145                                                                               \
00146 TEMPLATE                                                                      \
00147 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00148 (                                                                             \
00149     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1              \
00150 )                                                                             \
00151 {                                                                             \
00152     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
00153                                                                               \
00154     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00155     (                                                                         \
00156         reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New   \
00157         (                                                                     \
00158             tgf1,                                                             \
00159             #Op + gf1.name(),                                                 \
00160             Dfunc(gf1.dimensions())                                           \
00161         )                                                                     \
00162     );                                                                        \
00163                                                                               \
00164     Foam::OpFunc(tRes(), gf1);                                                \
00165                                                                               \
00166     reuseTmpGeometricField                                                    \
00167         <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1);                \
00168                                                                               \
00169     return tRes;                                                              \
00170 }
00171 
00172 
00173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00174 
00175 #define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)                       \
00176                                                                               \
00177 TEMPLATE                                                                      \
00178 void Func                                                                     \
00179 (                                                                             \
00180     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
00181     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00182     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00183 )                                                                             \
00184 {                                                                             \
00185     Foam::Func(res.internalField(), gf1.internalField(), gf2.internalField());\
00186     Foam::Func(res.boundaryField(), gf1.boundaryField(), gf2.boundaryField());\
00187 }                                                                             \
00188                                                                               \
00189 TEMPLATE                                                                      \
00190 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00191 (                                                                             \
00192     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00193     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00194 )                                                                             \
00195 {                                                                             \
00196     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00197     (                                                                         \
00198         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
00199         (                                                                     \
00200             IOobject                                                          \
00201             (                                                                 \
00202                 #Func "(" + gf1.name() + ',' + gf2.name() + ')',              \
00203                 gf1.instance(),                                               \
00204                 gf1.db(),                                                     \
00205                 IOobject::NO_READ,                                            \
00206                 IOobject::NO_WRITE                                            \
00207             ),                                                                \
00208             gf1.mesh(),                                                       \
00209             Func(gf1.dimensions(), gf2.dimensions())                          \
00210         )                                                                     \
00211     );                                                                        \
00212                                                                               \
00213     Foam::Func(tRes(), gf1, gf2);                                             \
00214                                                                               \
00215     return tRes;                                                              \
00216 }                                                                             \
00217                                                                               \
00218 TEMPLATE                                                                      \
00219 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00220 (                                                                             \
00221     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00222     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00223 )                                                                             \
00224 {                                                                             \
00225     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
00226                                                                               \
00227     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00228     (                                                                         \
00229         reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New   \
00230         (                                                                     \
00231             tgf2,                                                             \
00232             #Func "(" + gf1.name() + ',' + gf2.name() + ')',                  \
00233             Func(gf1.dimensions(), gf2.dimensions())                          \
00234         )                                                                     \
00235     );                                                                        \
00236                                                                               \
00237     Foam::Func(tRes(), gf1, gf2);                                             \
00238                                                                               \
00239     reuseTmpGeometricField                                                    \
00240         <ReturnType, Type2, PatchField, GeoMesh>::clear(tgf2);                \
00241                                                                               \
00242     return tRes;                                                              \
00243 }                                                                             \
00244                                                                               \
00245 TEMPLATE                                                                      \
00246 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00247 (                                                                             \
00248     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00249     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00250 )                                                                             \
00251 {                                                                             \
00252     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
00253                                                                               \
00254     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00255     (                                                                         \
00256         reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New   \
00257         (                                                                     \
00258             tgf1,                                                             \
00259             #Func "(" + gf1.name() + ',' + gf2.name() + ')',                  \
00260             Func(gf1.dimensions(), gf2.dimensions())                          \
00261         )                                                                     \
00262     );                                                                        \
00263                                                                               \
00264     Foam::Func(tRes(), gf1, gf2);                                             \
00265                                                                               \
00266     reuseTmpGeometricField                                                    \
00267         <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1);                \
00268                                                                               \
00269     return tRes;                                                              \
00270 }                                                                             \
00271                                                                               \
00272 TEMPLATE                                                                      \
00273 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00274 (                                                                             \
00275     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00276     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00277 )                                                                             \
00278 {                                                                             \
00279     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
00280     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
00281                                                                               \
00282     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00283     (                                                                         \
00284         reuseTmpTmpGeometricField                                             \
00285             <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh>            \
00286         ::New                                                                 \
00287         (                                                                     \
00288             tgf1,                                                             \
00289             tgf2,                                                             \
00290             #Func "(" + gf1.name() + ',' + gf2.name() + ')',                  \
00291             Func(gf1.dimensions(), gf2.dimensions())                          \
00292         )                                                                     \
00293     );                                                                        \
00294                                                                               \
00295     Foam::Func(tRes(), gf1, gf2);                                             \
00296                                                                               \
00297     reuseTmpTmpGeometricField                                                 \
00298         <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh>                \
00299         ::clear(tgf1, tgf2);                                                  \
00300                                                                               \
00301     return tRes;                                                              \
00302 }
00303 
00304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00305 
00306 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)               \
00307                                                                               \
00308 TEMPLATE                                                                      \
00309 void Func                                                                     \
00310 (                                                                             \
00311     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
00312     const dimensioned<Type1>& dt1,                                            \
00313     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00314 )                                                                             \
00315 {                                                                             \
00316     Foam::Func(res.internalField(), dt1.value(), gf2.internalField());        \
00317     Foam::Func(res.boundaryField(), dt1.value(), gf2.boundaryField());        \
00318 }                                                                             \
00319                                                                               \
00320 TEMPLATE                                                                      \
00321 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00322 (                                                                             \
00323     const dimensioned<Type1>& dt1,                                            \
00324     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00325 )                                                                             \
00326 {                                                                             \
00327     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00328     (                                                                         \
00329         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
00330         (                                                                     \
00331             IOobject                                                          \
00332             (                                                                 \
00333                 #Func "(" + dt1.name() + ',' + gf2.name() + ')',              \
00334                 gf2.instance(),                                               \
00335                 gf2.db(),                                                     \
00336                 IOobject::NO_READ,                                            \
00337                 IOobject::NO_WRITE                                            \
00338             ),                                                                \
00339             gf2.mesh(),                                                       \
00340             Func(dt1.dimensions(), gf2.dimensions())                          \
00341         )                                                                     \
00342     );                                                                        \
00343                                                                               \
00344     Foam::Func(tRes(), dt1, gf2);                                             \
00345                                                                               \
00346     return tRes;                                                              \
00347 }                                                                             \
00348                                                                               \
00349 TEMPLATE                                                                      \
00350 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00351 (                                                                             \
00352     const Type1& t1,                                                          \
00353     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00354 )                                                                             \
00355 {                                                                             \
00356     return Func(dimensioned<Type1>(t1), gf2);                                 \
00357 }                                                                             \
00358                                                                               \
00359                                                                               \
00360 TEMPLATE                                                                      \
00361 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00362 (                                                                             \
00363     const dimensioned<Type1>& dt1,                                            \
00364     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00365 )                                                                             \
00366 {                                                                             \
00367     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
00368                                                                               \
00369     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00370     (                                                                         \
00371         reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New   \
00372         (                                                                     \
00373             tgf2,                                                             \
00374             #Func "(" + dt1.name() + gf2.name() + ',' + ')',                  \
00375             Func(dt1.dimensions(), gf2.dimensions())                          \
00376         )                                                                     \
00377     );                                                                        \
00378                                                                               \
00379     Foam::Func(tRes(), dt1, gf2);                                             \
00380                                                                               \
00381     reuseTmpGeometricField                                                    \
00382         <ReturnType, Type2, PatchField, GeoMesh>::clear(tgf2);                \
00383                                                                               \
00384     return tRes;                                                              \
00385 }                                                                             \
00386                                                                               \
00387 TEMPLATE                                                                      \
00388 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00389 (                                                                             \
00390     const Type1& t1,                                                          \
00391     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00392 )                                                                             \
00393 {                                                                             \
00394     return Func(dimensioned<Type1>(t1), tgf2);                                \
00395 }
00396 
00397 
00398 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)               \
00399                                                                               \
00400 TEMPLATE                                                                      \
00401 void Func                                                                     \
00402 (                                                                             \
00403     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
00404     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00405     const dimensioned<Type2>& dt2                                             \
00406 )                                                                             \
00407 {                                                                             \
00408     Foam::Func(res.internalField(), gf1.internalField(), dt2.value());        \
00409     Foam::Func(res.boundaryField(), gf1.boundaryField(), dt2.value());        \
00410 }                                                                             \
00411                                                                               \
00412 TEMPLATE                                                                      \
00413 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00414 (                                                                             \
00415     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00416     const dimensioned<Type2>& dt2                                             \
00417 )                                                                             \
00418 {                                                                             \
00419     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00420     (                                                                         \
00421         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
00422         (                                                                     \
00423             IOobject                                                          \
00424             (                                                                 \
00425                 #Func "(" + gf1.name() + ',' + dt2.name() + ')',              \
00426                 gf1.instance(),                                               \
00427                 gf1.db(),                                                     \
00428                 IOobject::NO_READ,                                            \
00429                 IOobject::NO_WRITE                                            \
00430             ),                                                                \
00431             gf1.mesh(),                                                       \
00432             Func(gf1.dimensions(), dt2.dimensions())                          \
00433         )                                                                     \
00434     );                                                                        \
00435                                                                               \
00436     Foam::Func(tRes(), gf1, dt2);                                             \
00437                                                                               \
00438     return tRes;                                                              \
00439 }                                                                             \
00440                                                                               \
00441 TEMPLATE                                                                      \
00442 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00443 (                                                                             \
00444     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00445     const Type2& t2                                                           \
00446 )                                                                             \
00447 {                                                                             \
00448     return Func(gf1, dimensioned<Type2>(t2));                                 \
00449 }                                                                             \
00450                                                                               \
00451                                                                               \
00452 TEMPLATE                                                                      \
00453 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00454 (                                                                             \
00455     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00456     const dimensioned<Type2>& dt2                                             \
00457 )                                                                             \
00458 {                                                                             \
00459     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
00460                                                                               \
00461     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00462     (                                                                         \
00463         reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New   \
00464         (                                                                     \
00465             tgf1,                                                             \
00466             #Func "(" + gf1.name() + ',' + dt2.name() + ')',                  \
00467             Func(gf1.dimensions(), dt2.dimensions())                          \
00468         )                                                                     \
00469     );                                                                        \
00470                                                                               \
00471     Foam::Func(tRes(), gf1, dt2);                                             \
00472                                                                               \
00473     reuseTmpGeometricField                                                    \
00474         <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1);                \
00475                                                                               \
00476     return tRes;                                                              \
00477 }                                                                             \
00478                                                                               \
00479 TEMPLATE                                                                      \
00480 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
00481 (                                                                             \
00482     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00483     const Type2& t2                                                           \
00484 )                                                                             \
00485 {                                                                             \
00486     return Func(tgf1, dimensioned<Type2>(t2));                                \
00487 }
00488 
00489 
00490 #define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)                  \
00491     BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)                   \
00492     BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
00493 
00494 
00495 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00496 
00497 #define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)         \
00498                                                                               \
00499 TEMPLATE                                                                      \
00500 void OpFunc                                                                   \
00501 (                                                                             \
00502     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
00503     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00504     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00505 )                                                                             \
00506 {                                                                             \
00507     Foam::OpFunc                                                              \
00508         (res.internalField(), gf1.internalField(), gf2.internalField());      \
00509     Foam::OpFunc                                                              \
00510         (res.boundaryField(), gf1.boundaryField(), gf2.boundaryField());      \
00511 }                                                                             \
00512                                                                               \
00513 TEMPLATE                                                                      \
00514 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00515 (                                                                             \
00516     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00517     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00518 )                                                                             \
00519 {                                                                             \
00520     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00521     (                                                                         \
00522         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
00523         (                                                                     \
00524             IOobject                                                          \
00525             (                                                                 \
00526                 '(' + gf1.name() + OpName + gf2.name() + ')',                 \
00527                 gf1.instance(),                                               \
00528                 gf1.db(),                                                     \
00529                 IOobject::NO_READ,                                            \
00530                 IOobject::NO_WRITE                                            \
00531             ),                                                                \
00532             gf1.mesh(),                                                       \
00533             gf1.dimensions() Op gf2.dimensions()                              \
00534         )                                                                     \
00535     );                                                                        \
00536                                                                               \
00537     Foam::OpFunc(tRes(), gf1, gf2);                                           \
00538                                                                               \
00539     return tRes;                                                              \
00540 }                                                                             \
00541                                                                               \
00542 TEMPLATE                                                                      \
00543 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00544 (                                                                             \
00545     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00546     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00547 )                                                                             \
00548 {                                                                             \
00549     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
00550                                                                               \
00551     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00552     (                                                                         \
00553         reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New   \
00554         (                                                                     \
00555             tgf2,                                                             \
00556             '(' + gf1.name() + OpName + gf2.name() + ')',                     \
00557             gf1.dimensions() Op gf2.dimensions()                              \
00558         )                                                                     \
00559     );                                                                        \
00560                                                                               \
00561     Foam::OpFunc(tRes(), gf1, gf2);                                           \
00562                                                                               \
00563     reuseTmpGeometricField                                                    \
00564         <ReturnType, Type2, PatchField, GeoMesh>::clear(tgf2);                \
00565                                                                               \
00566     return tRes;                                                              \
00567 }                                                                             \
00568                                                                               \
00569 TEMPLATE                                                                      \
00570 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00571 (                                                                             \
00572     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00573     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00574 )                                                                             \
00575 {                                                                             \
00576     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
00577                                                                               \
00578     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00579     (                                                                         \
00580         reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New   \
00581         (                                                                     \
00582             tgf1,                                                             \
00583             '(' + gf1.name() + OpName + gf2.name() + ')',                     \
00584             gf1.dimensions() Op gf2.dimensions()                              \
00585         )                                                                     \
00586     );                                                                        \
00587                                                                               \
00588     Foam::OpFunc(tRes(), gf1, gf2);                                           \
00589                                                                               \
00590     reuseTmpGeometricField                                                    \
00591         <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1);                \
00592                                                                               \
00593     return tRes;                                                              \
00594 }                                                                             \
00595                                                                               \
00596 TEMPLATE                                                                      \
00597 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00598 (                                                                             \
00599     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00600     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00601 )                                                                             \
00602 {                                                                             \
00603     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
00604     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
00605                                                                               \
00606     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00607     (                                                                         \
00608         reuseTmpTmpGeometricField                                             \
00609             <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh>::New       \
00610         (                                                                     \
00611             tgf1,                                                             \
00612             tgf2,                                                             \
00613             '(' + gf1.name() + OpName + gf2.name() + ')',                     \
00614             gf1.dimensions() Op gf2.dimensions()                              \
00615         )                                                                     \
00616     );                                                                        \
00617                                                                               \
00618     Foam::OpFunc(tRes(), gf1, gf2);                                           \
00619                                                                               \
00620     reuseTmpTmpGeometricField                                                 \
00621         <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh>                \
00622         ::clear(tgf1, tgf2);                                                  \
00623                                                                               \
00624     return tRes;                                                              \
00625 }
00626 
00627 
00628 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00629 
00630 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
00631                                                                               \
00632 TEMPLATE                                                                      \
00633 void OpFunc                                                                   \
00634 (                                                                             \
00635     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
00636     const dimensioned<Type1>& dt1,                                            \
00637     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00638 )                                                                             \
00639 {                                                                             \
00640     Foam::OpFunc(res.internalField(), dt1.value(), gf2.internalField());      \
00641     Foam::OpFunc(res.boundaryField(), dt1.value(), gf2.boundaryField());      \
00642 }                                                                             \
00643                                                                               \
00644 TEMPLATE                                                                      \
00645 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00646 (                                                                             \
00647     const dimensioned<Type1>& dt1,                                            \
00648     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00649 )                                                                             \
00650 {                                                                             \
00651     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00652     (                                                                         \
00653         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
00654         (                                                                     \
00655             IOobject                                                          \
00656             (                                                                 \
00657                 '(' + dt1.name() + OpName + gf2.name() + ')',                 \
00658                 gf2.instance(),                                               \
00659                 gf2.db(),                                                     \
00660                 IOobject::NO_READ,                                            \
00661                 IOobject::NO_WRITE                                            \
00662             ),                                                                \
00663             gf2.mesh(),                                                       \
00664             dt1.dimensions() Op gf2.dimensions()                              \
00665         )                                                                     \
00666     );                                                                        \
00667                                                                               \
00668     Foam::OpFunc(tRes(), dt1, gf2);                                           \
00669                                                                               \
00670     return tRes;                                                              \
00671 }                                                                             \
00672                                                                               \
00673 TEMPLATE                                                                      \
00674 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00675 (                                                                             \
00676     const Type1& t1,                                                          \
00677     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00678 )                                                                             \
00679 {                                                                             \
00680     return dimensioned<Type1>(t1) Op gf2;                                     \
00681 }                                                                             \
00682                                                                               \
00683                                                                               \
00684 TEMPLATE                                                                      \
00685 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00686 (                                                                             \
00687     const dimensioned<Type1>& dt1,                                            \
00688     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00689 )                                                                             \
00690 {                                                                             \
00691     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
00692                                                                               \
00693     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00694     (                                                                         \
00695         reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New   \
00696         (                                                                     \
00697             tgf2,                                                             \
00698             '(' + dt1.name() + OpName + gf2.name() + ')',                     \
00699             dt1.dimensions() Op gf2.dimensions()                              \
00700         )                                                                     \
00701     );                                                                        \
00702                                                                               \
00703     Foam::OpFunc(tRes(), dt1, gf2);                                           \
00704                                                                               \
00705     reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>            \
00706         ::clear(tgf2);                                                        \
00707                                                                               \
00708     return tRes;                                                              \
00709 }                                                                             \
00710                                                                               \
00711 TEMPLATE                                                                      \
00712 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00713 (                                                                             \
00714     const Type1& t1,                                                          \
00715     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00716 )                                                                             \
00717 {                                                                             \
00718     return dimensioned<Type1>(t1) Op tgf2;                                    \
00719 }
00720 
00721 
00722 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
00723                                                                               \
00724 TEMPLATE                                                                      \
00725 void OpFunc                                                                   \
00726 (                                                                             \
00727     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
00728     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00729     const dimensioned<Type2>& dt2                                             \
00730 )                                                                             \
00731 {                                                                             \
00732     Foam::OpFunc(res.internalField(), gf1.internalField(), dt2.value());      \
00733     Foam::OpFunc(res.boundaryField(), gf1.boundaryField(), dt2.value());      \
00734 }                                                                             \
00735                                                                               \
00736 TEMPLATE                                                                      \
00737 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00738 (                                                                             \
00739     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00740     const dimensioned<Type2>& dt2                                             \
00741 )                                                                             \
00742 {                                                                             \
00743     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00744     (                                                                         \
00745         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
00746         (                                                                     \
00747             IOobject                                                          \
00748             (                                                                 \
00749                 '(' + gf1.name() + OpName + dt2.name() + ')',                 \
00750                 gf1.instance(),                                               \
00751                 gf1.db(),                                                     \
00752                 IOobject::NO_READ,                                            \
00753                 IOobject::NO_WRITE                                            \
00754             ),                                                                \
00755             gf1.mesh(),                                                       \
00756             gf1.dimensions() Op dt2.dimensions()                              \
00757         )                                                                     \
00758     );                                                                        \
00759                                                                               \
00760     Foam::OpFunc(tRes(), gf1, dt2);                                           \
00761                                                                               \
00762     return tRes;                                                              \
00763 }                                                                             \
00764                                                                               \
00765 TEMPLATE                                                                      \
00766 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00767 (                                                                             \
00768     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00769     const Type2& t2                                                           \
00770 )                                                                             \
00771 {                                                                             \
00772     return gf1 Op dimensioned<Type2>(t2);                                     \
00773 }                                                                             \
00774                                                                               \
00775                                                                               \
00776 TEMPLATE                                                                      \
00777 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00778 (                                                                             \
00779     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00780     const dimensioned<Type2>& dt2                                             \
00781 )                                                                             \
00782 {                                                                             \
00783     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
00784                                                                               \
00785     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
00786     (                                                                         \
00787         reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New   \
00788         (                                                                     \
00789             tgf1,                                                             \
00790             '(' + gf1.name() + OpName + dt2.name() + ')',                     \
00791             gf1.dimensions() Op dt2.dimensions()                              \
00792         )                                                                     \
00793     );                                                                        \
00794                                                                               \
00795     Foam::OpFunc(tRes(), gf1, dt2);                                           \
00796                                                                               \
00797     reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>            \
00798         ::clear(tgf1);                                                        \
00799                                                                               \
00800     return tRes;                                                              \
00801 }                                                                             \
00802                                                                               \
00803 TEMPLATE                                                                      \
00804 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
00805 (                                                                             \
00806     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00807     const Type2& t2                                                           \
00808 )                                                                             \
00809 {                                                                             \
00810     return tgf1 Op dimensioned<Type2>(t2);                                    \
00811 }
00812 
00813 
00814 #define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)    \
00815     BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)     \
00816     BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
00817 
00818 
00819 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00820 
00821 } // End namespace Foam
00822 
00823 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines