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

GeometricFieldFunctions.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 #define TEMPLATE \
00029     template<class Type, template<class> class PatchField, class GeoMesh>
00030 #include <OpenFOAM/GeometricFieldFunctionsM.C>
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 // * * * * * * * * * * * * * * * Global functions  * * * * * * * * * * * * * //
00038 
00039 template<class Type, template<class> class PatchField, class GeoMesh>
00040 void component
00041 (
00042     GeometricField
00043     <
00044         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
00045         PatchField,
00046         GeoMesh
00047     >& gcf,
00048     const GeometricField<Type, PatchField, GeoMesh>& gf,
00049     const direction d
00050 )
00051 {
00052     component(gcf.internalField(), gf.internalField(), d);
00053     component(gcf.boundaryField(), gf.boundaryField(), d);
00054 }
00055 
00056 
00057 template<class Type, template<class> class PatchField, class GeoMesh>
00058 void T
00059 (
00060      GeometricField<Type, PatchField, GeoMesh>& gf,
00061      const GeometricField<Type, PatchField, GeoMesh>& gf1
00062 )
00063 {
00064     T(gf.internalField(), gf1.internalField());
00065     T(gf.boundaryField(), gf1.boundaryField());
00066 }
00067 
00068 
00069 template<class Type, template<class> class PatchField, class GeoMesh, int r>
00070 void pow
00071 (
00072     GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>& gf,
00073     const GeometricField<Type, PatchField, GeoMesh>& gf1
00074 )
00075 {
00076     pow(gf.internalField(), gf1.internalField(), r);
00077     pow(gf.boundaryField(), gf1.boundaryField(), r);
00078 }
00079 
00080 template<class Type, template<class> class PatchField, class GeoMesh, int r>
00081 tmp<GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh> >
00082 pow
00083 (
00084     const GeometricField<Type, PatchField, GeoMesh>& gf,
00085     typename powProduct<Type, r>::type
00086 )
00087 {
00088     typedef typename powProduct<Type, r>::type powProductType;
00089 
00090     tmp<GeometricField<powProductType, PatchField, GeoMesh> > tPow
00091     (
00092         new GeometricField<powProductType, PatchField, GeoMesh>
00093         (
00094             IOobject
00095             (
00096                 "pow(" + gf.name() + ',' + name(r) + ')',
00097                 gf.instance(),
00098                 gf.db(),
00099                 IOobject::NO_READ,
00100                 IOobject::NO_WRITE
00101             ),
00102             gf.mesh(),
00103             pow(gf.dimensions(), r)
00104         )
00105     );
00106 
00107     pow<Type, r, PatchField, GeoMesh>(tPow(), gf);
00108 
00109     return tPow;
00110 }
00111 
00112 
00113 template<class Type, template<class> class PatchField, class GeoMesh, int r>
00114 tmp<GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh> >
00115 pow
00116 (
00117     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf,
00118     typename powProduct<Type, r>::type
00119 )
00120 {
00121     typedef typename powProduct<Type, r>::type powProductType;
00122 
00123     const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
00124 
00125     tmp<GeometricField<powProductType, PatchField, GeoMesh> > tPow
00126     (
00127         new GeometricField<powProductType, PatchField, GeoMesh>
00128         (
00129             IOobject
00130             (
00131                 "pow(" + gf.name() + ',' + name(r) + ')',
00132                 gf.instance(),
00133                 gf.db(),
00134                 IOobject::NO_READ,
00135                 IOobject::NO_WRITE
00136             ),
00137             gf.mesh(),
00138             pow(gf.dimensions(), r)
00139         )
00140     );
00141 
00142     pow<Type, r, PatchField, GeoMesh>(tPow(), gf);
00143 
00144     tgf.clear();
00145 
00146     return tPow;
00147 }
00148 
00149 
00150 template<class Type, template<class> class PatchField, class GeoMesh>
00151 void sqr
00152 (
00153     GeometricField
00154     <typename outerProduct<Type, Type>::type, PatchField, GeoMesh>& gf,
00155     const GeometricField<Type, PatchField, GeoMesh>& gf1
00156 )
00157 {
00158     sqr(gf.internalField(), gf1.internalField());
00159     sqr(gf.boundaryField(), gf1.boundaryField());
00160 }
00161 
00162 template<class Type, template<class> class PatchField, class GeoMesh>
00163 tmp
00164 <
00165     GeometricField
00166     <
00167         typename outerProduct<Type, Type>::type,
00168         PatchField,
00169         GeoMesh
00170     >
00171 >
00172 sqr(const GeometricField<Type, PatchField, GeoMesh>& gf)
00173 {
00174     typedef typename outerProduct<Type, Type>::type outerProductType;
00175 
00176     tmp<GeometricField<outerProductType, PatchField, GeoMesh> > tSqr
00177     (
00178         new GeometricField<outerProductType, PatchField, GeoMesh>
00179         (
00180             IOobject
00181             (
00182                 "sqr(" + gf.name() + ')',
00183                 gf.instance(),
00184                 gf.db(),
00185                 IOobject::NO_READ,
00186                 IOobject::NO_WRITE
00187             ),
00188             gf.mesh(),
00189             sqr(gf.dimensions())
00190         )
00191     );
00192 
00193     sqr(tSqr(), gf);
00194 
00195     return tSqr;
00196 }
00197 
00198 template<class Type, template<class> class PatchField, class GeoMesh>
00199 tmp
00200 <
00201     GeometricField
00202     <
00203         typename outerProduct<Type, Type>::type,
00204         PatchField,
00205         GeoMesh
00206     >
00207 >
00208 sqr(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf)
00209 {
00210     typedef typename outerProduct<Type, Type>::type outerProductType;
00211 
00212     const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
00213 
00214     tmp<GeometricField<outerProductType, PatchField, GeoMesh> > tSqr
00215     (
00216         new GeometricField<outerProductType, PatchField, GeoMesh>
00217         (
00218             IOobject
00219             (
00220                 "sqr(" + gf.name() + ')',
00221                 gf.instance(),
00222                 gf.db(),
00223                 IOobject::NO_READ,
00224                 IOobject::NO_WRITE
00225             ),
00226             gf.mesh(),
00227             sqr(gf.dimensions())
00228         )
00229     );
00230 
00231     sqr(tSqr(), gf);
00232 
00233     tgf.clear();
00234 
00235     return tSqr;
00236 }
00237 
00238 
00239 template<class Type, template<class> class PatchField, class GeoMesh>
00240 void magSqr
00241 (
00242     GeometricField<scalar, PatchField, GeoMesh>& gsf,
00243     const GeometricField<Type, PatchField, GeoMesh>& gf
00244 )
00245 {
00246     magSqr(gsf.internalField(), gf.internalField());
00247     magSqr(gsf.boundaryField(), gf.boundaryField());
00248 }
00249 
00250 template<class Type, template<class> class PatchField, class GeoMesh>
00251 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
00252 (
00253     const GeometricField<Type, PatchField, GeoMesh>& gf
00254 )
00255 {
00256     tmp<GeometricField<scalar, PatchField, GeoMesh> > tMagSqr
00257     (
00258         new GeometricField<scalar, PatchField, GeoMesh>
00259         (
00260             IOobject
00261             (
00262                 "magSqr(" + gf.name() + ')',
00263                 gf.instance(),
00264                 gf.db(),
00265                 IOobject::NO_READ,
00266                 IOobject::NO_WRITE
00267             ),
00268             gf.mesh(),
00269             sqr(gf.dimensions())
00270         )
00271     );
00272 
00273     magSqr(tMagSqr(), gf);
00274 
00275     return tMagSqr;
00276 }
00277 
00278 template<class Type, template<class> class PatchField, class GeoMesh>
00279 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
00280 (
00281     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
00282 )
00283 {
00284     const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
00285 
00286     tmp<GeometricField<scalar, PatchField, GeoMesh> > tMagSqr
00287     (
00288         new GeometricField<scalar, PatchField, GeoMesh>
00289         (
00290             IOobject
00291             (
00292                 "magSqr(" + gf.name() + ')',
00293                 gf.instance(),
00294                 gf.db(),
00295                 IOobject::NO_READ,
00296                 IOobject::NO_WRITE
00297             ),
00298             gf.mesh(),
00299             sqr(gf.dimensions())
00300         )
00301     );
00302 
00303     magSqr(tMagSqr(), gf);
00304 
00305     tgf.clear();
00306 
00307     return tMagSqr;
00308 }
00309 
00310 
00311 template<class Type, template<class> class PatchField, class GeoMesh>
00312 void mag
00313 (
00314     GeometricField<scalar, PatchField, GeoMesh>& gsf,
00315     const GeometricField<Type, PatchField, GeoMesh>& gf
00316 )
00317 {
00318     mag(gsf.internalField(), gf.internalField());
00319     mag(gsf.boundaryField(), gf.boundaryField());
00320 }
00321 
00322 template<class Type, template<class> class PatchField, class GeoMesh>
00323 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
00324 (
00325     const GeometricField<Type, PatchField, GeoMesh>& gf
00326 )
00327 {
00328     tmp<GeometricField<scalar, PatchField, GeoMesh> > tMag
00329     (
00330         new GeometricField<scalar, PatchField, GeoMesh>
00331         (
00332             IOobject
00333             (
00334                 "mag(" + gf.name() + ')',
00335                 gf.instance(),
00336                 gf.db(),
00337                 IOobject::NO_READ,
00338                 IOobject::NO_WRITE
00339             ),
00340             gf.mesh(),
00341             gf.dimensions()
00342         )
00343     );
00344 
00345     mag(tMag(), gf);
00346 
00347     return tMag;
00348 }
00349 
00350 template<class Type, template<class> class PatchField, class GeoMesh>
00351 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
00352 (
00353     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
00354 )
00355 {
00356     const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
00357 
00358     tmp<GeometricField<scalar, PatchField, GeoMesh> > tMag
00359     (
00360         new GeometricField<scalar, PatchField, GeoMesh>
00361         (
00362             IOobject
00363             (
00364                 "mag(" + gf.name() + ')',
00365                 gf.instance(),
00366                 gf.db(),
00367                 IOobject::NO_READ,
00368                 IOobject::NO_WRITE
00369             ),
00370             gf.mesh(),
00371             gf.dimensions()
00372         )
00373     );
00374 
00375     mag(tMag(), gf);
00376 
00377     tgf.clear();
00378 
00379     return tMag;
00380 }
00381 
00382 
00383 template<class Type, template<class> class PatchField, class GeoMesh>
00384 void cmptAv
00385 (
00386     GeometricField
00387     <
00388         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
00389         PatchField,
00390         GeoMesh
00391     >& gcf,
00392     const GeometricField<Type, PatchField, GeoMesh>& gf
00393 )
00394 {
00395     cmptAv(gcf.internalField(), gf.internalField());
00396     cmptAv(gcf.boundaryField(), gf.boundaryField());
00397 }
00398 
00399 template<class Type, template<class> class PatchField, class GeoMesh>
00400 tmp
00401 <
00402     GeometricField
00403     <
00404         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
00405         PatchField,
00406         GeoMesh
00407     >
00408 >
00409 cmptAv(const GeometricField<Type, PatchField, GeoMesh>& gf)
00410 {
00411     typedef typename GeometricField<Type, PatchField, GeoMesh>::cmptType
00412         cmptType;
00413 
00414     tmp<GeometricField<cmptType, PatchField, GeoMesh> > CmptAv
00415     (
00416         new GeometricField<scalar, PatchField, GeoMesh>
00417         (
00418             IOobject
00419             (
00420                 "cmptAv(" + gf.name() + ')',
00421                 gf.instance(),
00422                 gf.db(),
00423                 IOobject::NO_READ,
00424                 IOobject::NO_WRITE
00425             ),
00426             gf.mesh(),
00427             gf.dimensions()
00428         )
00429     );
00430 
00431     cmptAv(CmptAv(), gf);
00432 
00433     return CmptAv;
00434 }
00435 
00436 template<class Type, template<class> class PatchField, class GeoMesh>
00437 tmp
00438 <
00439     GeometricField
00440     <
00441         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
00442         PatchField,
00443         GeoMesh
00444     >
00445 >
00446 cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf)
00447 {
00448     typedef typename GeometricField<Type, PatchField, GeoMesh>::cmptType 
00449         cmptType;
00450 
00451     const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
00452 
00453     tmp<GeometricField<cmptType, PatchField, GeoMesh> > CmptAv
00454     (
00455         new GeometricField<scalar, PatchField, GeoMesh>
00456         (
00457             IOobject
00458             (
00459                 "cmptAv(" + gf.name() + ')',
00460                 gf.instance(),
00461                 gf.db(),
00462                 IOobject::NO_READ,
00463                 IOobject::NO_WRITE
00464             ),
00465             gf.mesh(),
00466             gf.dimensions()
00467         )
00468     );
00469 
00470     cmptAv(CmptAv(), gf);
00471 
00472     tgf.clear();
00473 
00474     return CmptAv;
00475 }
00476 
00477 
00478 #define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc)       \
00479                                                                               \
00480 template<class Type, template<class> class PatchField, class GeoMesh>         \
00481 dimensioned<returnType> func                                                  \
00482 (                                                                             \
00483     const GeometricField<Type, PatchField, GeoMesh>& gf                       \
00484 )                                                                             \
00485 {                                                                             \
00486     return dimensioned<Type>                                                  \
00487     (                                                                         \
00488         #func "(" + gf.name() + ')',                                          \
00489         gf.dimensions(),                                                      \
00490         Foam::func(gFunc(gf.internalField()), gFunc(gf.boundaryField()))      \
00491     );                                                                        \
00492 }                                                                             \
00493                                                                               \
00494 template<class Type, template<class> class PatchField, class GeoMesh>         \
00495 dimensioned<returnType> func                                                  \
00496 (                                                                             \
00497     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
00498 )                                                                             \
00499 {                                                                             \
00500     dimensioned<returnType> res = func(tgf1());                               \
00501     tgf1.clear();                                                             \
00502     return res;                                                               \
00503 }
00504 
00505 UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, max, gMax)
00506 UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, min, gMin)
00507 
00508 #undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
00509 
00510 
00511 #define UNARY_REDUCTION_FUNCTION(returnType, func, gFunc)                     \
00512                                                                               \
00513 template<class Type, template<class> class PatchField, class GeoMesh>         \
00514 dimensioned<returnType> func                                                  \
00515 (                                                                             \
00516     const GeometricField<Type, PatchField, GeoMesh>& gf                       \
00517 )                                                                             \
00518 {                                                                             \
00519     return dimensioned<Type>                                                  \
00520     (                                                                         \
00521         #func "(" + gf.name() + ')',                                          \
00522         gf.dimensions(),                                                      \
00523         gFunc(gf.internalField())                                             \
00524     );                                                                        \
00525 }                                                                             \
00526                                                                               \
00527 template<class Type, template<class> class PatchField, class GeoMesh>         \
00528 dimensioned<returnType> func                                                  \
00529 (                                                                             \
00530     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
00531 )                                                                             \
00532 {                                                                             \
00533     dimensioned<returnType> res = func(tgf1());                               \
00534     tgf1.clear();                                                             \
00535     return res;                                                               \
00536 }
00537 
00538 UNARY_REDUCTION_FUNCTION(Type, sum, gSum)
00539 UNARY_REDUCTION_FUNCTION(scalar, sumMag, gSumMag)
00540 UNARY_REDUCTION_FUNCTION(Type, average, gAverage)
00541 
00542 #undef UNARY_REDUCTION_FUNCTION
00543 
00544 
00545 BINARY_FUNCTION(Type, Type, Type, max)
00546 BINARY_FUNCTION(Type, Type, Type, min)
00547 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
00548 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
00549 
00550 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
00551 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
00552 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
00553 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
00554 
00555 
00556 // * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * //
00557 
00558 UNARY_OPERATOR(Type, Type, -, negate, transform)
00559 
00560 #ifndef __INTEL_COMPILER
00561 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
00562 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
00563 #endif
00564 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
00565 
00566 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
00567 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
00568 
00569 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
00570 
00571 
00572 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00573 
00574 #define PRODUCT_OPERATOR(product, op, opFunc)                                 \
00575                                                                               \
00576 template                                                                      \
00577 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00578 void opFunc                                                                   \
00579 (                                                                             \
00580     GeometricField                                                            \
00581     <typename product<Type1, Type2>::type, PatchField, GeoMesh>& gf,          \
00582     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00583     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00584 )                                                                             \
00585 {                                                                             \
00586     Foam::opFunc(gf.internalField(), gf1.internalField(), gf2.internalField());\
00587     Foam::opFunc(gf.boundaryField(), gf1.boundaryField(), gf2.boundaryField());\
00588 }                                                                             \
00589                                                                               \
00590 template                                                                      \
00591 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00592 tmp                                                                           \
00593 <                                                                             \
00594     GeometricField<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
00595 >                                                                             \
00596 operator op                                                                   \
00597 (                                                                             \
00598     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00599     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00600 )                                                                             \
00601 {                                                                             \
00602     typedef typename product<Type1, Type2>::type productType;                 \
00603     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes               \
00604     (                                                                         \
00605         new GeometricField<productType, PatchField, GeoMesh>                  \
00606         (                                                                     \
00607             IOobject                                                          \
00608             (                                                                 \
00609                 '(' + gf1.name() + #op + gf2.name() + ')',                    \
00610                 gf1.instance(),                                               \
00611                 gf1.db(),                                                     \
00612                 IOobject::NO_READ,                                            \
00613                 IOobject::NO_WRITE                                            \
00614             ),                                                                \
00615             gf1.mesh(),                                                       \
00616             gf1.dimensions() op gf2.dimensions()                              \
00617         )                                                                     \
00618     );                                                                        \
00619                                                                               \
00620     Foam::opFunc(tRes(), gf1, gf2);                                           \
00621                                                                               \
00622     return tRes;                                                              \
00623 }                                                                             \
00624                                                                               \
00625 template                                                                      \
00626 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00627 tmp                                                                           \
00628 <                                                                             \
00629     GeometricField<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
00630 >                                                                             \
00631 operator op                                                                   \
00632 (                                                                             \
00633     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00634     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00635 )                                                                             \
00636 {                                                                             \
00637     typedef typename product<Type1, Type2>::type productType;                 \
00638                                                                               \
00639     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
00640                                                                               \
00641     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes =             \
00642         reuseTmpGeometricField<productType, Type2, PatchField, GeoMesh>::New  \
00643         (                                                                     \
00644             tgf2,                                                             \
00645             '(' + gf1.name() + #op + gf2.name() + ')',                        \
00646             gf1.dimensions() op gf2.dimensions()                              \
00647         );                                                                    \
00648                                                                               \
00649     Foam::opFunc(tRes(), gf1, gf2);                                           \
00650                                                                               \
00651     reuseTmpGeometricField<productType, Type2, PatchField, GeoMesh>           \
00652     ::clear(tgf2);                                                            \
00653                                                                               \
00654     return tRes;                                                              \
00655 }                                                                             \
00656                                                                               \
00657 template                                                                      \
00658 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00659 tmp                                                                           \
00660 <                                                                             \
00661     GeometricField<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
00662 >                                                                             \
00663 operator op                                                                   \
00664 (                                                                             \
00665     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00666     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00667 )                                                                             \
00668 {                                                                             \
00669     typedef typename product<Type1, Type2>::type productType;                 \
00670                                                                               \
00671     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
00672                                                                               \
00673     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes =             \
00674         reuseTmpGeometricField<productType, Type1, PatchField, GeoMesh>::New  \
00675         (                                                                     \
00676             tgf1,                                                             \
00677             '(' + gf1.name() + #op + gf2.name() + ')',                        \
00678             gf1.dimensions() op gf2.dimensions()                              \
00679         );                                                                    \
00680                                                                               \
00681     Foam::opFunc(tRes(), gf1, gf2);                                           \
00682                                                                               \
00683     reuseTmpGeometricField<productType, Type1, PatchField, GeoMesh>           \
00684     ::clear(tgf1);                                                            \
00685                                                                               \
00686     return tRes;                                                              \
00687 }                                                                             \
00688                                                                               \
00689 template                                                                      \
00690 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00691 tmp                                                                           \
00692 <                                                                             \
00693     GeometricField<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
00694 >                                                                             \
00695 operator op                                                                   \
00696 (                                                                             \
00697     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00698     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00699 )                                                                             \
00700 {                                                                             \
00701     typedef typename product<Type1, Type2>::type productType;                 \
00702                                                                               \
00703     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
00704     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
00705                                                                               \
00706     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes =             \
00707         reuseTmpTmpGeometricField                                             \
00708         <productType, Type1, Type1, Type2, PatchField, GeoMesh>::New          \
00709         (                                                                     \
00710             tgf1,                                                             \
00711             tgf2,                                                             \
00712             '(' + gf1.name() + #op + gf2.name() + ')',                        \
00713             gf1.dimensions() op gf2.dimensions()                              \
00714         );                                                                    \
00715                                                                               \
00716     Foam::opFunc(tRes(), gf1, gf2);                                           \
00717                                                                               \
00718     reuseTmpTmpGeometricField                                                 \
00719         <productType, Type1, Type1, Type2, PatchField, GeoMesh>               \
00720     ::clear(tgf1, tgf2);                                                      \
00721                                                                               \
00722     return tRes;                                                              \
00723 }                                                                             \
00724                                                                               \
00725 template                                                                      \
00726 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00727 void opFunc                                                                   \
00728 (                                                                             \
00729     GeometricField                                                            \
00730     <typename product<Type, Form>::type, PatchField, GeoMesh>& gf,            \
00731     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
00732     const dimensioned<Form>& dvs                                              \
00733 )                                                                             \
00734 {                                                                             \
00735     Foam::opFunc(gf.internalField(), gf1.internalField(), dvs.value());       \
00736     Foam::opFunc(gf.boundaryField(), gf1.boundaryField(), dvs.value());       \
00737 }                                                                             \
00738                                                                               \
00739 template                                                                      \
00740 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00741 tmp<GeometricField<typename product<Type, Form>::type, PatchField, GeoMesh> > \
00742 operator op                                                                   \
00743 (                                                                             \
00744     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
00745     const dimensioned<Form>& dvs                                              \
00746 )                                                                             \
00747 {                                                                             \
00748     typedef typename product<Type, Form>::type productType;                   \
00749                                                                               \
00750     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes               \
00751     (                                                                         \
00752         new GeometricField<productType, PatchField, GeoMesh>                  \
00753         (                                                                     \
00754             IOobject                                                          \
00755             (                                                                 \
00756                 '(' + gf1.name() + #op + dvs.name() + ')',                    \
00757                 gf1.instance(),                                               \
00758                 gf1.db(),                                                     \
00759                 IOobject::NO_READ,                                            \
00760                 IOobject::NO_WRITE                                            \
00761             ),                                                                \
00762             gf1.mesh(),                                                       \
00763             gf1.dimensions() op dvs.dimensions()                              \
00764         )                                                                     \
00765     );                                                                        \
00766                                                                               \
00767     Foam::opFunc(tRes(), gf1, dvs);                                           \
00768                                                                               \
00769     return tRes;                                                              \
00770 }                                                                             \
00771                                                                               \
00772 template                                                                      \
00773 <                                                                             \
00774     class Form,                                                               \
00775     class Cmpt,                                                               \
00776     int nCmpt,                                                                \
00777     class Type, template<class> class PatchField,                             \
00778     class GeoMesh                                                             \
00779 >                                                                             \
00780 tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh> > \
00781 operator op                                                                   \
00782 (                                                                             \
00783     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
00784     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00785 )                                                                             \
00786 {                                                                             \
00787     return gf1 op dimensioned<Form>(static_cast<const Form&>(vs));            \
00788 }                                                                             \
00789                                                                               \
00790                                                                               \
00791 template                                                                      \
00792 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00793 tmp<GeometricField<typename product<Type, Form>::type, PatchField, GeoMesh> > \
00794 operator op                                                                   \
00795 (                                                                             \
00796     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1,              \
00797     const dimensioned<Form>& dvs                                              \
00798 )                                                                             \
00799 {                                                                             \
00800     typedef typename product<Type, Form>::type productType;                   \
00801                                                                               \
00802     const GeometricField<Type, PatchField, GeoMesh>& gf1 = tgf1();            \
00803                                                                               \
00804     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes =             \
00805         reuseTmpGeometricField<productType, Type, PatchField, GeoMesh>::New   \
00806         (                                                                     \
00807             tgf1,                                                             \
00808             '(' + gf1.name() + #op + dvs.name() + ')',                        \
00809             gf1.dimensions() op dvs.dimensions()                              \
00810         );                                                                    \
00811                                                                               \
00812     Foam::opFunc(tRes(), gf1, dvs);                                           \
00813                                                                               \
00814     reuseTmpGeometricField<productType, Type, PatchField, GeoMesh>            \
00815     ::clear(tgf1);                                                            \
00816                                                                               \
00817     return tRes;                                                              \
00818 }                                                                             \
00819                                                                               \
00820 template                                                                      \
00821 <                                                                             \
00822     class Form,                                                               \
00823     class Cmpt,                                                               \
00824     int nCmpt,                                                                \
00825     class Type, template<class> class PatchField,                             \
00826     class GeoMesh                                                             \
00827 >                                                                             \
00828 tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh> > \
00829 operator op                                                                   \
00830 (                                                                             \
00831     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1,              \
00832     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00833 )                                                                             \
00834 {                                                                             \
00835     return tgf1 op dimensioned<Form>(static_cast<const Form&>(vs));           \
00836 }                                                                             \
00837                                                                               \
00838                                                                               \
00839 template                                                                      \
00840 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00841 void opFunc                                                                   \
00842 (                                                                             \
00843     GeometricField                                                            \
00844     <typename product<Form, Type>::type, PatchField, GeoMesh>& gf,            \
00845     const dimensioned<Form>& dvs,                                             \
00846     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
00847 )                                                                             \
00848 {                                                                             \
00849     Foam::opFunc(gf.internalField(), dvs.value(), gf1.internalField());       \
00850     Foam::opFunc(gf.boundaryField(), dvs.value(), gf1.boundaryField());       \
00851 }                                                                             \
00852                                                                               \
00853 template                                                                      \
00854 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00855 tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh> > \
00856 operator op                                                                   \
00857 (                                                                             \
00858     const dimensioned<Form>& dvs,                                             \
00859     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
00860 )                                                                             \
00861 {                                                                             \
00862     typedef typename product<Form, Type>::type productType;                   \
00863     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes               \
00864     (                                                                         \
00865         new GeometricField<productType, PatchField, GeoMesh>                  \
00866         (                                                                     \
00867             IOobject                                                          \
00868             (                                                                 \
00869                 '(' + dvs.name() + #op + gf1.name() + ')',                    \
00870                 gf1.instance(),                                               \
00871                 gf1.db(),                                                     \
00872                 IOobject::NO_READ,                                            \
00873                 IOobject::NO_WRITE                                            \
00874             ),                                                                \
00875             gf1.mesh(),                                                       \
00876             dvs.dimensions() op gf1.dimensions()                              \
00877         )                                                                     \
00878     );                                                                        \
00879                                                                               \
00880     Foam::opFunc(tRes(), dvs, gf1);                                           \
00881                                                                               \
00882     return tRes;                                                              \
00883 }                                                                             \
00884                                                                               \
00885 template                                                                      \
00886 <                                                                             \
00887     class Form,                                                               \
00888     class Cmpt,                                                               \
00889     int nCmpt,                                                                \
00890     class Type, template<class> class PatchField,                             \
00891     class GeoMesh                                                             \
00892 >                                                                             \
00893 tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh> > \
00894 operator op                                                                   \
00895 (                                                                             \
00896     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00897     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
00898 )                                                                             \
00899 {                                                                             \
00900     return dimensioned<Form>(static_cast<const Form&>(vs)) op gf1;            \
00901 }                                                                             \
00902                                                                               \
00903 template                                                                      \
00904 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00905 tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh> > \
00906 operator op                                                                   \
00907 (                                                                             \
00908     const dimensioned<Form>& dvs,                                             \
00909     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
00910 )                                                                             \
00911 {                                                                             \
00912     typedef typename product<Form, Type>::type productType;                   \
00913                                                                               \
00914     const GeometricField<Type, PatchField, GeoMesh>& gf1 = tgf1();            \
00915                                                                               \
00916     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes =             \
00917         reuseTmpGeometricField<productType, Type, PatchField, GeoMesh>::New   \
00918         (                                                                     \
00919             tgf1,                                                             \
00920             '(' + dvs.name() + #op + gf1.name() + ')',                        \
00921             dvs.dimensions() op gf1.dimensions()                              \
00922         );                                                                    \
00923                                                                               \
00924     Foam::opFunc(tRes(), dvs, gf1);                                           \
00925                                                                               \
00926     reuseTmpGeometricField<productType, Type, PatchField, GeoMesh>            \
00927     ::clear(tgf1);                                                            \
00928                                                                               \
00929     return tRes;                                                              \
00930 }                                                                             \
00931                                                                               \
00932 template                                                                      \
00933 <                                                                             \
00934     class Form,                                                               \
00935     class Cmpt,                                                               \
00936     int nCmpt,                                                                \
00937     class Type, template<class> class PatchField,                             \
00938     class GeoMesh                                                             \
00939 >                                                                             \
00940 tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh> > \
00941 operator op                                                                   \
00942 (                                                                             \
00943     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00944     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
00945 )                                                                             \
00946 {                                                                             \
00947     return dimensioned<Form>(static_cast<const Form&>(vs)) op tgf1;           \
00948 }
00949 
00950 PRODUCT_OPERATOR(typeOfSum, +, add)
00951 PRODUCT_OPERATOR(typeOfSum, -, subtract)
00952 
00953 PRODUCT_OPERATOR(outerProduct, *, outer)
00954 PRODUCT_OPERATOR(crossProduct, ^, cross)
00955 PRODUCT_OPERATOR(innerProduct, &, dot)
00956 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
00957 
00958 #undef PRODUCT_OPERATOR
00959 
00960 
00961 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00962 
00963 } // End namespace Foam
00964 
00965 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00966 
00967 #include <OpenFOAM/undefFieldFunctionsM.H>
00968 
00969 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines