initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / fields / FieldFields / FieldField / FieldFieldFunctions.H
blob0f0b1570eda1fa078e16afc665970e37413a8423
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 "scalarFieldField.H"
29 #define TEMPLATE template<template<class> class Field, class Type>
30 #include "FieldFieldFunctionsM.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace Foam
37 /* * * * * * * * * * * * * * * * Global functions  * * * * * * * * * * * * * */
39 template<template<class> class Field, class Type>
40 void component
42     FieldField<Field, typename FieldField<Field, Type>::cmptType>& sf,
43     const FieldField<Field, Type>& f,
44     const direction d
47 template<template<class> class Field, class Type>
48 void T(FieldField<Field, Type>& f1, const FieldField<Field, Type>& f2);
51 template<template<class> class Field, class Type, int r>
52 void pow
54     FieldField<Field, typename powProduct<Type, r>::type>& f,
55     const FieldField<Field, Type>& vf
58 template<template<class> class Field, class Type, int r>
59 tmp<FieldField<Field, typename powProduct<Type, r>::type> >
60 pow
62     const FieldField<Field, Type>& f, typename powProduct<Type, r>::type
63         = pTraits<typename powProduct<Type, r>::type>::zero
66 template<template<class> class Field, class Type, int r>
67 tmp<FieldField<Field, typename powProduct<Type, r>::type> >
68 pow
70     const tmp<FieldField<Field, Type> >& tf, typename powProduct<Type, r>::type
71         = pTraits<typename powProduct<Type, r>::type>::zero
75 template<template<class> class Field, class Type>
76 void sqr
78     FieldField<Field, typename outerProduct<Type, Type>::type>& f,
79     const FieldField<Field, Type>& vf
82 template<template<class> class Field, class Type>
83 tmp<FieldField<Field, typename outerProduct<Type, Type>::type> >
84 sqr(const FieldField<Field, Type>& f);
86 template<template<class> class Field, class Type>
87 tmp<FieldField<Field, typename outerProduct<Type, Type>::type> >
88 sqr(const tmp<FieldField<Field, Type> >& tf);
90 template<template<class> class Field, class Type>
91 void magSqr(FieldField<Field, scalar>& sf, const FieldField<Field, Type>& f);
93 template<template<class> class Field, class Type>
94 tmp<FieldField<Field, scalar> > magSqr(const FieldField<Field, Type>& f);
96 template<template<class> class Field, class Type>
97 tmp<FieldField<Field, scalar> > magSqr(const tmp<FieldField<Field, Type> >& tf);
99 template<template<class> class Field, class Type>
100 void mag(FieldField<Field, scalar>& sf, const FieldField<Field, Type>& f);
102 template<template<class> class Field, class Type>
103 tmp<FieldField<Field, scalar> > mag(const FieldField<Field, Type>& f);
105 template<template<class> class Field, class Type>
106 tmp<FieldField<Field, scalar> > mag(const tmp<FieldField<Field, Type> >& tf);
109 template<template<class> class Field, class Type>
110 void cmptMax
112     FieldField<Field, typename FieldField<Field, Type>::cmptType>& cf,
113     const FieldField<Field, Type>& f
116 template<template<class> class Field, class Type>
117 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMax
119     const FieldField<Field, Type>& f
122 template<template<class> class Field, class Type>
123 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMax
125     const tmp<FieldField<Field, Type> >& tf
129 template<template<class> class Field, class Type>
130 void cmptMin
132     FieldField<Field, typename FieldField<Field, Type>::cmptType>& cf,
133     const FieldField<Field, Type>& f
136 template<template<class> class Field, class Type>
137 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMin
139     const FieldField<Field, Type>& f
142 template<template<class> class Field, class Type>
143 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMin
145     const tmp<FieldField<Field, Type> >& tf
149 template<template<class> class Field, class Type>
150 void cmptAv
152     FieldField<Field, typename FieldField<Field, Type>::cmptType>& cf,
153     const FieldField<Field, Type>& f
156 template<template<class> class Field, class Type>
157 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptAv
159     const FieldField<Field, Type>& f
162 template<template<class> class Field, class Type>
163 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptAv
165     const tmp<FieldField<Field, Type> >& tf
169 template<template<class> class Field, class Type>
170 void cmptMag
172     FieldField<Field, Type>& cf,
173     const FieldField<Field, Type>& f
176 template<template<class> class Field, class Type>
177 tmp<FieldField<Field, Type> > cmptMag
179     const FieldField<Field, Type>& f
182 template<template<class> class Field, class Type>
183 tmp<FieldField<Field, Type> > cmptMag
185     const tmp<FieldField<Field, Type> >& tf
189 #define TMP_UNARY_FUNCTION(returnType, func)                                  \
190                                                                               \
191 template<template<class> class Field, class Type>                             \
192 returnType func(const tmp<FieldField<Field, Type> >& tf1);
194 template<template<class> class Field, class Type>
195 Type max(const FieldField<Field, Type>& f);
197 TMP_UNARY_FUNCTION(Type, max)
199 template<template<class> class Field, class Type>
200 Type min(const FieldField<Field, Type>& f);
202 TMP_UNARY_FUNCTION(Type, min)
204 template<template<class> class Field, class Type>
205 Type sum(const FieldField<Field, Type>& f);
207 TMP_UNARY_FUNCTION(Type, sum)
209 template<template<class> class Field, class Type>
210 scalar sumMag(const FieldField<Field, Type>& f);
212 TMP_UNARY_FUNCTION(scalar, sumMag)
214 template<template<class> class Field, class Type>
215 Type average(const FieldField<Field, Type>& f);
217 TMP_UNARY_FUNCTION(Type, average)
220 #define G_UNARY_FUNCTION(returnType, gFunc, func, rFunc)                      \
221                                                                               \
222 template<template<class> class Field, class Type>                             \
223 returnType gFunc(const FieldField<Field, Type>& f);                           \
224 TMP_UNARY_FUNCTION(returnType, gFunc)
226 G_UNARY_FUNCTION(Type, gMax, max, max)
227 G_UNARY_FUNCTION(Type, gMin, min, min)
228 G_UNARY_FUNCTION(Type, gSum, sum, sum)
229 G_UNARY_FUNCTION(scalar, gSumMag, sumMag, sum)
231 #undef G_UNARY_FUNCTION
234 template<template<class> class Field, class Type>
235 Type gAverage(const FieldField<Field, Type>& f);
237 TMP_UNARY_FUNCTION(Type, gAverage)
239 #undef TMP_UNARY_FUNCTION
242 BINARY_FUNCTION(Type, Type, Type, max)
243 BINARY_FUNCTION(Type, Type, Type, min)
244 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
245 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
247 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
248 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
249 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
250 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
253 /* * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * */
255 UNARY_OPERATOR(Type, Type, -, negate)
257 #ifndef __INTEL_COMPILER
258 BINARY_OPERATOR(Type, Type, scalar, *, multiply)
259 BINARY_OPERATOR(Type, scalar, Type, *, multiply)
260 #endif
261 BINARY_OPERATOR(Type, Type, scalar, /, divide)
263 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, multiply)
264 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, multiply)
266 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide)
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 #define PRODUCT_OPERATOR(product, op, opFunc)                                 \
272                                                                               \
273 template<template<class> class Field, class Type1, class Type2>               \
274 void opFunc                                                                   \
275 (                                                                             \
276     FieldField<Field, typename product<Type1, Type2>::type>& f,               \
277     const FieldField<Field, Type1>& f1,                                       \
278     const FieldField<Field, Type2>& f2                                        \
279 );                                                                            \
280                                                                               \
281 template<template<class> class Field, class Type1, class Type2>               \
282 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
283 operator op                                                                   \
284 (                                                                             \
285     const FieldField<Field, Type1>& f1,                                       \
286     const FieldField<Field, Type2>& f2                                        \
287 );                                                                            \
288                                                                               \
289 template<template<class> class Field, class Type1, class Type2>               \
290 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
291 operator op                                                                   \
292 (                                                                             \
293     const FieldField<Field, Type1>& f1,                                       \
294     const tmp<FieldField<Field, Type2> >& tf2                                 \
295 );                                                                            \
296                                                                               \
297 template<template<class> class Field, class Type1, class Type2>               \
298 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
299 operator op                                                                   \
300 (                                                                             \
301     const tmp<FieldField<Field, Type1> >& tf1,                                \
302     const FieldField<Field, Type2>& f2                                        \
303 );                                                                            \
304                                                                               \
305 template<template<class> class Field, class Type1, class Type2>               \
306 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
307 operator op                                                                   \
308 (                                                                             \
309     const tmp<FieldField<Field, Type1> >& tf1,                                \
310     const tmp<FieldField<Field, Type2> >& tf2                                 \
311 );                                                                            \
312                                                                               \
313 template                                                                      \
314 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>  \
315 void opFunc                                                                   \
316 (                                                                             \
317     FieldField<Field, typename product<Type, Form>::type>& f,                 \
318     const FieldField<Field, Type>& f1,                                        \
319     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
320 );                                                                            \
321                                                                               \
322 template                                                                      \
323 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>  \
324 tmp<FieldField<Field, typename product<Type, Form>::type> >                   \
325 operator op                                                                   \
326 (                                                                             \
327     const FieldField<Field, Type>& f1,                                        \
328     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
329 );                                                                            \
330                                                                               \
331 template                                                                      \
332 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>  \
333 tmp<FieldField<Field, typename product<Type, Form>::type> >                   \
334 operator op                                                                   \
335 (                                                                             \
336     const tmp<FieldField<Field, Type> >& tf1,                                 \
337     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
338 );                                                                            \
339                                                                               \
340 template                                                                      \
341 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>  \
342 void opFunc                                                                   \
343 (                                                                             \
344     FieldField<Field, typename product<Form, Type>::type>& f,                 \
345     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
346     const FieldField<Field, Type>& f1                                         \
347 );                                                                            \
348                                                                               \
349 template                                                                      \
350 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>  \
351 tmp<FieldField<Field, typename product<Form, Type>::type> >                   \
352 operator op                                                                   \
353 (                                                                             \
354     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
355     const FieldField<Field, Type>& f1                                         \
356 );                                                                            \
357                                                                               \
358 template                                                                      \
359 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>  \
360 tmp<FieldField<Field, typename product<Form, Type>::type> >                   \
361 operator op                                                                   \
362 (                                                                             \
363     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
364     const tmp<FieldField<Field, Type> >& tf1                                  \
367 PRODUCT_OPERATOR(typeOfSum, +, add)
368 PRODUCT_OPERATOR(typeOfSum, -, subtract)
370 PRODUCT_OPERATOR(outerProduct, *, outer)
371 PRODUCT_OPERATOR(crossProduct, ^, cross)
372 PRODUCT_OPERATOR(innerProduct, &, dot)
373 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
375 #undef PRODUCT_OPERATOR
378 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
380 } // End namespace Foam
382 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
384 #include "undefFieldFunctionsM.H"
386 // ************************************************************************* //