FreeFOAM The Cross-Platform CFD Toolkit
FieldFieldFunctions.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 
28 #define TEMPLATE template<template<class> class Field, class Type>
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 /* * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * */
37 
38 template<template<class> class Field, class Type>
39 void component
40 (
41  FieldField<Field, typename FieldField<Field, Type>::cmptType>& sf,
42  const FieldField<Field, Type>& f,
43  const direction d
44 );
45 
46 template<template<class> class Field, class Type>
47 void T(FieldField<Field, Type>& f1, const FieldField<Field, Type>& f2);
48 
49 
50 template<template<class> class Field, class Type, int r>
51 void pow
52 (
53  FieldField<Field, typename powProduct<Type, r>::type>& f,
54  const FieldField<Field, Type>& vf
55 );
56 
57 template<template<class> class Field, class Type, int r>
59 pow
60 (
61  const FieldField<Field, Type>& f, typename powProduct<Type, r>::type
62  = pTraits<typename powProduct<Type, r>::type>::zero
63 );
64 
65 template<template<class> class Field, class Type, int r>
67 pow
68 (
69  const tmp<FieldField<Field, Type> >& tf, typename powProduct<Type, r>::type
70  = pTraits<typename powProduct<Type, r>::type>::zero
71 );
72 
73 
74 template<template<class> class Field, class Type>
75 void sqr
76 (
77  FieldField<Field, typename outerProduct<Type, Type>::type>& f,
78  const FieldField<Field, Type>& vf
79 );
80 
81 template<template<class> class Field, class Type>
83 sqr(const FieldField<Field, Type>& f);
84 
85 template<template<class> class Field, class Type>
87 sqr(const tmp<FieldField<Field, Type> >& tf);
88 
89 template<template<class> class Field, class Type>
90 void magSqr(FieldField<Field, scalar>& sf, const FieldField<Field, Type>& f);
91 
92 template<template<class> class Field, class Type>
93 tmp<FieldField<Field, scalar> > magSqr(const FieldField<Field, Type>& f);
94 
95 template<template<class> class Field, class Type>
96 tmp<FieldField<Field, scalar> > magSqr(const tmp<FieldField<Field, Type> >& tf);
97 
98 template<template<class> class Field, class Type>
99 void mag(FieldField<Field, scalar>& sf, const FieldField<Field, Type>& f);
100 
101 template<template<class> class Field, class Type>
102 tmp<FieldField<Field, scalar> > mag(const FieldField<Field, Type>& f);
103 
104 template<template<class> class Field, class Type>
105 tmp<FieldField<Field, scalar> > mag(const tmp<FieldField<Field, Type> >& tf);
106 
107 
108 template<template<class> class Field, class Type>
109 void cmptMax
110 (
111  FieldField<Field, typename FieldField<Field, Type>::cmptType>& cf,
112  const FieldField<Field, Type>& f
113 );
114 
115 template<template<class> class Field, class Type>
116 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMax
117 (
118  const FieldField<Field, Type>& f
119 );
120 
121 template<template<class> class Field, class Type>
122 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMax
123 (
124  const tmp<FieldField<Field, Type> >& tf
125 );
126 
127 
128 template<template<class> class Field, class Type>
129 void cmptMin
130 (
131  FieldField<Field, typename FieldField<Field, Type>::cmptType>& cf,
132  const FieldField<Field, Type>& f
133 );
134 
135 template<template<class> class Field, class Type>
136 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMin
137 (
138  const FieldField<Field, Type>& f
139 );
140 
141 template<template<class> class Field, class Type>
142 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptMin
143 (
144  const tmp<FieldField<Field, Type> >& tf
145 );
146 
147 
148 template<template<class> class Field, class Type>
149 void cmptAv
150 (
151  FieldField<Field, typename FieldField<Field, Type>::cmptType>& cf,
152  const FieldField<Field, Type>& f
153 );
154 
155 template<template<class> class Field, class Type>
156 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptAv
157 (
158  const FieldField<Field, Type>& f
159 );
160 
161 template<template<class> class Field, class Type>
162 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType> > cmptAv
163 (
164  const tmp<FieldField<Field, Type> >& tf
165 );
166 
167 
168 template<template<class> class Field, class Type>
169 void cmptMag
170 (
171  FieldField<Field, Type>& cf,
172  const FieldField<Field, Type>& f
173 );
174 
175 template<template<class> class Field, class Type>
176 tmp<FieldField<Field, Type> > cmptMag
177 (
178  const FieldField<Field, Type>& f
179 );
180 
181 template<template<class> class Field, class Type>
182 tmp<FieldField<Field, Type> > cmptMag
183 (
184  const tmp<FieldField<Field, Type> >& tf
185 );
186 
187 
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);
192 
193 template<template<class> class Field, class Type>
194 Type max(const FieldField<Field, Type>& f);
195 
196 TMP_UNARY_FUNCTION(Type, max)
197 
198 template<template<class> class Field, class Type>
199 Type min(const FieldField<Field, Type>& f);
200 
201 TMP_UNARY_FUNCTION(Type, min)
202 
203 template<template<class> class Field, class Type>
204 Type sum(const FieldField<Field, Type>& f);
205 
206 TMP_UNARY_FUNCTION(Type, sum)
207 
208 template<template<class> class Field, class Type>
209 scalar sumMag(const FieldField<Field, Type>& f);
210 
211 TMP_UNARY_FUNCTION(scalar, sumMag)
212 
213 template<template<class> class Field, class Type>
214 Type average(const FieldField<Field, Type>& f);
215 
217 
218 
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)
224 
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)
229 
230 #undef G_UNARY_FUNCTION
231 
232 
233 template<template<class> class Field, class Type>
234 Type gAverage(const FieldField<Field, Type>& f);
235 
237 
238 #undef TMP_UNARY_FUNCTION
239 
240 
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)
245 
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)
250 
251 
252 /* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */
253 
254 UNARY_OPERATOR(Type, Type, -, negate)
255 
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)
261 
262 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, multiply)
263 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, multiply)
264 
265 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide)
266 
267 
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 
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 \
364 );
365 
366 PRODUCT_OPERATOR(typeOfSum, +, add)
367 PRODUCT_OPERATOR(typeOfSum, -, subtract)
368 
369 PRODUCT_OPERATOR(outerProduct, *, outer)
370 PRODUCT_OPERATOR(crossProduct, ^, cross)
371 PRODUCT_OPERATOR(innerProduct, &, dot)
372 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
373 
374 #undef PRODUCT_OPERATOR
375 
376 
377 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
378 
379 } // End namespace Foam
380 
381 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
382 
384 
385 // ************************ vim: set sw=4 sts=4 et: ************************ //