OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide 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-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 "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, cmptMultiply)
00245 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
00246 
00247 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
00248 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
00249 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
00250 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
00251 
00252 
00253 /* * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * */
00254 
00255 UNARY_OPERATOR(Type, Type, -, negate)
00256 
00257 #ifndef __INTEL_COMPILER
00258 BINARY_OPERATOR(Type, Type, scalar, *, multiply)
00259 BINARY_OPERATOR(Type, scalar, Type, *, multiply)
00260 #endif
00261 BINARY_OPERATOR(Type, Type, scalar, /, divide)
00262 
00263 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, multiply)
00264 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, multiply)
00265 
00266 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide)
00267 
00268 
00269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00270 
00271 #define PRODUCT_OPERATOR(product, op, opFunc)                                 \
00272                                                                               \
00273 template<template<class> class Field, class Type1, class Type2>               \
00274 void opFunc                                                                   \
00275 (                                                                             \
00276     FieldField<Field, typename product<Type1, Type2>::type>& f,               \
00277     const FieldField<Field, Type1>& f1,                                       \
00278     const FieldField<Field, Type2>& f2                                        \
00279 );                                                                            \
00280                                                                               \
00281 template<template<class> class Field, class Type1, class Type2>               \
00282 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
00283 operator op                                                                   \
00284 (                                                                             \
00285     const FieldField<Field, Type1>& f1,                                       \
00286     const FieldField<Field, Type2>& f2                                        \
00287 );                                                                            \
00288                                                                               \
00289 template<template<class> class Field, class Type1, class Type2>               \
00290 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
00291 operator op                                                                   \
00292 (                                                                             \
00293     const FieldField<Field, Type1>& f1,                                       \
00294     const tmp<FieldField<Field, Type2> >& tf2                                 \
00295 );                                                                            \
00296                                                                               \
00297 template<template<class> class Field, class Type1, class Type2>               \
00298 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
00299 operator op                                                                   \
00300 (                                                                             \
00301     const tmp<FieldField<Field, Type1> >& tf1,                                \
00302     const FieldField<Field, Type2>& f2                                        \
00303 );                                                                            \
00304                                                                               \
00305 template<template<class> class Field, class Type1, class Type2>               \
00306 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
00307 operator op                                                                   \
00308 (                                                                             \
00309     const tmp<FieldField<Field, Type1> >& tf1,                                \
00310     const tmp<FieldField<Field, Type2> >& tf2                                 \
00311 );                                                                            \
00312                                                                               \
00313 template                                                                      \
00314 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>  \
00315 void opFunc                                                                   \
00316 (                                                                             \
00317     FieldField<Field, typename product<Type, Form>::type>& f,                 \
00318     const FieldField<Field, Type>& f1,                                        \
00319     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00320 );                                                                            \
00321                                                                               \
00322 template                                                                      \
00323 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>  \
00324 tmp<FieldField<Field, typename product<Type, Form>::type> >                   \
00325 operator op                                                                   \
00326 (                                                                             \
00327     const FieldField<Field, Type>& f1,                                        \
00328     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00329 );                                                                            \
00330                                                                               \
00331 template                                                                      \
00332 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>  \
00333 tmp<FieldField<Field, typename product<Type, Form>::type> >                   \
00334 operator op                                                                   \
00335 (                                                                             \
00336     const tmp<FieldField<Field, Type> >& tf1,                                 \
00337     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00338 );                                                                            \
00339                                                                               \
00340 template                                                                      \
00341 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>  \
00342 void opFunc                                                                   \
00343 (                                                                             \
00344     FieldField<Field, typename product<Form, Type>::type>& f,                 \
00345     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00346     const FieldField<Field, Type>& f1                                         \
00347 );                                                                            \
00348                                                                               \
00349 template                                                                      \
00350 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>  \
00351 tmp<FieldField<Field, typename product<Form, Type>::type> >                   \
00352 operator op                                                                   \
00353 (                                                                             \
00354     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00355     const FieldField<Field, Type>& f1                                         \
00356 );                                                                            \
00357                                                                               \
00358 template                                                                      \
00359 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>  \
00360 tmp<FieldField<Field, typename product<Form, Type>::type> >                   \
00361 operator op                                                                   \
00362 (                                                                             \
00363     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00364     const tmp<FieldField<Field, Type> >& tf1                                  \
00365 );
00366 
00367 PRODUCT_OPERATOR(typeOfSum, +, add)
00368 PRODUCT_OPERATOR(typeOfSum, -, subtract)
00369 
00370 PRODUCT_OPERATOR(outerProduct, *, outer)
00371 PRODUCT_OPERATOR(crossProduct, ^, cross)
00372 PRODUCT_OPERATOR(innerProduct, &, dot)
00373 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
00374 
00375 #undef PRODUCT_OPERATOR
00376 
00377 
00378 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00379 
00380 } // End namespace Foam
00381 
00382 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00383 
00384 #include "undefFieldFunctionsM.H"
00385 
00386 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd