FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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