initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / GeometricFields / GeometricField / GeometricFieldFunctions.H
blob88a5f16ce150fc314d0f8416e536a94976da43f5
1 /*---------------------------------------------------------------------------*\
2   =========                 | 
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 "GeometricScalarField.H"
29 #define TEMPLATE \
30     template<class Type, template<class> class PatchField, class GeoMesh>
31 #include "GeometricFieldFunctionsM.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
38 // * * * * * * * * * * * * * * * Global functions  * * * * * * * * * * * * * //
40 template<class Type, template<class> class PatchField, class GeoMesh>
41 void component
43     GeometricField
44     <
45         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
46         PatchField,
47         GeoMesh
48     >& gcf,
49     const GeometricField<Type, PatchField, GeoMesh>& gf,
50     const direction d
53 template<class Type, template<class> class PatchField, class GeoMesh>
54 void T
56      GeometricField<Type, PatchField, GeoMesh>& gf,
57      const GeometricField<Type, PatchField, GeoMesh>& gf1
60 template<class Type, template<class> class PatchField, class GeoMesh, int r>
61 void pow
63     GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>& gf,
64     const GeometricField<Type, PatchField, GeoMesh>& gf1
67 template<class Type, template<class> class PatchField, class GeoMesh, int r>
68 tmp
70     GeometricField
71     <typename powProduct<Type, r>::type, PatchField, GeoMesh>
73 pow
75     const GeometricField<Type, PatchField, GeoMesh>& gf,
76     typename powProduct<Type, r>::type
79 template<class Type, template<class> class PatchField, class GeoMesh, int r>
80 tmp
82     GeometricField
83     <typename powProduct<Type, r>::type, PatchField, GeoMesh>
85 pow
87     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf,
88     typename powProduct<Type, r>::type
91 template<class Type, template<class> class PatchField, class GeoMesh>
92 void sqr
94     GeometricField
95     <typename outerProduct<Type, Type>::type, PatchField, GeoMesh>& gf,
96     const GeometricField<Type, PatchField, GeoMesh>& gf1
99 template<class Type, template<class> class PatchField, class GeoMesh>
102     GeometricField
103     <
104         typename outerProduct<Type, Type>::type,
105         PatchField,
106         GeoMesh
107     >
109 sqr(const GeometricField<Type, PatchField, GeoMesh>& gf);
111 template<class Type, template<class> class PatchField, class GeoMesh>
114     GeometricField
115     <
116         typename outerProduct<Type, Type>::type,
117         PatchField,
118         GeoMesh
119     >
121 sqr(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf);
123 template<class Type, template<class> class PatchField, class GeoMesh>
124 void magSqr
126     GeometricField<scalar, PatchField, GeoMesh>& gsf,
127     const GeometricField<Type, PatchField, GeoMesh>& gf
130 template<class Type, template<class> class PatchField, class GeoMesh>
131 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
133     const GeometricField<Type, PatchField, GeoMesh>& gf
136 template<class Type, template<class> class PatchField, class GeoMesh>
137 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
139     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
142 template<class Type, template<class> class PatchField, class GeoMesh>
143 void mag
145     GeometricField<scalar, PatchField, GeoMesh>& gsf,
146     const GeometricField<Type, PatchField, GeoMesh>& gf
149 template<class Type, template<class> class PatchField, class GeoMesh>
150 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
152     const GeometricField<Type, PatchField, GeoMesh>& gf
155 template<class Type, template<class> class PatchField, class GeoMesh>
156 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
158     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
161 template<class Type, template<class> class PatchField, class GeoMesh>
162 void cmptAv
164     GeometricField
165     <
166         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
167         PatchField,
168         GeoMesh
169     >& gcf,
170     const GeometricField<Type, PatchField, GeoMesh>& gf
173 template<class Type, template<class> class PatchField, class GeoMesh>
176     GeometricField
177     <
178         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
179         PatchField,
180         GeoMesh
181     >
183 cmptAv(const GeometricField<Type, PatchField, GeoMesh>& gf);
185 template<class Type, template<class> class PatchField, class GeoMesh>
188     GeometricField
189     <
190         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
191         PatchField,
192         GeoMesh
193     >
195 cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf);
198 #define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc)       \
199                                                                               \
200 template<class Type, template<class> class PatchField, class GeoMesh>         \
201 dimensioned<returnType> func                                                  \
202 (                                                                             \
203     const GeometricField<Type, PatchField, GeoMesh>& gf                       \
204 );                                                                            \
205                                                                               \
206 template<class Type, template<class> class PatchField, class GeoMesh>         \
207 dimensioned<returnType> func                                                  \
208 (                                                                             \
209     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
212 UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, max, gMax)
213 UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, min, gMin)
215 #undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
218 #define UNARY_REDUCTION_FUNCTION(returnType, func, gFunc)                     \
219                                                                               \
220 template<class Type, template<class> class PatchField, class GeoMesh>         \
221 dimensioned<returnType> func                                                  \
222 (                                                                             \
223     const GeometricField<Type, PatchField, GeoMesh>& gf                       \
224 );                                                                            \
225                                                                               \
226 template<class Type, template<class> class PatchField, class GeoMesh>         \
227 dimensioned<returnType> func                                                  \
228 (                                                                             \
229     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
232 UNARY_REDUCTION_FUNCTION(Type, sum, gSum)
233 UNARY_REDUCTION_FUNCTION(scalar, sumMag, gSumMag)
234 UNARY_REDUCTION_FUNCTION(Type, average, gAverage)
236 #undef UNARY_REDUCTION_FUNCTION
239 BINARY_FUNCTION(Type, Type, Type, max)
240 BINARY_FUNCTION(Type, Type, Type, min)
241 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
242 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
244 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
245 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
246 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
247 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
250 // * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * //
252 UNARY_OPERATOR(Type, Type, -, negate, transform)
254 #ifndef __INTEL_COMPILER
255 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
256 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
257 #endif
258 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
260 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
261 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
263 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 #define PRODUCT_OPERATOR(product, op, opFunc)                                 \
269                                                                               \
270 template                                                                      \
271 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
272 void opFunc                                                                   \
273 (                                                                             \
274     GeometricField                                                            \
275     <typename product<Type1, Type2>::type, PatchField, GeoMesh>& gf,          \
276     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
277     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
278 );                                                                            \
279                                                                               \
280 template                                                                      \
281 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
282 tmp                                                                           \
283 <                                                                             \
284     GeometricField                                                            \
285         <typename product<Type1, Type2>::type, PatchField, GeoMesh>           \
286 >                                                                             \
287 operator op                                                                   \
288 (                                                                             \
289     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
290     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
291 );                                                                            \
292                                                                               \
293 template                                                                      \
294 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
295 tmp                                                                           \
296 <                                                                             \
297     GeometricField                                                            \
298     <typename product<Type1, Type2>::type, PatchField, GeoMesh>               \
299 >                                                                             \
300 operator op                                                                   \
301 (                                                                             \
302     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
303     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
304 );                                                                            \
305                                                                               \
306 template                                                                      \
307 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
308 tmp                                                                           \
309 <                                                                             \
310     GeometricField                                                            \
311     <typename product<Type1, Type2>::type, PatchField, GeoMesh>               \
312 >                                                                             \
313 operator op                                                                   \
314 (                                                                             \
315     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
316     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
317 );                                                                            \
318                                                                               \
319 template                                                                      \
320 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
321 tmp                                                                           \
322 <                                                                             \
323     GeometricField                                                            \
324     <typename product<Type1, Type2>::type, PatchField, GeoMesh>               \
325 >                                                                             \
326 operator op                                                                   \
327 (                                                                             \
328     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
329     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
330 );                                                                            \
331                                                                               \
332 template                                                                      \
333 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
334 void opFunc                                                                   \
335 (                                                                             \
336     GeometricField                                                            \
337     <typename product<Type, Form>::type, PatchField, GeoMesh>& gf,            \
338     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
339     const dimensioned<Form>& dvs                                              \
340 );                                                                            \
341                                                                               \
342 template                                                                      \
343 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
344 tmp                                                                           \
345 <                                                                             \
346     GeometricField                                                            \
347     <typename product<Type, Form>::type, PatchField, GeoMesh>                 \
348 >                                                                             \
349 operator op                                                                   \
350 (                                                                             \
351     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
352     const dimensioned<Form>& dvs                                              \
353 );                                                                            \
354                                                                               \
355 template                                                                      \
356 <                                                                             \
357     class Form,                                                               \
358     class Cmpt,                                                               \
359     int nCmpt,                                                                \
360     class Type, template<class> class PatchField,                             \
361     class GeoMesh                                                             \
362 >                                                                             \
363 tmp                                                                           \
364 <                                                                             \
365     GeometricField                                                            \
366     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
367 >                                                                             \
368 operator op                                                                   \
369 (                                                                             \
370     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
371     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
372 );                                                                            \
373                                                                               \
374 template                                                                      \
375 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
376 tmp                                                                           \
377 <                                                                             \
378     GeometricField                                                            \
379     <typename product<Type, Form>::type, PatchField, GeoMesh>                 \
380 >                                                                             \
381 operator op                                                                   \
382 (                                                                             \
383     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1,              \
384     const dimensioned<Form>& dvs                                              \
385 );                                                                            \
386                                                                               \
387 template                                                                      \
388 <                                                                             \
389     class Form,                                                               \
390     class Cmpt,                                                               \
391     int nCmpt,                                                                \
392     class Type, template<class> class PatchField,                             \
393     class GeoMesh                                                             \
394 >                                                                             \
395 tmp                                                                           \
396 <                                                                             \
397     GeometricField                                                            \
398     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
399 >                                                                             \
400 operator op                                                                   \
401 (                                                                             \
402     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1,              \
403     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
404 );                                                                            \
405                                                                               \
406 template                                                                      \
407 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
408 void opFunc                                                                   \
409 (                                                                             \
410     GeometricField                                                            \
411     <typename product<Form, Type>::type, PatchField, GeoMesh>& gf,            \
412     const dimensioned<Form>& dvs,                                             \
413     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
414 );                                                                            \
415                                                                               \
416 template                                                                      \
417 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
418 tmp                                                                           \
419 <                                                                             \
420     GeometricField                                                            \
421     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
422 >                                                                             \
423 operator op                                                                   \
424 (                                                                             \
425     const dimensioned<Form>& dvs,                                             \
426     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
427 );                                                                            \
428                                                                               \
429 template                                                                      \
430 <                                                                             \
431     class Form,                                                               \
432     class Cmpt,                                                               \
433     int nCmpt,                                                                \
434     class Type, template<class> class PatchField,                             \
435     class GeoMesh                                                             \
436 >                                                                             \
437 tmp                                                                           \
438 <                                                                             \
439     GeometricField                                                            \
440     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
441 >                                                                             \
442 operator op                                                                   \
443 (                                                                             \
444     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
445     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
446 );                                                                            \
447                                                                               \
448 template                                                                      \
449 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
450 tmp                                                                           \
451 <                                                                             \
452     GeometricField                                                            \
453     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
454 >                                                                             \
455 operator op                                                                   \
456 (                                                                             \
457     const dimensioned<Form>& dvs,                                             \
458     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
459 );                                                                            \
460                                                                               \
461 template                                                                      \
462 <                                                                             \
463     class Form,                                                               \
464     class Cmpt,                                                               \
465     int nCmpt,                                                                \
466     class Type, template<class> class PatchField,                             \
467     class GeoMesh                                                             \
468 >                                                                             \
469 tmp                                                                           \
470 <                                                                             \
471     GeometricField                                                            \
472     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
473 >                                                                             \
474 operator op                                                                   \
475 (                                                                             \
476     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
477     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
480 PRODUCT_OPERATOR(typeOfSum, +, add)
481 PRODUCT_OPERATOR(typeOfSum, -, subtract)
483 PRODUCT_OPERATOR(outerProduct, *, outer)
484 PRODUCT_OPERATOR(crossProduct, ^, cross)
485 PRODUCT_OPERATOR(innerProduct, &, dot)
486 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
488 #undef PRODUCT_OPERATOR
491 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
493 } // End namespace Foam
495 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
497 #include "undefFieldFunctionsM.H"
499 // ************************************************************************* //