Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / OpenFOAM / fields / FieldFields / FieldField / FieldFieldFunctions.H
blobc3e89c7b0e03f325728655cf98b7c55c9099bc90
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
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
19     for more details.
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 /* * * * * * * * * * * * * * * * Global functions  * * * * * * * * * * * * * */
38 template<template<class> class Field, class Type>
39 void component
41     FieldField<Field, typename FieldField<Field, Type>::cmptType>& sf,
42     const FieldField<Field, Type>& f,
43     const direction d
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>
51 void pow
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> >
59 pow
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> >
67 pow
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>
75 void sqr
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>
109 void cmptMax
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>
129 void cmptMin
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>
149 void cmptAv
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>
169 void cmptMag
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)                                  \
189                                                                               \
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)                      \
220                                                                               \
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)
259 #endif
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)                                 \
271                                                                               \
272 template<template<class> class Field, class Type1, class Type2>               \
273 void opFunc                                                                   \
274 (                                                                             \
275     FieldField<Field, typename product<Type1, Type2>::type>& f,               \
276     const FieldField<Field, Type1>& f1,                                       \
277     const FieldField<Field, Type2>& f2                                        \
278 );                                                                            \
279                                                                               \
280 template<template<class> class Field, class Type1, class Type2>               \
281 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
282 operator op                                                                   \
283 (                                                                             \
284     const FieldField<Field, Type1>& f1,                                       \
285     const FieldField<Field, Type2>& f2                                        \
286 );                                                                            \
287                                                                               \
288 template<template<class> class Field, class Type1, class Type2>               \
289 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
290 operator op                                                                   \
291 (                                                                             \
292     const FieldField<Field, Type1>& f1,                                       \
293     const tmp<FieldField<Field, Type2> >& tf2                                 \
294 );                                                                            \
295                                                                               \
296 template<template<class> class Field, class Type1, class Type2>               \
297 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
298 operator op                                                                   \
299 (                                                                             \
300     const tmp<FieldField<Field, Type1> >& tf1,                                \
301     const FieldField<Field, Type2>& f2                                        \
302 );                                                                            \
303                                                                               \
304 template<template<class> class Field, class Type1, class Type2>               \
305 tmp<FieldField<Field, typename product<Type1, Type2>::type> >                 \
306 operator op                                                                   \
307 (                                                                             \
308     const tmp<FieldField<Field, Type1> >& tf1,                                \
309     const tmp<FieldField<Field, Type2> >& tf2                                 \
310 );                                                                            \
311                                                                               \
312 template                                                                      \
313 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>  \
314 void opFunc                                                                   \
315 (                                                                             \
316     FieldField<Field, typename product<Type, Form>::type>& f,                 \
317     const FieldField<Field, Type>& f1,                                        \
318     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
319 );                                                                            \
320                                                                               \
321 template                                                                      \
322 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>  \
323 tmp<FieldField<Field, typename product<Type, Form>::type> >                   \
324 operator op                                                                   \
325 (                                                                             \
326     const FieldField<Field, Type>& f1,                                        \
327     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
328 );                                                                            \
329                                                                               \
330 template                                                                      \
331 <template<class> class Field, class Type, class Form, class Cmpt, int nCmpt>  \
332 tmp<FieldField<Field, typename product<Type, Form>::type> >                   \
333 operator op                                                                   \
334 (                                                                             \
335     const tmp<FieldField<Field, Type> >& tf1,                                 \
336     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
337 );                                                                            \
338                                                                               \
339 template                                                                      \
340 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>  \
341 void opFunc                                                                   \
342 (                                                                             \
343     FieldField<Field, typename product<Form, Type>::type>& f,                 \
344     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
345     const FieldField<Field, Type>& f1                                         \
346 );                                                                            \
347                                                                               \
348 template                                                                      \
349 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>  \
350 tmp<FieldField<Field, typename product<Form, Type>::type> >                   \
351 operator op                                                                   \
352 (                                                                             \
353     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
354     const FieldField<Field, Type>& f1                                         \
355 );                                                                            \
356                                                                               \
357 template                                                                      \
358 <template<class> class Field, class Form, class Cmpt, int nCmpt, class Type>  \
359 tmp<FieldField<Field, typename product<Form, Type>::type> >                   \
360 operator op                                                                   \
361 (                                                                             \
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 // ************************************************************************* //