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

DimensionedFieldFunctions.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 "DimensionedScalarField.H"
00028 
00029 #define TEMPLATE template<class Type, class GeoMesh>
00030 #include "DimensionedFieldFunctionsM.H"
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 // * * * * * * * * * * * * * * * Global functions  * * * * * * * * * * * * * //
00038 
00039 template<class Type, class GeoMesh, int r>
00040 tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh> >
00041 pow
00042 (
00043     const DimensionedField<Type, GeoMesh>& df,
00044     typename powProduct<Type, r>::type
00045 );
00046 
00047 template<class Type, class GeoMesh, int r>
00048 tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh> >
00049 pow
00050 (
00051     const tmp<DimensionedField<Type, GeoMesh> >& tdf,
00052     typename powProduct<Type, r>::type
00053 );
00054 
00055 template<class Type, class GeoMesh>
00056 tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh> >
00057 sqr(const DimensionedField<Type, GeoMesh>& df);
00058 
00059 template<class Type, class GeoMesh>
00060 tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh> >
00061 sqr(const tmp<DimensionedField<Type, GeoMesh> >& tdf);
00062 
00063 template<class Type, class GeoMesh>
00064 tmp<DimensionedField<scalar, GeoMesh> > magSqr
00065 (
00066     const DimensionedField<Type, GeoMesh>& df
00067 );
00068 
00069 template<class Type, class GeoMesh>
00070 tmp<DimensionedField<scalar, GeoMesh> > magSqr
00071 (
00072     const tmp<DimensionedField<Type, GeoMesh> >& tdf
00073 );
00074 
00075 template<class Type, class GeoMesh>
00076 tmp<DimensionedField<scalar, GeoMesh> > mag
00077 (
00078     const DimensionedField<Type, GeoMesh>& df
00079 );
00080 
00081 template<class Type, class GeoMesh>
00082 tmp<DimensionedField<scalar, GeoMesh> > mag
00083 (
00084     const tmp<DimensionedField<Type, GeoMesh> >& tdf
00085 );
00086 
00087 template<class Type, class GeoMesh>
00088 tmp
00089 <
00090     DimensionedField
00091         <typename DimensionedField<Type, GeoMesh>::cmptType, GeoMesh>
00092 >
00093 cmptAv(const DimensionedField<Type, GeoMesh>& df);
00094 
00095 template<class Type, class GeoMesh>
00096 tmp
00097 <
00098     DimensionedField
00099         <typename DimensionedField<Type, GeoMesh>::cmptType, GeoMesh>
00100 >
00101 cmptAv(const tmp<DimensionedField<Type, GeoMesh> >& tdf);
00102 
00103 
00104 #define UNARY_REDUCTION_FUNCTION(returnType, func, dfunc)                     \
00105                                                                               \
00106 template<class Type, class GeoMesh>                                           \
00107 dimensioned<returnType> func                                                  \
00108 (                                                                             \
00109     const DimensionedField<Type, GeoMesh>& df                                 \
00110 );                                                                            \
00111 template<class Type, class GeoMesh>                                           \
00112 dimensioned<returnType> func                                                  \
00113 (                                                                             \
00114     const tmp<DimensionedField<Type, GeoMesh> >& tdf1                         \
00115 );
00116 
00117 UNARY_REDUCTION_FUNCTION(Type, max, gMax)
00118 UNARY_REDUCTION_FUNCTION(Type, min, gMin)
00119 UNARY_REDUCTION_FUNCTION(Type, sum, gSum)
00120 UNARY_REDUCTION_FUNCTION(scalar, sumMag, gSumMag)
00121 UNARY_REDUCTION_FUNCTION(Type, average, gAverage)
00122 
00123 #undef UNARY_REDUCTION_FUNCTION
00124 
00125 
00126 BINARY_FUNCTION(Type, Type, Type, max)
00127 BINARY_FUNCTION(Type, Type, Type, min)
00128 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
00129 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
00130 
00131 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
00132 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
00133 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
00134 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
00135 
00136 
00137 // * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * //
00138 
00139 UNARY_OPERATOR(Type, Type, -, negate, transform)
00140 
00141 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
00142 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
00143 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
00144 
00145 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
00146 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
00147 
00148 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
00149 
00150 
00151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00152 
00153 #define PRODUCT_OPERATOR(product, op, opFunc)                                 \
00154                                                                               \
00155 template<class Type1, class Type2, class GeoMesh>                             \
00156 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> >         \
00157 operator op                                                                   \
00158 (                                                                             \
00159     const DimensionedField<Type1, GeoMesh>& df1,                              \
00160     const DimensionedField<Type2, GeoMesh>& df2                               \
00161 );                                                                            \
00162                                                                               \
00163 template<class Type1, class Type2, class GeoMesh>                             \
00164 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> >         \
00165 operator op                                                                   \
00166 (                                                                             \
00167     const DimensionedField<Type1, GeoMesh>& df1,                              \
00168     const tmp<DimensionedField<Type2, GeoMesh> >& tdf2                        \
00169 );                                                                            \
00170                                                                               \
00171 template<class Type1, class Type2, class GeoMesh>                             \
00172 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> >         \
00173 operator op                                                                   \
00174 (                                                                             \
00175     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,                       \
00176     const DimensionedField<Type2, GeoMesh>& df2                               \
00177 );                                                                            \
00178                                                                               \
00179 template<class Type1, class Type2, class GeoMesh>                             \
00180 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> >         \
00181 operator op                                                                   \
00182 (                                                                             \
00183     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,                       \
00184     const tmp<DimensionedField<Type2, GeoMesh> >& tdf2                        \
00185 );                                                                            \
00186                                                                               \
00187 template<class Form, class Type, class GeoMesh>                               \
00188 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh> >           \
00189 operator op                                                                   \
00190 (                                                                             \
00191     const DimensionedField<Type, GeoMesh>& df1,                               \
00192     const dimensioned<Form>& dvs                                              \
00193 );                                                                            \
00194                                                                               \
00195 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>        \
00196 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> >           \
00197 operator op                                                                   \
00198 (                                                                             \
00199     const DimensionedField<Type, GeoMesh>& df1,                               \
00200     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00201 );                                                                            \
00202                                                                               \
00203 template<class Form, class Type, class GeoMesh>                               \
00204 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh> >           \
00205 operator op                                                                   \
00206 (                                                                             \
00207     const tmp<DimensionedField<Type, GeoMesh> >& tdf1,                        \
00208     const dimensioned<Form>& dvs                                              \
00209 );                                                                            \
00210                                                                               \
00211 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>        \
00212 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> >           \
00213 operator op                                                                   \
00214 (                                                                             \
00215     const tmp<DimensionedField<Type, GeoMesh> >& tdf1,                        \
00216     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00217 );                                                                            \
00218                                                                               \
00219 template<class Form, class Type, class GeoMesh>                               \
00220 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> >           \
00221 operator op                                                                   \
00222 (                                                                             \
00223     const dimensioned<Form>& dvs,                                             \
00224     const DimensionedField<Type, GeoMesh>& df1                                \
00225 );                                                                            \
00226                                                                               \
00227 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>        \
00228 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> >           \
00229 operator op                                                                   \
00230 (                                                                             \
00231     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00232     const DimensionedField<Type, GeoMesh>& df1                                \
00233 );                                                                            \
00234                                                                               \
00235 template<class Form, class Type, class GeoMesh>                               \
00236 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> >           \
00237 operator op                                                                   \
00238 (                                                                             \
00239     const dimensioned<Form>& dvs,                                             \
00240     const tmp<DimensionedField<Type, GeoMesh> >& tdf1                         \
00241 );                                                                            \
00242                                                                               \
00243 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>        \
00244 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> >           \
00245 operator op                                                                   \
00246 (                                                                             \
00247     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00248     const tmp<DimensionedField<Type, GeoMesh> >& tdf1                         \
00249 );
00250 
00251 PRODUCT_OPERATOR(typeOfSum, +, add)
00252 PRODUCT_OPERATOR(typeOfSum, -, subtract)
00253 
00254 PRODUCT_OPERATOR(outerProduct, *, outer)
00255 PRODUCT_OPERATOR(crossProduct, ^, cross)
00256 PRODUCT_OPERATOR(innerProduct, &, dot)
00257 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
00258 
00259 #undef PRODUCT_OPERATOR
00260 
00261 
00262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00263 
00264 } // End namespace Foam
00265 
00266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00267 
00268 #include "undefFieldFunctionsM.H"
00269 
00270 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd