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

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