1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "DimensionedScalarField.H"
28 #define TEMPLATE template<class Type, class GeoMesh>
29 #include "DimensionedFieldFunctionsM.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
38 template<class Type, class GeoMesh, int r>
39 tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh> >
42 const DimensionedField<Type, GeoMesh>& df,
43 typename powProduct<Type, r>::type
46 template<class Type, class GeoMesh, int r>
47 tmp<DimensionedField<typename powProduct<Type, r>::type, GeoMesh> >
50 const tmp<DimensionedField<Type, GeoMesh> >& tdf,
51 typename powProduct<Type, r>::type
54 template<class Type, class GeoMesh>
55 tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh> >
56 sqr(const DimensionedField<Type, GeoMesh>& df);
58 template<class Type, class GeoMesh>
59 tmp<DimensionedField<typename outerProduct<Type, Type>::type, GeoMesh> >
60 sqr(const tmp<DimensionedField<Type, GeoMesh> >& tdf);
62 template<class Type, class GeoMesh>
63 tmp<DimensionedField<scalar, GeoMesh> > magSqr
65 const DimensionedField<Type, GeoMesh>& df
68 template<class Type, class GeoMesh>
69 tmp<DimensionedField<scalar, GeoMesh> > magSqr
71 const tmp<DimensionedField<Type, GeoMesh> >& tdf
74 template<class Type, class GeoMesh>
75 tmp<DimensionedField<scalar, GeoMesh> > mag
77 const DimensionedField<Type, GeoMesh>& df
80 template<class Type, class GeoMesh>
81 tmp<DimensionedField<scalar, GeoMesh> > mag
83 const tmp<DimensionedField<Type, GeoMesh> >& tdf
86 template<class Type, class GeoMesh>
90 <typename DimensionedField<Type, GeoMesh>::cmptType, GeoMesh>
92 cmptAv(const DimensionedField<Type, GeoMesh>& df);
94 template<class Type, class GeoMesh>
98 <typename DimensionedField<Type, GeoMesh>::cmptType, GeoMesh>
100 cmptAv(const tmp<DimensionedField<Type, GeoMesh> >& tdf);
103 #define UNARY_REDUCTION_FUNCTION(returnType, func, dfunc) \
105 template<class Type, class GeoMesh> \
106 dimensioned<returnType> func \
108 const DimensionedField<Type, GeoMesh>& df \
110 template<class Type, class GeoMesh> \
111 dimensioned<returnType> func \
113 const tmp<DimensionedField<Type, GeoMesh> >& tdf1 \
116 UNARY_REDUCTION_FUNCTION(Type, max, gMax)
117 UNARY_REDUCTION_FUNCTION(Type, min, gMin)
118 UNARY_REDUCTION_FUNCTION(Type, sum, gSum)
119 UNARY_REDUCTION_FUNCTION(scalar, sumMag, gSumMag)
120 UNARY_REDUCTION_FUNCTION(Type, average, gAverage)
122 #undef UNARY_REDUCTION_FUNCTION
125 BINARY_FUNCTION(Type, Type, Type, max)
126 BINARY_FUNCTION(Type, Type, Type, min)
127 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
128 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
130 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
131 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
132 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
133 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
136 // * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
138 UNARY_OPERATOR(Type, Type, -, negate, transform)
140 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
141 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
142 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
144 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
145 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
147 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 #define PRODUCT_OPERATOR(product, op, opFunc) \
154 template<class Type1, class Type2, class GeoMesh> \
155 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> > \
158 const DimensionedField<Type1, GeoMesh>& df1, \
159 const DimensionedField<Type2, GeoMesh>& df2 \
162 template<class Type1, class Type2, class GeoMesh> \
163 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> > \
166 const DimensionedField<Type1, GeoMesh>& df1, \
167 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2 \
170 template<class Type1, class Type2, class GeoMesh> \
171 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> > \
174 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1, \
175 const DimensionedField<Type2, GeoMesh>& df2 \
178 template<class Type1, class Type2, class GeoMesh> \
179 tmp<DimensionedField<typename product<Type1, Type2>::type, GeoMesh> > \
182 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1, \
183 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2 \
186 template<class Form, class Type, class GeoMesh> \
187 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh> > \
190 const DimensionedField<Type, GeoMesh>& df1, \
191 const dimensioned<Form>& dvs \
194 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh> \
195 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> > \
198 const DimensionedField<Type, GeoMesh>& df1, \
199 const VectorSpace<Form,Cmpt,nCmpt>& vs \
202 template<class Form, class Type, class GeoMesh> \
203 tmp<DimensionedField<typename product<Type, Form>::type, GeoMesh> > \
206 const tmp<DimensionedField<Type, GeoMesh> >& tdf1, \
207 const dimensioned<Form>& dvs \
210 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh> \
211 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> > \
214 const tmp<DimensionedField<Type, GeoMesh> >& tdf1, \
215 const VectorSpace<Form,Cmpt,nCmpt>& vs \
218 template<class Form, class Type, class GeoMesh> \
219 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> > \
222 const dimensioned<Form>& dvs, \
223 const DimensionedField<Type, GeoMesh>& df1 \
226 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh> \
227 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> > \
230 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
231 const DimensionedField<Type, GeoMesh>& df1 \
234 template<class Form, class Type, class GeoMesh> \
235 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> > \
238 const dimensioned<Form>& dvs, \
239 const tmp<DimensionedField<Type, GeoMesh> >& tdf1 \
242 template<class Form, class Cmpt, int nCmpt, class Type, class GeoMesh> \
243 tmp<DimensionedField<typename product<Form, Type>::type, GeoMesh> > \
246 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
247 const tmp<DimensionedField<Type, GeoMesh> >& tdf1 \
250 PRODUCT_OPERATOR(typeOfSum, +, add)
251 PRODUCT_OPERATOR(typeOfSum, -, subtract)
253 PRODUCT_OPERATOR(outerProduct, *, outer)
254 PRODUCT_OPERATOR(crossProduct, ^, cross)
255 PRODUCT_OPERATOR(innerProduct, &, dot)
256 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
258 #undef PRODUCT_OPERATOR
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 } // End namespace Foam
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 #include "undefFieldFunctionsM.H"
269 // ************************************************************************* //