OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen 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-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 "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, scale)
00129 
00130 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
00131 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
00132 BINARY_TYPE_FUNCTION(Type, Type, Type, scale)
00133 
00134 
00135 // * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * //
00136 
00137 UNARY_OPERATOR(Type, Type, -, negate, transform)
00138 
00139 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
00140 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
00141 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
00142 
00143 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
00144 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
00145 
00146 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
00147 
00148 
00149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00150 
00151 #define PRODUCT_OPERATOR(product, op, opFunc)                                 \
00152                                                                               \
00153 template<class Type1, class Type2, class GeoMesh>                             \
00154 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> >         \
00155 operator op                                                                   \
00156 (                                                                             \
00157     const DimensionedField<Type1, GeoMesh>& df1,                              \
00158     const DimensionedField<Type2, GeoMesh>& df2                               \
00159 );                                                                            \
00160                                                                               \
00161 template<class Type1, class Type2, class GeoMesh>                             \
00162 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> >         \
00163 operator op                                                                   \
00164 (                                                                             \
00165     const DimensionedField<Type1, GeoMesh>& df1,                              \
00166     const tmp<DimensionedField<Type2, GeoMesh> >& tdf2                        \
00167 );                                                                            \
00168                                                                               \
00169 template<class Type1, class Type2, class GeoMesh>                             \
00170 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> >         \
00171 operator op                                                                   \
00172 (                                                                             \
00173     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,                       \
00174     const DimensionedField<Type2, GeoMesh>& df2                               \
00175 );                                                                            \
00176                                                                               \
00177 template<class Type1, class Type2, class GeoMesh>                             \
00178 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> >         \
00179 operator op                                                                   \
00180 (                                                                             \
00181     const tmp<DimensionedField<Type1, GeoMesh> >& tdf1,                       \
00182     const tmp<DimensionedField<Type2, GeoMesh> >& tdf2                        \
00183 );                                                                            \
00184                                                                               \
00185 template<class Form, class Type, class GeoMesh>                               \
00186 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh> >           \
00187 operator op                                                                   \
00188 (                                                                             \
00189     const DimensionedField<Type, GeoMesh>& df1,                               \
00190     const dimensioned<Form>& dvs                                              \
00191 );                                                                            \
00192                                                                               \
00193 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>        \
00194 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> >           \
00195 operator op                                                                   \
00196 (                                                                             \
00197     const DimensionedField<Type, GeoMesh>& df1,                               \
00198     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00199 );                                                                            \
00200                                                                               \
00201 template<class Form, class Type, class GeoMesh>                               \
00202 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh> >           \
00203 operator op                                                                   \
00204 (                                                                             \
00205     const tmp<DimensionedField<Type, GeoMesh> >& tdf1,                        \
00206     const dimensioned<Form>& dvs                                              \
00207 );                                                                            \
00208                                                                               \
00209 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>        \
00210 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> >           \
00211 operator op                                                                   \
00212 (                                                                             \
00213     const tmp<DimensionedField<Type, GeoMesh> >& tdf1,                        \
00214     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
00215 );                                                                            \
00216                                                                               \
00217 template<class Form, class Type, class GeoMesh>                               \
00218 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> >           \
00219 operator op                                                                   \
00220 (                                                                             \
00221     const dimensioned<Form>& dvs,                                             \
00222     const DimensionedField<Type, GeoMesh>& df1                                \
00223 );                                                                            \
00224                                                                               \
00225 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>        \
00226 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> >           \
00227 operator op                                                                   \
00228 (                                                                             \
00229     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00230     const DimensionedField<Type, GeoMesh>& df1                                \
00231 );                                                                            \
00232                                                                               \
00233 template<class Form, class Type, class GeoMesh>                               \
00234 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> >           \
00235 operator op                                                                   \
00236 (                                                                             \
00237     const dimensioned<Form>& dvs,                                             \
00238     const tmp<DimensionedField<Type, GeoMesh> >& tdf1                         \
00239 );                                                                            \
00240                                                                               \
00241 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh>        \
00242 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> >           \
00243 operator op                                                                   \
00244 (                                                                             \
00245     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
00246     const tmp<DimensionedField<Type, GeoMesh> >& tdf1                         \
00247 );
00248 
00249 PRODUCT_OPERATOR(typeOfSum, +, add)
00250 PRODUCT_OPERATOR(typeOfSum, -, subtract)
00251 
00252 PRODUCT_OPERATOR(outerProduct, *, outer)
00253 PRODUCT_OPERATOR(crossProduct, ^, cross)
00254 PRODUCT_OPERATOR(innerProduct, &, dot)
00255 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
00256 
00257 #undef PRODUCT_OPERATOR
00258 
00259 
00260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00261 
00262 } // End namespace Foam
00263 
00264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00265 
00266 #include "undefFieldFunctionsM.H"
00267 
00268 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd