OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen 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-2007 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, scale)
00242 
00243 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
00244 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
00245 BINARY_TYPE_FUNCTION(Type, Type, Type, scale)
00246 
00247 
00248 // * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * //
00249 
00250 UNARY_OPERATOR(Type, Type, -, negate, transform)
00251 
00252 #ifndef __INTEL_COMPILER
00253 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
00254 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
00255 #endif
00256 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
00257 
00258 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
00259 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
00260 
00261 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
00262 
00263 
00264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00265 
00266 #define PRODUCT_OPERATOR(product, op, opFunc)                                 \
00267                                                                               \
00268 template                                                                      \
00269 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00270 void opFunc                                                                   \
00271 (                                                                             \
00272     GeometricField                                                            \
00273     <typename product<Type1, Type2>::type, PatchField, GeoMesh>& gf,          \
00274     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00275     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00276 );                                                                            \
00277                                                                               \
00278 template                                                                      \
00279 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00280 tmp                                                                           \
00281 <                                                                             \
00282     GeometricField                                                            \
00283         <typename product<Type1, Type2>::type, PatchField, GeoMesh>           \
00284 >                                                                             \
00285 operator op                                                                   \
00286 (                                                                             \
00287     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00288     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00289 );                                                                            \
00290                                                                               \
00291 template                                                                      \
00292 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00293 tmp                                                                           \
00294 <                                                                             \
00295     GeometricField                                                            \
00296     <typename product<Type1, Type2>::type, PatchField, GeoMesh>               \
00297 >                                                                             \
00298 operator op                                                                   \
00299 (                                                                             \
00300     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
00301     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00302 );                                                                            \
00303                                                                               \
00304 template                                                                      \
00305 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00306 tmp                                                                           \
00307 <                                                                             \
00308     GeometricField                                                            \
00309     <typename product<Type1, Type2>::type, PatchField, GeoMesh>               \
00310 >                                                                             \
00311 operator op                                                                   \
00312 (                                                                             \
00313     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00314     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
00315 );                                                                            \
00316                                                                               \
00317 template                                                                      \
00318 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
00319 tmp                                                                           \
00320 <                                                                             \
00321     GeometricField                                                            \
00322     <typename product<Type1, Type2>::type, PatchField, GeoMesh>               \
00323 >                                                                             \
00324 operator op                                                                   \
00325 (                                                                             \
00326     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
00327     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
00328 );                                                                            \
00329                                                                               \
00330 template                                                                      \
00331 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00332 void opFunc                                                                   \
00333 (                                                                             \
00334     GeometricField                                                            \
00335     <typename product<Type, Form>::type, PatchField, GeoMesh>& gf,            \
00336     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
00337     const dimensioned<Form>& dvs                                              \
00338 );                                                                            \
00339                                                                               \
00340 template                                                                      \
00341 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00342 tmp                                                                           \
00343 <                                                                             \
00344     GeometricField                                                            \
00345     <typename product<Type, Form>::type, PatchField, GeoMesh>                 \
00346 >                                                                             \
00347 operator op                                                                   \
00348 (                                                                             \
00349     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
00350     const dimensioned<Form>& dvs                                              \
00351 );                                                                            \
00352                                                                               \
00353 template                                                                      \
00354 <                                                                             \
00355     class Form,                                                               \
00356     class Cmpt,                                                               \
00357     int nCmpt,                                                                \
00358     class Type, template<class> class PatchField,                             \
00359     class GeoMesh                                                             \
00360 >                                                                             \
00361 tmp                                                                           \
00362 <                                                                             \
00363     GeometricField                                                            \
00364     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
00365 >                                                                             \
00366 operator op                                                                   \
00367 (                                                                             \
00368     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
00369     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00370 );                                                                            \
00371                                                                               \
00372 template                                                                      \
00373 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00374 tmp                                                                           \
00375 <                                                                             \
00376     GeometricField                                                            \
00377     <typename product<Type, Form>::type, PatchField, GeoMesh>                 \
00378 >                                                                             \
00379 operator op                                                                   \
00380 (                                                                             \
00381     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1,              \
00382     const dimensioned<Form>& dvs                                              \
00383 );                                                                            \
00384                                                                               \
00385 template                                                                      \
00386 <                                                                             \
00387     class Form,                                                               \
00388     class Cmpt,                                                               \
00389     int nCmpt,                                                                \
00390     class Type, template<class> class PatchField,                             \
00391     class GeoMesh                                                             \
00392 >                                                                             \
00393 tmp                                                                           \
00394 <                                                                             \
00395     GeometricField                                                            \
00396     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
00397 >                                                                             \
00398 operator op                                                                   \
00399 (                                                                             \
00400     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1,              \
00401     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00402 );                                                                            \
00403                                                                               \
00404 template                                                                      \
00405 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00406 void opFunc                                                                   \
00407 (                                                                             \
00408     GeometricField                                                            \
00409     <typename product<Form, Type>::type, PatchField, GeoMesh>& gf,            \
00410     const dimensioned<Form>& dvs,                                             \
00411     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
00412 );                                                                            \
00413                                                                               \
00414 template                                                                      \
00415 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00416 tmp                                                                           \
00417 <                                                                             \
00418     GeometricField                                                            \
00419     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
00420 >                                                                             \
00421 operator op                                                                   \
00422 (                                                                             \
00423     const dimensioned<Form>& dvs,                                             \
00424     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
00425 );                                                                            \
00426                                                                               \
00427 template                                                                      \
00428 <                                                                             \
00429     class Form,                                                               \
00430     class Cmpt,                                                               \
00431     int nCmpt,                                                                \
00432     class Type, template<class> class PatchField,                             \
00433     class GeoMesh                                                             \
00434 >                                                                             \
00435 tmp                                                                           \
00436 <                                                                             \
00437     GeometricField                                                            \
00438     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
00439 >                                                                             \
00440 operator op                                                                   \
00441 (                                                                             \
00442     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00443     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
00444 );                                                                            \
00445                                                                               \
00446 template                                                                      \
00447 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
00448 tmp                                                                           \
00449 <                                                                             \
00450     GeometricField                                                            \
00451     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
00452 >                                                                             \
00453 operator op                                                                   \
00454 (                                                                             \
00455     const dimensioned<Form>& dvs,                                             \
00456     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
00457 );                                                                            \
00458                                                                               \
00459 template                                                                      \
00460 <                                                                             \
00461     class Form,                                                               \
00462     class Cmpt,                                                               \
00463     int nCmpt,                                                                \
00464     class Type, template<class> class PatchField,                             \
00465     class GeoMesh                                                             \
00466 >                                                                             \
00467 tmp                                                                           \
00468 <                                                                             \
00469     GeometricField                                                            \
00470     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
00471 >                                                                             \
00472 operator op                                                                   \
00473 (                                                                             \
00474     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00475     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
00476 );
00477 
00478 PRODUCT_OPERATOR(typeOfSum, +, add)
00479 PRODUCT_OPERATOR(typeOfSum, -, subtract)
00480 
00481 PRODUCT_OPERATOR(outerProduct, *, outer)
00482 PRODUCT_OPERATOR(crossProduct, ^, cross)
00483 PRODUCT_OPERATOR(innerProduct, &, dot)
00484 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
00485 
00486 #undef PRODUCT_OPERATOR
00487 
00488 
00489 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00490 
00491 } // End namespace Foam
00492 
00493 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00494 
00495 #include "undefFieldFunctionsM.H"
00496 
00497 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd