1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "DimensionedScalarField.H"
29 #define TEMPLATE template<class Type, class GeoMesh>
30 #include "DimensionedFieldFunctionsM.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
39 template<class Type, class GeoMesh, int r>
40 tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh> >
43 const DimensionedField<Type, GeoMesh>& df,
44 typename powProduct<Type, r>::type
47 template<class Type, class GeoMesh, int r>
48 tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh> >
51 const tmp<DimensionedField<Type, GeoMesh> >& tdf,
52 typename powProduct<Type, r>::type
55 template<class Type, class GeoMesh>
56 tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh> >
57 sqr(const DimensionedField<Type, GeoMesh>& df);
59 template<class Type, class GeoMesh>
60 tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh> >
61 sqr(const tmp<DimensionedField<Type, GeoMesh> >& tdf);
63 template<class Type, class GeoMesh>
64 tmp<DimensionedField<scalar, GeoMesh> > magSqr
66 const DimensionedField<Type, GeoMesh>& df
69 template<class Type, class GeoMesh>
70 tmp<DimensionedField<scalar, GeoMesh> > magSqr
72 const tmp<DimensionedField<Type, GeoMesh> >& tdf
75 template<class Type, class GeoMesh>
76 tmp<DimensionedField<scalar, GeoMesh> > mag
78 const DimensionedField<Type, GeoMesh>& df
81 template<class Type, class GeoMesh>
82 tmp<DimensionedField<scalar, GeoMesh> > mag
84 const tmp<DimensionedField<Type, GeoMesh> >& tdf
87 template<class Type, class GeoMesh>
91 <typename DimensionedField<Type, GeoMesh>::cmptType, GeoMesh>
93 cmptAv(const DimensionedField<Type, GeoMesh>& df);
95 template<class Type, class GeoMesh>
99 <typename DimensionedField<Type, GeoMesh>::cmptType, GeoMesh>
101 cmptAv(const tmp<DimensionedField<Type, GeoMesh> >& tdf);
104 #define UNARY_REDUCTION_FUNCTION(returnType, func, dfunc) \
106 template<class Type, class GeoMesh> \
107 dimensioned<returnType> func \
109 const DimensionedField<Type, GeoMesh>& df \
111 template<class Type, class GeoMesh> \
112 dimensioned<returnType> func \
114 const tmp<DimensionedField<Type, GeoMesh> >& tdf1 \
117 UNARY_REDUCTION_FUNCTION(Type, max, gMax)
118 UNARY_REDUCTION_FUNCTION(Type, min, gMin)
119 UNARY_REDUCTION_FUNCTION(Type, sum, gSum)
120 UNARY_REDUCTION_FUNCTION(scalar, sumMag, gSumMag)
121 UNARY_REDUCTION_FUNCTION(Type, average, gAverage)
123 #undef UNARY_REDUCTION_FUNCTION
126 BINARY_FUNCTION(Type, Type, Type, max)
127 BINARY_FUNCTION(Type, Type, Type, min)
128 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
129 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
131 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
132 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
133 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
134 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
137 // * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
139 UNARY_OPERATOR(Type, Type, -, negate, transform)
141 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
142 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
143 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
145 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
146 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
148 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 #define PRODUCT_OPERATOR(product, op, opFunc) \
155 template<class Type1, class Type2, class GeoMesh> \
156 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> > \
159 const DimensionedField<Type1, GeoMesh>& df1, \
160 const DimensionedField<Type2, GeoMesh>& df2 \
163 template<class Type1, class Type2, class GeoMesh> \
164 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> > \
167 const DimensionedField<Type1, GeoMesh>& df1, \
168 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2 \
171 template<class Type1, class Type2, class GeoMesh> \
172 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> > \
175 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1, \
176 const DimensionedField<Type2, GeoMesh>& df2 \
179 template<class Type1, class Type2, class GeoMesh> \
180 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> > \
183 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1, \
184 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2 \
187 template<class Form, class Type, class GeoMesh> \
188 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh> > \
191 const DimensionedField<Type, GeoMesh>& df1, \
192 const dimensioned<Form>& dvs \
195 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh> \
196 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> > \
199 const DimensionedField<Type, GeoMesh>& df1, \
200 const VectorSpace<Form,Cmpt,nCmpt>& vs \
203 template<class Form, class Type, class GeoMesh> \
204 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh> > \
207 const tmp<DimensionedField<Type, GeoMesh> >& tdf1, \
208 const dimensioned<Form>& dvs \
211 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh> \
212 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> > \
215 const tmp<DimensionedField<Type, GeoMesh> >& tdf1, \
216 const VectorSpace<Form,Cmpt,nCmpt>& vs \
219 template<class Form, class Type, class GeoMesh> \
220 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> > \
223 const dimensioned<Form>& dvs, \
224 const DimensionedField<Type, GeoMesh>& df1 \
227 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh> \
228 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> > \
231 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
232 const DimensionedField<Type, GeoMesh>& df1 \
235 template<class Form, class Type, class GeoMesh> \
236 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> > \
239 const dimensioned<Form>& dvs, \
240 const tmp<DimensionedField<Type, GeoMesh> >& tdf1 \
243 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh> \
244 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> > \
247 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
248 const tmp<DimensionedField<Type, GeoMesh> >& tdf1 \
251 PRODUCT_OPERATOR(typeOfSum, +, add)
252 PRODUCT_OPERATOR(typeOfSum, -, subtract)
254 PRODUCT_OPERATOR(outerProduct, *, outer)
255 PRODUCT_OPERATOR(crossProduct, ^, cross)
256 PRODUCT_OPERATOR(innerProduct, &, dot)
257 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
259 #undef PRODUCT_OPERATOR
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 } // End namespace Foam
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 #include "undefFieldFunctionsM.H"
270 // ************************************************************************* //