1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
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 "scalarFieldField.H"
28 #define TEMPLATE template<template<class> class Field, class Type>
29 #include "FieldFieldFunctionsM.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 /* * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * */
38 template<template<class> class Field, class Type>
41 FieldField<Field, typename FieldField<Field, Type>::cmptType>& sf,
42 const FieldField<Field, Type>& f,
46 template<template<class> class Field, class Type>
47 void T(FieldField<Field, Type>& f1, const FieldField<Field, Type>& f2);
50 template<template<class> class Field, class Type, int r>
53 FieldField<Field, typename powProduct<Type, r>::type>& f,
54 const FieldField<Field, Type>& vf
57 template<template<class> class Field, class Type, int r>
58 tmp<FieldField<Field, typename powProduct<Type, r>::type> >
61 const FieldField<Field, Type>& f, typename powProduct<Type, r>::type
62 = pTraits<typename powProduct<Type, r>::type>::zero
65 template<template<class> class Field, class Type, int r>
66 tmp<FieldField<Field, typename powProduct<Type, r>::type> >
69 const tmp<FieldField<Field, Type> >& tf, typename powProduct<Type, r>::type
70 = pTraits<typename powProduct<Type, r>::type>::zero
74 template<template<class> class Field, class Type>
77 FieldField<Field, typename outerProduct<Type, Type>::type>& f,
78 const FieldField<Field, Type>& vf
81 template<template<class> class Field, class Type>
82 tmp<FieldField<Field, typename outerProduct<Type, Type>::type> >
83 sqr(const FieldField<Field, Type>& f);
85 template<template<class> class Field, class Type>
86 tmp<FieldField<Field, typename outerProduct<Type, Type>::type> >
87 sqr(const tmp<FieldField<Field, Type> >& tf);
89 template<template<class> class Field, class Type>
90 void magSqr(FieldField<Field, scalar>& sf, const FieldField<Field, Type>& f);
92 template<template<class> class Field, class Type>
93 tmp<FieldField<Field, scalar> > magSqr(const FieldField<Field, Type>& f);
95 template<template<class> class Field, class Type>
96 tmp<FieldField<Field, scalar> > magSqr(const tmp<FieldField<Field, Type> >& tf);
98 template<template<class> class Field, class Type>
99 void mag(FieldField<Field, scalar>& sf, const FieldField<Field, Type>& f);
101 template<template<class> class Field, class Type>
102 tmp<FieldField<Field, scalar> > mag(const FieldField<Field, Type>& f);
104 template<template<class> class Field, class Type>
105 tmp<FieldField<Field, scalar> > mag(const tmp<FieldField<Field, Type> >& tf);
108 template<template<class> class Field, class Type>
111 FieldField<Field, typename FieldField<Field, Type>::cmptType>& cf,
112 const FieldField<Field, Type>& f
115 template<template<class> class Field, class Type>
116 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMax
118 const FieldField<Field, Type>& f
121 template<template<class> class Field, class Type>
122 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMax
124 const tmp<FieldField<Field, Type> >& tf
128 template<template<class> class Field, class Type>
131 FieldField<Field, typename FieldField<Field, Type>::cmptType>& cf,
132 const FieldField<Field, Type>& f
135 template<template<class> class Field, class Type>
136 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMin
138 const FieldField<Field, Type>& f
141 template<template<class> class Field, class Type>
142 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMin
144 const tmp<FieldField<Field, Type> >& tf
148 template<template<class> class Field, class Type>
151 FieldField<Field, typename FieldField<Field, Type>::cmptType>& cf,
152 const FieldField<Field, Type>& f
155 template<template<class> class Field, class Type>
156 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptAv
158 const FieldField<Field, Type>& f
161 template<template<class> class Field, class Type>
162 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptAv
164 const tmp<FieldField<Field, Type> >& tf
168 template<template<class> class Field, class Type>
171 FieldField<Field, Type>& cf,
172 const FieldField<Field, Type>& f
175 template<template<class> class Field, class Type>
176 tmp<FieldField<Field, Type> > cmptMag
178 const FieldField<Field, Type>& f
181 template<template<class> class Field, class Type>
182 tmp<FieldField<Field, Type> > cmptMag
184 const tmp<FieldField<Field, Type> >& tf
188 #define TMP_UNARY_FUNCTION(returnType, func) \
190 template<template<class> class Field, class Type> \
191 returnType func(const tmp<FieldField<Field, Type> >& tf1);
193 template<template<class> class Field, class Type>
194 Type max(const FieldField<Field, Type>& f);
196 TMP_UNARY_FUNCTION(Type, max)
198 template<template<class> class Field, class Type>
199 Type min(const FieldField<Field, Type>& f);
201 TMP_UNARY_FUNCTION(Type, min)
203 template<template<class> class Field, class Type>
204 Type sum(const FieldField<Field, Type>& f);
206 TMP_UNARY_FUNCTION(Type, sum)
208 template<template<class> class Field, class Type>
209 scalar sumMag(const FieldField<Field, Type>& f);
211 TMP_UNARY_FUNCTION(scalar, sumMag)
213 template<template<class> class Field, class Type>
214 Type average(const FieldField<Field, Type>& f);
216 TMP_UNARY_FUNCTION(Type, average)
219 #define G_UNARY_FUNCTION(returnType, gFunc, func, rFunc) \
221 template<template<class> class Field, class Type> \
222 returnType gFunc(const FieldField<Field, Type>& f); \
223 TMP_UNARY_FUNCTION(returnType, gFunc)
225 G_UNARY_FUNCTION(Type, gMax, max, max)
226 G_UNARY_FUNCTION(Type, gMin, min, min)
227 G_UNARY_FUNCTION(Type, gSum, sum, sum)
228 G_UNARY_FUNCTION(scalar, gSumMag, sumMag, sum)
230 #undef G_UNARY_FUNCTION
233 template<template<class> class Field, class Type>
234 Type gAverage(const FieldField<Field, Type>& f);
236 TMP_UNARY_FUNCTION(Type, gAverage)
238 #undef TMP_UNARY_FUNCTION
241 BINARY_FUNCTION(Type, Type, Type, max)
242 BINARY_FUNCTION(Type, Type, Type, min)
243 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
244 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
246 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
247 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
248 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
249 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
252 /* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */
254 UNARY_OPERATOR(Type, Type, -, negate)
256 #ifndef __INTEL_COMPILER
257 BINARY_OPERATOR(Type, Type, scalar, *, multiply)
258 BINARY_OPERATOR(Type, scalar, Type, *, multiply)
260 BINARY_OPERATOR(Type, Type, scalar, /, divide)
262 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, multiply)
263 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, multiply)
265 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide)
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270 #define PRODUCT_OPERATOR(product, op, opFunc) \
272 template<template<class> class Field, class Type1, class Type2> \
275 FieldField<Field, typename product<Type1, Type2>::type>& f, \
276 const FieldField<Field, Type1>& f1, \
277 const FieldField<Field, Type2>& f2 \
280 template<template<class> class Field, class Type1, class Type2> \
281 tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
284 const FieldField<Field, Type1>& f1, \
285 const FieldField<Field, Type2>& f2 \
288 template<template<class> class Field, class Type1, class Type2> \
289 tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
292 const FieldField<Field, Type1>& f1, \
293 const tmp<FieldField<Field, Type2> >& tf2 \
296 template<template<class> class Field, class Type1, class Type2> \
297 tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
300 const tmp<FieldField<Field, Type1> >& tf1, \
301 const FieldField<Field, Type2>& f2 \
304 template<template<class> class Field, class Type1, class Type2> \
305 tmp<FieldField<Field, typename product<Type1, Type2>::type> > \
308 const tmp<FieldField<Field, Type1> >& tf1, \
309 const tmp<FieldField<Field, Type2> >& tf2 \
313 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt> \
316 FieldField<Field, typename product<Type, Form>::type>& f, \
317 const FieldField<Field, Type>& f1, \
318 const VectorSpace<Form,Cmpt,nCmpt>& vs \
322 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt> \
323 tmp<FieldField<Field, typename product<Type, Form>::type> > \
326 const FieldField<Field, Type>& f1, \
327 const VectorSpace<Form,Cmpt,nCmpt>& vs \
331 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt> \
332 tmp<FieldField<Field, typename product<Type, Form>::type> > \
335 const tmp<FieldField<Field, Type> >& tf1, \
336 const VectorSpace<Form,Cmpt,nCmpt>& vs \
340 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type> \
343 FieldField<Field, typename product<Form, Type>::type>& f, \
344 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
345 const FieldField<Field, Type>& f1 \
349 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type> \
350 tmp<FieldField<Field, typename product<Form, Type>::type> > \
353 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
354 const FieldField<Field, Type>& f1 \
358 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type> \
359 tmp<FieldField<Field, typename product<Form, Type>::type> > \
362 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
363 const tmp<FieldField<Field, Type> >& tf1 \
366 PRODUCT_OPERATOR(typeOfSum, +, add)
367 PRODUCT_OPERATOR(typeOfSum, -, subtract)
369 PRODUCT_OPERATOR(outerProduct, *, outer)
370 PRODUCT_OPERATOR(crossProduct, ^, cross)
371 PRODUCT_OPERATOR(innerProduct, &, dot)
372 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
374 #undef PRODUCT_OPERATOR
377 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
379 } // End namespace Foam
381 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
383 #include "undefFieldFunctionsM.H"
385 // ************************************************************************* //