OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

FieldFieldFunctions.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 "scalarFieldField.H"
00028 
00029 #define TEMPLATE template<template<class> class Field, class Type>
00030 #include "FieldFieldFunctionsM.H"
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 /* * * * * * * * * * * * * * * * Global functions  * * * * * * * * * * * * * */
00038 
00039 template<template<class> class Field, class Type>
00040 void component
00041 (
00042     FieldField<Field, typename FieldField<Field, Type>::cmptType>& sf,
00043     const FieldField<Field, Type>& f,
00044     const direction d
00045 );
00046 
00047 template<template<class> class Field, class Type>
00048 void T(FieldField<Field, Type>& f1, const FieldField<Field, Type>& f2);
00049 
00050 
00051 template<template<class> class Field, class Type, int r>
00052 void pow
00053 (
00054     FieldField<Field, typename powProduct<Type, r>::type>& f,
00055     const FieldField<Field, Type>& vf
00056 );
00057 
00058 template<template<class> class Field, class Type, int r>
00059 tmp<FieldField<Field, typename powProduct<Type, r>::type> >
00060 pow
00061 (
00062     const FieldField<Field, Type>& f, typename powProduct<Type, r>::type
00063         = pTraits<typename powProduct<Type, r>::type>::zero
00064 );
00065 
00066 template<template<class> class Field, class Type, int r>
00067 tmp<FieldField<Field, typename powProduct<Type, r>::type> >
00068 pow
00069 (
00070     const tmp<FieldField<Field, Type> >& tf, typename powProduct<Type, r>::type
00071         = pTraits<typename powProduct<Type, r>::type>::zero
00072 );
00073 
00074 
00075 template<template<class> class Field, class Type>
00076 void sqr
00077 (
00078     FieldField<Field, typename outerProduct<Type, Type>::type>& f,
00079     const FieldField<Field, Type>& vf
00080 );
00081 
00082 template<template<class> class Field, class Type>
00083 tmp<FieldField<Field, typename outerProduct<Type, Type>::type> >
00084 sqr(const FieldField<Field, Type>& f);
00085 
00086 template<template<class> class Field, class Type>
00087 tmp<FieldField<Field, typename outerProduct<Type, Type>::type> >
00088 sqr(const tmp<FieldField<Field, Type> >& tf);
00089 
00090 template<template<class> class Field, class Type>
00091 void magSqr(FieldField<Field, scalar>& sf, const FieldField<Field, Type>& f);
00092 
00093 template<template<class> class Field, class Type>
00094 tmp<FieldField<Field, scalar> > magSqr(const FieldField<Field, Type>& f);
00095 
00096 template<template<class> class Field, class Type>
00097 tmp<FieldField<Field, scalar> > magSqr(const tmp<FieldField<Field, Type> >& tf);
00098 
00099 template<template<class> class Field, class Type>
00100 void mag(FieldField<Field, scalar>& sf, const FieldField<Field, Type>& f);
00101 
00102 template<template<class> class Field, class Type>
00103 tmp<FieldField<Field, scalar> > mag(const FieldField<Field, Type>& f);
00104 
00105 template<template<class> class Field, class Type>
00106 tmp<FieldField<Field, scalar> > mag(const tmp<FieldField<Field, Type> >& tf);
00107 
00108 
00109 template<template<class> class Field, class Type>
00110 void cmptMax
00111 (
00112     FieldField<Field, typename FieldField<Field, Type>::cmptType>& cf,
00113     const FieldField<Field, Type>& f
00114 );
00115 
00116 template<template<class> class Field, class Type>
00117 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMax
00118 (
00119     const FieldField<Field, Type>& f
00120 );
00121 
00122 template<template<class> class Field, class Type>
00123 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMax
00124 (
00125     const tmp<FieldField<Field, Type> >& tf
00126 );
00127 
00128 
00129 template<template<class> class Field, class Type>
00130 void cmptMin
00131 (
00132     FieldField<Field, typename FieldField<Field, Type>::cmptType>& cf,
00133     const FieldField<Field, Type>& f
00134 );
00135 
00136 template<template<class> class Field, class Type>
00137 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMin
00138 (
00139     const FieldField<Field, Type>& f
00140 );
00141 
00142 template<template<class> class Field, class Type>
00143 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMin
00144 (
00145     const tmp<FieldField<Field, Type> >& tf
00146 );
00147 
00148 
00149 template<template<class> class Field, class Type>
00150 void cmptAv
00151 (
00152     FieldField<Field, typename FieldField<Field, Type>::cmptType>& cf,
00153     const FieldField<Field, Type>& f
00154 );
00155 
00156 template<template<class> class Field, class Type>
00157 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptAv
00158 (
00159     const FieldField<Field, Type>& f
00160 );
00161 
00162 template<template<class> class Field, class Type>
00163 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptAv
00164 (
00165     const tmp<FieldField<Field, Type> >& tf
00166 );
00167 
00168 
00169 template<template<class> class Field, class Type>
00170 void cmptMag
00171 (
00172     FieldField<Field, Type>& cf,
00173     const FieldField<Field, Type>& f
00174 );
00175 
00176 template<template<class> class Field, class Type>
00177 tmp<FieldField<Field, Type> > cmptMag
00178 (
00179     const FieldField<Field, Type>& f
00180 );
00181 
00182 template<template<class> class Field, class Type>
00183 tmp<FieldField<Field, Type> > cmptMag
00184 (
00185     const tmp<FieldField<Field, Type> >& tf
00186 );
00187 
00188 
00189 #define TMP_UNARY_FUNCTION(returnType, func)                                  \
00190                                                                               \
00191 template<template<class> class Field, class Type>                             \
00192 returnType func(const tmp<FieldField<Field, Type> >& tf1);
00193 
00194 template<template<class> class Field, class Type>
00195 Type max(const FieldField<Field, Type>& f);
00196 
00197 TMP_UNARY_FUNCTION(Type, max)
00198 
00199 template<template<class> class Field, class Type>
00200 Type min(const FieldField<Field, Type>& f);
00201 
00202 TMP_UNARY_FUNCTION(Type, min)
00203 
00204 template<template<class> class Field, class Type>
00205 Type sum(const FieldField<Field, Type>& f);
00206 
00207 TMP_UNARY_FUNCTION(Type, sum)
00208 
00209 template<template<class> class Field, class Type>
00210 scalar sumMag(const FieldField<Field, Type>& f);
00211 
00212 TMP_UNARY_FUNCTION(scalar, sumMag)
00213 
00214 template<template<class> class Field, class Type>
00215 Type average(const FieldField<Field, Type>& f);
00216 
00217 TMP_UNARY_FUNCTION(Type, average)
00218 
00219 
00220 #define G_UNARY_FUNCTION(returnType, gFunc, func, rFunc)                      \
00221                                                                               \
00222 template<template<class> class Field, class Type>                             \
00223 returnType gFunc(const FieldField<Field, Type>& f);                           \
00224 TMP_UNARY_FUNCTION(returnType, gFunc)
00225 
00226 G_UNARY_FUNCTION(Type, gMax, max, max)
00227 G_UNARY_FUNCTION(Type, gMin, min, min)
00228 G_UNARY_FUNCTION(Type, gSum, sum, sum)
00229 G_UNARY_FUNCTION(scalar, gSumMag, sumMag, sum)
00230 
00231 #undef G_UNARY_FUNCTION
00232 
00233 
00234 template<template<class> class Field, class Type>
00235 Type gAverage(const FieldField<Field, Type>& f);
00236 
00237 TMP_UNARY_FUNCTION(Type, gAverage)
00238 
00239 #undef TMP_UNARY_FUNCTION
00240 
00241 
00242 BINARY_FUNCTION(Type, Type, Type, max)
00243 BINARY_FUNCTION(Type, Type, Type, min)
00244 BINARY_FUNCTION(Type, Type, Type, scale)
00245 
00246 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
00247 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
00248 BINARY_TYPE_FUNCTION(Type, Type, Type, scale)
00249 
00250 
00251 /* * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * */
00252 
00253 UNARY_OPERATOR(Type, Type, -, negate)
00254 
00255 #ifndef __INTEL_COMPILER
00256 BINARY_OPERATOR(Type, Type, scalar, *, multiply)
00257 BINARY_OPERATOR(Type, scalar, Type, *, multiply)
00258 #endif
00259 BINARY_OPERATOR(Type, Type, scalar, /, divide)
00260 
00261 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, multiply)
00262 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, multiply)
00263 
00264 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide)
00265 
00266 
00267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00268 
00269 #define PRODUCT_OPERATOR(product, op, opFunc)                                 \
00270                                                                               \
00271 template<template<class> class Field, class Type1, class Type2>               \
00272 void opFunc                                                                   \
00273 (                                                                             \
00274     FieldField<Field, typename product<Type1, Type2>::type>& f,               \
00275     const FieldField<Field, Type1>& f1,                                       \
00276     const FieldField<Field, Type2>& f2                                        \
00277 );                                                                            \
00278                                                                               \
00279 template<template<class> class Field, class Type1, class Type2>               \
00280 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
00281 operator op                                                                   \
00282 (                                                                             \
00283     const FieldField<Field, Type1>& f1,                                       \
00284     const FieldField<Field, Type2>& f2                                        \
00285 );                                                                            \
00286                                                                               \
00287 template<template<class> class Field, class Type1, class Type2>               \
00288 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
00289 operator op                                                                   \
00290 (                                                                             \
00291     const FieldField<Field, Type1>& f1,                                       \
00292     const tmp<FieldField<Field, Type2> >& tf2                                 \
00293 );                                                                            \
00294                                                                               \
00295 template<template<class> class Field, class Type1, class Type2>               \
00296 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
00297 operator op                                                                   \
00298 (                                                                             \
00299     const tmp<FieldField<Field, Type1> >& tf1,                                \
00300     const FieldField<Field, Type2>& f2                                        \
00301 );                                                                            \
00302                                                                               \
00303 template<template<class> class Field, class Type1, class Type2>               \
00304 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
00305 operator op                                                                   \
00306 (                                                                             \
00307     const tmp<FieldField<Field, Type1> >& tf1,                                \
00308     const tmp<FieldField<Field, Type2> >& tf2                                 \
00309 );                                                                            \
00310                                                                               \
00311 template                                                                      \
00312 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>  \
00313 void opFunc                                                                   \
00314 (                                                                             \
00315     FieldField<Field, typename product<Type, Form>::type>& f,                 \
00316     const FieldField<Field, Type>& f1,                                        \
00317     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00318 );                                                                            \
00319                                                                               \
00320 template                                                                      \
00321 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>  \
00322 tmp<FieldField<Field, typename product<Type, Form>::type> >                   \
00323 operator op                                                                   \
00324 (                                                                             \
00325     const FieldField<Field, Type>& f1,                                        \
00326     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00327 );                                                                            \
00328                                                                               \
00329 template                                                                      \
00330 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>  \
00331 tmp<FieldField<Field, typename product<Type, Form>::type> >                   \
00332 operator op                                                                   \
00333 (                                                                             \
00334     const tmp<FieldField<Field, Type> >& tf1,                                 \
00335     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00336 );                                                                            \
00337                                                                               \
00338 template                                                                      \
00339 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>  \
00340 void opFunc                                                                   \
00341 (                                                                             \
00342     FieldField<Field, typename product<Form, Type>::type>& f,                 \
00343     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00344     const FieldField<Field, Type>& f1                                         \
00345 );                                                                            \
00346                                                                               \
00347 template                                                                      \
00348 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>  \
00349 tmp<FieldField<Field, typename product<Form, Type>::type> >                   \
00350 operator op                                                                   \
00351 (                                                                             \
00352     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00353     const FieldField<Field, Type>& f1                                         \
00354 );                                                                            \
00355                                                                               \
00356 template                                                                      \
00357 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>  \
00358 tmp<FieldField<Field, typename product<Form, Type>::type> >                   \
00359 operator op                                                                   \
00360 (                                                                             \
00361     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00362     const tmp<FieldField<Field, Type> >& tf1                                  \
00363 );
00364 
00365 PRODUCT_OPERATOR(typeOfSum, +, add)
00366 PRODUCT_OPERATOR(typeOfSum, -, subtract)
00367 
00368 PRODUCT_OPERATOR(outerProduct, *, outer)
00369 PRODUCT_OPERATOR(crossProduct, ^, cross)
00370 PRODUCT_OPERATOR(innerProduct, &, dot)
00371 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
00372 
00373 #undef PRODUCT_OPERATOR
00374 
00375 
00376 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00377 
00378 } // End namespace Foam
00379 
00380 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00381 
00382 #include "undefFieldFunctionsM.H"
00383 
00384 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd