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

GeometricFieldFunctions.H

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 "GeometricScalarField.H"
00028 
00029 #define TEMPLATE \
00030     template<class Type, template<class> class PatchField, class GeoMesh>
00031 #include "GeometricFieldFunctionsM.H"
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 template<class Type, template<class> class PatchField, class GeoMesh>
00054 void T
00055 (
00056      GeometricField<Type, PatchField, GeoMesh>& gf,
00057      const GeometricField<Type, PatchField, GeoMesh>& gf1
00058 );
00059 
00060 template<class Type, template<class> class PatchField, class GeoMesh, int r>
00061 void pow
00062 (
00063     GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>& gf,
00064     const GeometricField<Type, PatchField, GeoMesh>& gf1
00065 );
00066 
00067 template<class Type, template<class> class PatchField, class GeoMesh, int r>
00068 tmp
00069 <
00070     GeometricField
00071     <typename powProduct<Type, r>::type, PatchField, GeoMesh>
00072 >
00073 pow
00074 (
00075     const GeometricField<Type, PatchField, GeoMesh>& gf,
00076     typename powProduct<Type, r>::type
00077 );
00078 
00079 template<class Type, template<class> class PatchField, class GeoMesh, int r>
00080 tmp
00081 <
00082     GeometricField
00083     <typename powProduct<Type, r>::type, PatchField, GeoMesh>
00084 >
00085 pow
00086 (
00087     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf,
00088     typename powProduct<Type, r>::type
00089 );
00090 
00091 template<class Type, template<class> class PatchField, class GeoMesh>
00092 void sqr
00093 (
00094     GeometricField
00095     <typename outerProduct<Type, Type>::type, PatchField, GeoMesh>& gf,
00096     const GeometricField<Type, PatchField, GeoMesh>& gf1
00097 );
00098 
00099 template<class Type, template<class> class PatchField, class GeoMesh>
00100 tmp
00101 <
00102     GeometricField
00103     <
00104         typename outerProduct<Type, Type>::type,
00105         PatchField,
00106         GeoMesh
00107     >
00108 >
00109 sqr(const GeometricField<Type, PatchField, GeoMesh>& gf);
00110 
00111 template<class Type, template<class> class PatchField, class GeoMesh>
00112 tmp
00113 <
00114     GeometricField
00115     <
00116         typename outerProduct<Type, Type>::type,
00117         PatchField,
00118         GeoMesh
00119     >
00120 >
00121 sqr(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf);
00122 
00123 template<class Type, template<class> class PatchField, class GeoMesh>
00124 void magSqr
00125 (
00126     GeometricField<scalar, PatchField, GeoMesh>& gsf,
00127     const GeometricField<Type, PatchField, GeoMesh>& gf
00128 );
00129 
00130 template<class Type, template<class> class PatchField, class GeoMesh>
00131 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
00132 (
00133     const GeometricField<Type, PatchField, GeoMesh>& gf
00134 );
00135 
00136 template<class Type, template<class> class PatchField, class GeoMesh>
00137 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
00138 (
00139     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
00140 );
00141 
00142 template<class Type, template<class> class PatchField, class GeoMesh>
00143 void mag
00144 (
00145     GeometricField<scalar, PatchField, GeoMesh>& gsf,
00146     const GeometricField<Type, PatchField, GeoMesh>& gf
00147 );
00148 
00149 template<class Type, template<class> class PatchField, class GeoMesh>
00150 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
00151 (
00152     const GeometricField<Type, PatchField, GeoMesh>& gf
00153 );
00154 
00155 template<class Type, template<class> class PatchField, class GeoMesh>
00156 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
00157 (
00158     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
00159 );
00160 
00161 template<class Type, template<class> class PatchField, class GeoMesh>
00162 void cmptAv
00163 (
00164     GeometricField
00165     <
00166         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
00167         PatchField,
00168         GeoMesh
00169     >& gcf,
00170     const GeometricField<Type, PatchField, GeoMesh>& gf
00171 );
00172 
00173 template<class Type, template<class> class PatchField, class GeoMesh>
00174 tmp
00175 <
00176     GeometricField
00177     <
00178         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
00179         PatchField,
00180         GeoMesh
00181     >
00182 >
00183 cmptAv(const GeometricField<Type, PatchField, GeoMesh>& gf);
00184 
00185 template<class Type, template<class> class PatchField, class GeoMesh>
00186 tmp
00187 <
00188     GeometricField
00189     <
00190         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
00191         PatchField,
00192         GeoMesh
00193     >
00194 >
00195 cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf);
00196 
00197 
00198 #define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc)       \
00199                                                                               \
00200 template<class Type, template<class> class PatchField, class GeoMesh>         \
00201 dimensioned<returnType> func                                                  \
00202 (                                                                             \
00203     const GeometricField<Type, PatchField, GeoMesh>& gf                       \
00204 );                                                                            \
00205                                                                               \
00206 template<class Type, template<class> class PatchField, class GeoMesh>         \
00207 dimensioned<returnType> func                                                  \
00208 (                                                                             \
00209     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
00210 );
00211 
00212 UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, max, gMax)
00213 UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, min, gMin)
00214 
00215 #undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
00216 
00217 
00218 #define UNARY_REDUCTION_FUNCTION(returnType, func, gFunc)                     \
00219                                                                               \
00220 template<class Type, template<class> class PatchField, class GeoMesh>         \
00221 dimensioned<returnType> func                                                  \
00222 (                                                                             \
00223     const GeometricField<Type, PatchField, GeoMesh>& gf                       \
00224 );                                                                            \
00225                                                                               \
00226 template<class Type, template<class> class PatchField, class GeoMesh>         \
00227 dimensioned<returnType> func                                                  \
00228 (                                                                             \
00229     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
00230 );
00231 
00232 UNARY_REDUCTION_FUNCTION(Type, sum, gSum)
00233 UNARY_REDUCTION_FUNCTION(scalar, sumMag, gSumMag)
00234 UNARY_REDUCTION_FUNCTION(Type, average, gAverage)
00235 
00236 #undef UNARY_REDUCTION_FUNCTION
00237 
00238 
00239 BINARY_FUNCTION(Type, Type, Type, max)
00240 BINARY_FUNCTION(Type, Type, Type, min)
00241 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
00242 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
00243 
00244 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
00245 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
00246 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
00247 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
00248 
00249 
00250 // * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * //
00251 
00252 UNARY_OPERATOR(Type, Type, -, negate, transform)
00253 
00254 #ifndef __INTEL_COMPILER
00255 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
00256 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
00257 #endif
00258 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
00259 
00260 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
00261 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
00262 
00263 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
00264 
00265 
00266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00267 
00268 #define PRODUCT_OPERATOR(product, op, opFunc)                                 \
00269                                                                               \
00270 template                                                                      \
00271 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00272 void opFunc                                                                   \
00273 (                                                                             \
00274     GeometricField                                                            \
00275     <typename product<Type1, Type2>::type, PatchField, GeoMesh>& gf,          \
00276     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00277     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00278 );                                                                            \
00279                                                                               \
00280 template                                                                      \
00281 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00282 tmp                                                                           \
00283 <                                                                             \
00284     GeometricField                                                            \
00285         <typename product<Type1, Type2>::type, PatchField, GeoMesh>           \
00286 >                                                                             \
00287 operator op                                                                   \
00288 (                                                                             \
00289     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00290     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00291 );                                                                            \
00292                                                                               \
00293 template                                                                      \
00294 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00295 tmp                                                                           \
00296 <                                                                             \
00297     GeometricField                                                            \
00298     <typename product<Type1, Type2>::type, PatchField, GeoMesh>               \
00299 >                                                                             \
00300 operator op                                                                   \
00301 (                                                                             \
00302     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00303     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00304 );                                                                            \
00305                                                                               \
00306 template                                                                      \
00307 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00308 tmp                                                                           \
00309 <                                                                             \
00310     GeometricField                                                            \
00311     <typename product<Type1, Type2>::type, PatchField, GeoMesh>               \
00312 >                                                                             \
00313 operator op                                                                   \
00314 (                                                                             \
00315     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00316     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00317 );                                                                            \
00318                                                                               \
00319 template                                                                      \
00320 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00321 tmp                                                                           \
00322 <                                                                             \
00323     GeometricField                                                            \
00324     <typename product<Type1, Type2>::type, PatchField, GeoMesh>               \
00325 >                                                                             \
00326 operator op                                                                   \
00327 (                                                                             \
00328     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00329     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00330 );                                                                            \
00331                                                                               \
00332 template                                                                      \
00333 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00334 void opFunc                                                                   \
00335 (                                                                             \
00336     GeometricField                                                            \
00337     <typename product<Type, Form>::type, PatchField, GeoMesh>& gf,            \
00338     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
00339     const dimensioned<Form>& dvs                                              \
00340 );                                                                            \
00341                                                                               \
00342 template                                                                      \
00343 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00344 tmp                                                                           \
00345 <                                                                             \
00346     GeometricField                                                            \
00347     <typename product<Type, Form>::type, PatchField, GeoMesh>                 \
00348 >                                                                             \
00349 operator op                                                                   \
00350 (                                                                             \
00351     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
00352     const dimensioned<Form>& dvs                                              \
00353 );                                                                            \
00354                                                                               \
00355 template                                                                      \
00356 <                                                                             \
00357     class Form,                                                               \
00358     class Cmpt,                                                               \
00359     int nCmpt,                                                                \
00360     class Type, template<class> class PatchField,                             \
00361     class GeoMesh                                                             \
00362 >                                                                             \
00363 tmp                                                                           \
00364 <                                                                             \
00365     GeometricField                                                            \
00366     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
00367 >                                                                             \
00368 operator op                                                                   \
00369 (                                                                             \
00370     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
00371     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00372 );                                                                            \
00373                                                                               \
00374 template                                                                      \
00375 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00376 tmp                                                                           \
00377 <                                                                             \
00378     GeometricField                                                            \
00379     <typename product<Type, Form>::type, PatchField, GeoMesh>                 \
00380 >                                                                             \
00381 operator op                                                                   \
00382 (                                                                             \
00383     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1,              \
00384     const dimensioned<Form>& dvs                                              \
00385 );                                                                            \
00386                                                                               \
00387 template                                                                      \
00388 <                                                                             \
00389     class Form,                                                               \
00390     class Cmpt,                                                               \
00391     int nCmpt,                                                                \
00392     class Type, template<class> class PatchField,                             \
00393     class GeoMesh                                                             \
00394 >                                                                             \
00395 tmp                                                                           \
00396 <                                                                             \
00397     GeometricField                                                            \
00398     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
00399 >                                                                             \
00400 operator op                                                                   \
00401 (                                                                             \
00402     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1,              \
00403     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00404 );                                                                            \
00405                                                                               \
00406 template                                                                      \
00407 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00408 void opFunc                                                                   \
00409 (                                                                             \
00410     GeometricField                                                            \
00411     <typename product<Form, Type>::type, PatchField, GeoMesh>& gf,            \
00412     const dimensioned<Form>& dvs,                                             \
00413     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
00414 );                                                                            \
00415                                                                               \
00416 template                                                                      \
00417 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00418 tmp                                                                           \
00419 <                                                                             \
00420     GeometricField                                                            \
00421     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
00422 >                                                                             \
00423 operator op                                                                   \
00424 (                                                                             \
00425     const dimensioned<Form>& dvs,                                             \
00426     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
00427 );                                                                            \
00428                                                                               \
00429 template                                                                      \
00430 <                                                                             \
00431     class Form,                                                               \
00432     class Cmpt,                                                               \
00433     int nCmpt,                                                                \
00434     class Type, template<class> class PatchField,                             \
00435     class GeoMesh                                                             \
00436 >                                                                             \
00437 tmp                                                                           \
00438 <                                                                             \
00439     GeometricField                                                            \
00440     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
00441 >                                                                             \
00442 operator op                                                                   \
00443 (                                                                             \
00444     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00445     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
00446 );                                                                            \
00447                                                                               \
00448 template                                                                      \
00449 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00450 tmp                                                                           \
00451 <                                                                             \
00452     GeometricField                                                            \
00453     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
00454 >                                                                             \
00455 operator op                                                                   \
00456 (                                                                             \
00457     const dimensioned<Form>& dvs,                                             \
00458     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
00459 );                                                                            \
00460                                                                               \
00461 template                                                                      \
00462 <                                                                             \
00463     class Form,                                                               \
00464     class Cmpt,                                                               \
00465     int nCmpt,                                                                \
00466     class Type, template<class> class PatchField,                             \
00467     class GeoMesh                                                             \
00468 >                                                                             \
00469 tmp                                                                           \
00470 <                                                                             \
00471     GeometricField                                                            \
00472     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
00473 >                                                                             \
00474 operator op                                                                   \
00475 (                                                                             \
00476     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00477     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
00478 );
00479 
00480 PRODUCT_OPERATOR(typeOfSum, +, add)
00481 PRODUCT_OPERATOR(typeOfSum, -, subtract)
00482 
00483 PRODUCT_OPERATOR(outerProduct, *, outer)
00484 PRODUCT_OPERATOR(crossProduct, ^, cross)
00485 PRODUCT_OPERATOR(innerProduct, &, dot)
00486 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
00487 
00488 #undef PRODUCT_OPERATOR
00489 
00490 
00491 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00492 
00493 } // End namespace Foam
00494 
00495 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00496 
00497 #include "undefFieldFunctionsM.H"
00498 
00499 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd