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 "GeometricScalarField.H"
29 template<class Type, template<class> class PatchField, class GeoMesh>
30 #include "GeometricFieldFunctionsM.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * //
39 template<class Type, template<class> class PatchField, class GeoMesh>
44 typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
48 const GeometricField<Type, PatchField, GeoMesh>& gf,
52 template<class Type, template<class> class PatchField, class GeoMesh>
55 GeometricField<Type, PatchField, GeoMesh>& gf,
56 const GeometricField<Type, PatchField, GeoMesh>& gf1
59 template<class Type, template<class> class PatchField, class GeoMesh, int r>
62 GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>& gf,
63 const GeometricField<Type, PatchField, GeoMesh>& gf1
66 template<class Type, template<class> class PatchField, class GeoMesh, int r>
70 <typename powProduct<Type, r>::type, PatchField, GeoMesh>
74 const GeometricField<Type, PatchField, GeoMesh>& gf,
75 typename powProduct<Type, r>::type
78 template<class Type, template<class> class PatchField, class GeoMesh, int r>
82 <typename powProduct<Type, r>::type, PatchField, GeoMesh>
86 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf,
87 typename powProduct<Type, r>::type
90 template<class Type, template<class> class PatchField, class GeoMesh>
94 <typename outerProduct<Type, Type>::type, PatchField, GeoMesh>& gf,
95 const GeometricField<Type, PatchField, GeoMesh>& gf1
98 template<class Type, template<class> class PatchField, class GeoMesh>
103 typename outerProduct<Type, Type>::type,
108 sqr(const GeometricField<Type, PatchField, GeoMesh>& gf);
110 template<class Type, template<class> class PatchField, class GeoMesh>
115 typename outerProduct<Type, Type>::type,
120 sqr(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf);
122 template<class Type, template<class> class PatchField, class GeoMesh>
125 GeometricField<scalar, PatchField, GeoMesh>& gsf,
126 const GeometricField<Type, PatchField, GeoMesh>& gf
129 template<class Type, template<class> class PatchField, class GeoMesh>
130 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
132 const GeometricField<Type, PatchField, GeoMesh>& gf
135 template<class Type, template<class> class PatchField, class GeoMesh>
136 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
138 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
141 template<class Type, template<class> class PatchField, class GeoMesh>
144 GeometricField<scalar, PatchField, GeoMesh>& gsf,
145 const GeometricField<Type, PatchField, GeoMesh>& gf
148 template<class Type, template<class> class PatchField, class GeoMesh>
149 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
151 const GeometricField<Type, PatchField, GeoMesh>& gf
154 template<class Type, template<class> class PatchField, class GeoMesh>
155 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
157 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
160 template<class Type, template<class> class PatchField, class GeoMesh>
165 typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
169 const GeometricField<Type, PatchField, GeoMesh>& gf
172 template<class Type, template<class> class PatchField, class GeoMesh>
177 typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
182 cmptAv(const GeometricField<Type, PatchField, GeoMesh>& gf);
184 template<class Type, template<class> class PatchField, class GeoMesh>
189 typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
194 cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf);
197 #define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc) \
199 template<class Type, template<class> class PatchField, class GeoMesh> \
200 dimensioned<returnType> func \
202 const GeometricField<Type, PatchField, GeoMesh>& gf \
205 template<class Type, template<class> class PatchField, class GeoMesh> \
206 dimensioned<returnType> func \
208 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1 \
211 UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, max, gMax)
212 UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, min, gMin)
214 #undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
217 #define UNARY_REDUCTION_FUNCTION(returnType, func, gFunc) \
219 template<class Type, template<class> class PatchField, class GeoMesh> \
220 dimensioned<returnType> func \
222 const GeometricField<Type, PatchField, GeoMesh>& gf \
225 template<class Type, template<class> class PatchField, class GeoMesh> \
226 dimensioned<returnType> func \
228 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1 \
231 UNARY_REDUCTION_FUNCTION(Type, sum, gSum)
232 UNARY_REDUCTION_FUNCTION(scalar, sumMag, gSumMag)
233 UNARY_REDUCTION_FUNCTION(Type, average, gAverage)
235 #undef UNARY_REDUCTION_FUNCTION
238 BINARY_FUNCTION(Type, Type, Type, max)
239 BINARY_FUNCTION(Type, Type, Type, min)
240 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
241 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
243 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
244 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
245 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
246 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
249 // * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * //
251 UNARY_OPERATOR(Type, Type, -, negate, transform)
253 #ifndef __INTEL_COMPILER
254 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
255 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
257 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
259 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
260 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
262 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 #define PRODUCT_OPERATOR(product, op, opFunc) \
270 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
274 <typename product<Type1, Type2>::type, PatchField, GeoMesh>& gf, \
275 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
276 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
280 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
284 <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
288 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
289 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
293 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
297 <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
301 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
302 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
306 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
310 <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
314 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
315 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
319 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
323 <typename product<Type1, Type2>::type, PatchField, GeoMesh> \
327 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
328 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
332 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
336 <typename product<Type, Form>::type, PatchField, GeoMesh>& gf, \
337 const GeometricField<Type, PatchField, GeoMesh>& gf1, \
338 const dimensioned<Form>& dvs \
342 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
346 <typename product<Type, Form>::type, PatchField, GeoMesh> \
350 const GeometricField<Type, PatchField, GeoMesh>& gf1, \
351 const dimensioned<Form>& dvs \
359 class Type, template<class> class PatchField, \
365 <typename product<Form, Type>::type, PatchField, GeoMesh> \
369 const GeometricField<Type, PatchField, GeoMesh>& gf1, \
370 const VectorSpace<Form,Cmpt,nCmpt>& vs \
374 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
378 <typename product<Type, Form>::type, PatchField, GeoMesh> \
382 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1, \
383 const dimensioned<Form>& dvs \
391 class Type, template<class> class PatchField, \
397 <typename product<Form, Type>::type, PatchField, GeoMesh> \
401 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1, \
402 const VectorSpace<Form,Cmpt,nCmpt>& vs \
406 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
410 <typename product<Form, Type>::type, PatchField, GeoMesh>& gf, \
411 const dimensioned<Form>& dvs, \
412 const GeometricField<Type, PatchField, GeoMesh>& gf1 \
416 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
420 <typename product<Form, Type>::type, PatchField, GeoMesh> \
424 const dimensioned<Form>& dvs, \
425 const GeometricField<Type, PatchField, GeoMesh>& gf1 \
433 class Type, template<class> class PatchField, \
439 <typename product<Form, Type>::type, PatchField, GeoMesh> \
443 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
444 const GeometricField<Type, PatchField, GeoMesh>& gf1 \
448 <class Form, class Type, template<class> class PatchField, class GeoMesh> \
452 <typename product<Form, Type>::type, PatchField, GeoMesh> \
456 const dimensioned<Form>& dvs, \
457 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1 \
465 class Type, template<class> class PatchField, \
471 <typename product<Form, Type>::type, PatchField, GeoMesh> \
475 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
476 const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1 \
479 PRODUCT_OPERATOR(typeOfSum, +, add)
480 PRODUCT_OPERATOR(typeOfSum, -, subtract)
482 PRODUCT_OPERATOR(outerProduct, *, outer)
483 PRODUCT_OPERATOR(crossProduct, ^, cross)
484 PRODUCT_OPERATOR(innerProduct, &, dot)
485 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
487 #undef PRODUCT_OPERATOR
490 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
492 } // End namespace Foam
494 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
496 #include "undefFieldFunctionsM.H"
498 // ************************************************************************* //