OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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