initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / GeometricFields / GeometricField / GeometricFieldFunctions.C
blob4960a27756b8ada536e80db1d3f97d1ec9ebbdd5
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 "GeometricFieldReuseFunctions.H"
29 #define TEMPLATE \
30     template<class Type, template<class> class PatchField, class GeoMesh>
31 #include "GeometricFieldFunctionsM.C"
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     component(gcf.internalField(), gf.internalField(), d);
54     component(gcf.boundaryField(), gf.boundaryField(), d);
58 template<class Type, template<class> class PatchField, class GeoMesh>
59 void T
61      GeometricField<Type, PatchField, GeoMesh>& gf,
62      const GeometricField<Type, PatchField, GeoMesh>& gf1
65     T(gf.internalField(), gf1.internalField());
66     T(gf.boundaryField(), gf1.boundaryField());
70 template<class Type, template<class> class PatchField, class GeoMesh, int r>
71 void pow
73     GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>& gf,
74     const GeometricField<Type, PatchField, GeoMesh>& gf1
77     pow(gf.internalField(), gf1.internalField(), r);
78     pow(gf.boundaryField(), gf1.boundaryField(), r);
81 template<class Type, template<class> class PatchField, class GeoMesh, int r>
82 tmp<GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh> >
83 pow
85     const GeometricField<Type, PatchField, GeoMesh>& gf,
86     typename powProduct<Type, r>::type
89     typedef typename powProduct<Type, r>::type powProductType;
91     tmp<GeometricField<powProductType, PatchField, GeoMesh> > tPow
92     (
93         new GeometricField<powProductType, PatchField, GeoMesh>
94         (
95             IOobject
96             (
97                 "pow(" + gf.name() + ',' + name(r) + ')',
98                 gf.instance(),
99                 gf.db(),
100                 IOobject::NO_READ,
101                 IOobject::NO_WRITE
102             ),
103             gf.mesh(),
104             pow(gf.dimensions(), r)
105         )
106     );
108     pow<Type, r, PatchField, GeoMesh>(tPow(), gf);
110     return tPow;
114 template<class Type, template<class> class PatchField, class GeoMesh, int r>
115 tmp<GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh> >
118     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf,
119     typename powProduct<Type, r>::type
122     typedef typename powProduct<Type, r>::type powProductType;
124     const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
126     tmp<GeometricField<powProductType, PatchField, GeoMesh> > tPow
127     (
128         new GeometricField<powProductType, PatchField, GeoMesh>
129         (
130             IOobject
131             (
132                 "pow(" + gf.name() + ',' + name(r) + ')',
133                 gf.instance(),
134                 gf.db(),
135                 IOobject::NO_READ,
136                 IOobject::NO_WRITE
137             ),
138             gf.mesh(),
139             pow(gf.dimensions(), r)
140         )
141     );
143     pow<Type, r, PatchField, GeoMesh>(tPow(), gf);
145     tgf.clear();
147     return tPow;
151 template<class Type, template<class> class PatchField, class GeoMesh>
152 void sqr
154     GeometricField
155     <typename outerProduct<Type, Type>::type, PatchField, GeoMesh>& gf,
156     const GeometricField<Type, PatchField, GeoMesh>& gf1
159     sqr(gf.internalField(), gf1.internalField());
160     sqr(gf.boundaryField(), gf1.boundaryField());
163 template<class Type, template<class> class PatchField, class GeoMesh>
166     GeometricField
167     <
168         typename outerProduct<Type, Type>::type,
169         PatchField,
170         GeoMesh
171     >
173 sqr(const GeometricField<Type, PatchField, GeoMesh>& gf)
175     typedef typename outerProduct<Type, Type>::type outerProductType;
177     tmp<GeometricField<outerProductType, PatchField, GeoMesh> > tSqr
178     (
179         new GeometricField<outerProductType, PatchField, GeoMesh>
180         (
181             IOobject
182             (
183                 "sqr(" + gf.name() + ')',
184                 gf.instance(),
185                 gf.db(),
186                 IOobject::NO_READ,
187                 IOobject::NO_WRITE
188             ),
189             gf.mesh(),
190             sqr(gf.dimensions())
191         )
192     );
194     sqr(tSqr(), gf);
196     return tSqr;
199 template<class Type, template<class> class PatchField, class GeoMesh>
202     GeometricField
203     <
204         typename outerProduct<Type, Type>::type,
205         PatchField,
206         GeoMesh
207     >
209 sqr(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf)
211     typedef typename outerProduct<Type, Type>::type outerProductType;
213     const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
215     tmp<GeometricField<outerProductType, PatchField, GeoMesh> > tSqr
216     (
217         new GeometricField<outerProductType, PatchField, GeoMesh>
218         (
219             IOobject
220             (
221                 "sqr(" + gf.name() + ')',
222                 gf.instance(),
223                 gf.db(),
224                 IOobject::NO_READ,
225                 IOobject::NO_WRITE
226             ),
227             gf.mesh(),
228             sqr(gf.dimensions())
229         )
230     );
232     sqr(tSqr(), gf);
234     tgf.clear();
236     return tSqr;
240 template<class Type, template<class> class PatchField, class GeoMesh>
241 void magSqr
243     GeometricField<scalar, PatchField, GeoMesh>& gsf,
244     const GeometricField<Type, PatchField, GeoMesh>& gf
247     magSqr(gsf.internalField(), gf.internalField());
248     magSqr(gsf.boundaryField(), gf.boundaryField());
251 template<class Type, template<class> class PatchField, class GeoMesh>
252 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
254     const GeometricField<Type, PatchField, GeoMesh>& gf
257     tmp<GeometricField<scalar, PatchField, GeoMesh> > tMagSqr
258     (
259         new GeometricField<scalar, PatchField, GeoMesh>
260         (
261             IOobject
262             (
263                 "magSqr(" + gf.name() + ')',
264                 gf.instance(),
265                 gf.db(),
266                 IOobject::NO_READ,
267                 IOobject::NO_WRITE
268             ),
269             gf.mesh(),
270             sqr(gf.dimensions())
271         )
272     );
274     magSqr(tMagSqr(), gf);
276     return tMagSqr;
279 template<class Type, template<class> class PatchField, class GeoMesh>
280 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
282     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
285     const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
287     tmp<GeometricField<scalar, PatchField, GeoMesh> > tMagSqr
288     (
289         new GeometricField<scalar, PatchField, GeoMesh>
290         (
291             IOobject
292             (
293                 "magSqr(" + gf.name() + ')',
294                 gf.instance(),
295                 gf.db(),
296                 IOobject::NO_READ,
297                 IOobject::NO_WRITE
298             ),
299             gf.mesh(),
300             sqr(gf.dimensions())
301         )
302     );
304     magSqr(tMagSqr(), gf);
306     tgf.clear();
308     return tMagSqr;
312 template<class Type, template<class> class PatchField, class GeoMesh>
313 void mag
315     GeometricField<scalar, PatchField, GeoMesh>& gsf,
316     const GeometricField<Type, PatchField, GeoMesh>& gf
319     mag(gsf.internalField(), gf.internalField());
320     mag(gsf.boundaryField(), gf.boundaryField());
323 template<class Type, template<class> class PatchField, class GeoMesh>
324 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
326     const GeometricField<Type, PatchField, GeoMesh>& gf
329     tmp<GeometricField<scalar, PatchField, GeoMesh> > tMag
330     (
331         new GeometricField<scalar, PatchField, GeoMesh>
332         (
333             IOobject
334             (
335                 "mag(" + gf.name() + ')',
336                 gf.instance(),
337                 gf.db(),
338                 IOobject::NO_READ,
339                 IOobject::NO_WRITE
340             ),
341             gf.mesh(),
342             gf.dimensions()
343         )
344     );
346     mag(tMag(), gf);
348     return tMag;
351 template<class Type, template<class> class PatchField, class GeoMesh>
352 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
354     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
357     const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
359     tmp<GeometricField<scalar, PatchField, GeoMesh> > tMag
360     (
361         new GeometricField<scalar, PatchField, GeoMesh>
362         (
363             IOobject
364             (
365                 "mag(" + gf.name() + ')',
366                 gf.instance(),
367                 gf.db(),
368                 IOobject::NO_READ,
369                 IOobject::NO_WRITE
370             ),
371             gf.mesh(),
372             gf.dimensions()
373         )
374     );
376     mag(tMag(), gf);
378     tgf.clear();
380     return tMag;
384 template<class Type, template<class> class PatchField, class GeoMesh>
385 void cmptAv
387     GeometricField
388     <
389         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
390         PatchField,
391         GeoMesh
392     >& gcf,
393     const GeometricField<Type, PatchField, GeoMesh>& gf
396     cmptAv(gcf.internalField(), gf.internalField());
397     cmptAv(gcf.boundaryField(), gf.boundaryField());
400 template<class Type, template<class> class PatchField, class GeoMesh>
403     GeometricField
404     <
405         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
406         PatchField,
407         GeoMesh
408     >
410 cmptAv(const GeometricField<Type, PatchField, GeoMesh>& gf)
412     typedef typename GeometricField<Type, PatchField, GeoMesh>::cmptType
413         cmptType;
415     tmp<GeometricField<cmptType, PatchField, GeoMesh> > CmptAv
416     (
417         new GeometricField<scalar, PatchField, GeoMesh>
418         (
419             IOobject
420             (
421                 "cmptAv(" + gf.name() + ')',
422                 gf.instance(),
423                 gf.db(),
424                 IOobject::NO_READ,
425                 IOobject::NO_WRITE
426             ),
427             gf.mesh(),
428             gf.dimensions()
429         )
430     );
432     cmptAv(CmptAv(), gf);
434     return CmptAv;
437 template<class Type, template<class> class PatchField, class GeoMesh>
440     GeometricField
441     <
442         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
443         PatchField,
444         GeoMesh
445     >
447 cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf)
449     typedef typename GeometricField<Type, PatchField, GeoMesh>::cmptType 
450         cmptType;
452     const GeometricField<Type, PatchField, GeoMesh>& gf = tgf();
454     tmp<GeometricField<cmptType, PatchField, GeoMesh> > CmptAv
455     (
456         new GeometricField<scalar, PatchField, GeoMesh>
457         (
458             IOobject
459             (
460                 "cmptAv(" + gf.name() + ')',
461                 gf.instance(),
462                 gf.db(),
463                 IOobject::NO_READ,
464                 IOobject::NO_WRITE
465             ),
466             gf.mesh(),
467             gf.dimensions()
468         )
469     );
471     cmptAv(CmptAv(), gf);
473     tgf.clear();
475     return CmptAv;
479 #define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc)       \
480                                                                               \
481 template<class Type, template<class> class PatchField, class GeoMesh>         \
482 dimensioned<returnType> func                                                  \
483 (                                                                             \
484     const GeometricField<Type, PatchField, GeoMesh>& gf                       \
485 )                                                                             \
486 {                                                                             \
487     return dimensioned<Type>                                                  \
488     (                                                                         \
489         #func "(" + gf.name() + ')',                                          \
490         gf.dimensions(),                                                      \
491         Foam::func(gFunc(gf.internalField()), gFunc(gf.boundaryField()))      \
492     );                                                                        \
493 }                                                                             \
494                                                                               \
495 template<class Type, template<class> class PatchField, class GeoMesh>         \
496 dimensioned<returnType> func                                                  \
497 (                                                                             \
498     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
499 )                                                                             \
500 {                                                                             \
501     dimensioned<returnType> res = func(tgf1());                               \
502     tgf1.clear();                                                             \
503     return res;                                                               \
506 UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, max, gMax)
507 UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, min, gMin)
509 #undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
512 #define UNARY_REDUCTION_FUNCTION(returnType, func, gFunc)                     \
513                                                                               \
514 template<class Type, template<class> class PatchField, class GeoMesh>         \
515 dimensioned<returnType> func                                                  \
516 (                                                                             \
517     const GeometricField<Type, PatchField, GeoMesh>& gf                       \
518 )                                                                             \
519 {                                                                             \
520     return dimensioned<Type>                                                  \
521     (                                                                         \
522         #func "(" + gf.name() + ')',                                          \
523         gf.dimensions(),                                                      \
524         gFunc(gf.internalField())                                             \
525     );                                                                        \
526 }                                                                             \
527                                                                               \
528 template<class Type, template<class> class PatchField, class GeoMesh>         \
529 dimensioned<returnType> func                                                  \
530 (                                                                             \
531     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
532 )                                                                             \
533 {                                                                             \
534     dimensioned<returnType> res = func(tgf1());                               \
535     tgf1.clear();                                                             \
536     return res;                                                               \
539 UNARY_REDUCTION_FUNCTION(Type, sum, gSum)
540 UNARY_REDUCTION_FUNCTION(scalar, sumMag, gSumMag)
541 UNARY_REDUCTION_FUNCTION(Type, average, gAverage)
543 #undef UNARY_REDUCTION_FUNCTION
546 BINARY_FUNCTION(Type, Type, Type, max)
547 BINARY_FUNCTION(Type, Type, Type, min)
548 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
549 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
551 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
552 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
553 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
554 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
557 // * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * //
559 UNARY_OPERATOR(Type, Type, -, negate, transform)
561 #ifndef __INTEL_COMPILER
562 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
563 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
564 #endif
565 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
567 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
568 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
570 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
573 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
575 #define PRODUCT_OPERATOR(product, op, opFunc)                                 \
576                                                                               \
577 template                                                                      \
578 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
579 void opFunc                                                                   \
580 (                                                                             \
581     GeometricField                                                            \
582     <typename product<Type1, Type2>::type, PatchField, GeoMesh>& gf,          \
583     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
584     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
585 )                                                                             \
586 {                                                                             \
587     Foam::opFunc(gf.internalField(), gf1.internalField(), gf2.internalField());\
588     Foam::opFunc(gf.boundaryField(), gf1.boundaryField(), gf2.boundaryField());\
589 }                                                                             \
590                                                                               \
591 template                                                                      \
592 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
593 tmp                                                                           \
594 <                                                                             \
595     GeometricField<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
596 >                                                                             \
597 operator op                                                                   \
598 (                                                                             \
599     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
600     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
601 )                                                                             \
602 {                                                                             \
603     typedef typename product<Type1, Type2>::type productType;                 \
604     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes               \
605     (                                                                         \
606         new GeometricField<productType, PatchField, GeoMesh>                  \
607         (                                                                     \
608             IOobject                                                          \
609             (                                                                 \
610                 '(' + gf1.name() + #op + gf2.name() + ')',                    \
611                 gf1.instance(),                                               \
612                 gf1.db(),                                                     \
613                 IOobject::NO_READ,                                            \
614                 IOobject::NO_WRITE                                            \
615             ),                                                                \
616             gf1.mesh(),                                                       \
617             gf1.dimensions() op gf2.dimensions()                              \
618         )                                                                     \
619     );                                                                        \
620                                                                               \
621     Foam::opFunc(tRes(), gf1, gf2);                                           \
622                                                                               \
623     return tRes;                                                              \
624 }                                                                             \
625                                                                               \
626 template                                                                      \
627 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
628 tmp                                                                           \
629 <                                                                             \
630     GeometricField<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
631 >                                                                             \
632 operator op                                                                   \
633 (                                                                             \
634     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
635     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
636 )                                                                             \
637 {                                                                             \
638     typedef typename product<Type1, Type2>::type productType;                 \
639                                                                               \
640     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
641                                                                               \
642     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes =             \
643         reuseTmpGeometricField<productType, Type2, PatchField, GeoMesh>::New  \
644         (                                                                     \
645             tgf2,                                                             \
646             '(' + gf1.name() + #op + gf2.name() + ')',                        \
647             gf1.dimensions() op gf2.dimensions()                              \
648         );                                                                    \
649                                                                               \
650     Foam::opFunc(tRes(), gf1, gf2);                                           \
651                                                                               \
652     reuseTmpGeometricField<productType, Type2, PatchField, GeoMesh>           \
653     ::clear(tgf2);                                                            \
654                                                                               \
655     return tRes;                                                              \
656 }                                                                             \
657                                                                               \
658 template                                                                      \
659 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
660 tmp                                                                           \
661 <                                                                             \
662     GeometricField<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
663 >                                                                             \
664 operator op                                                                   \
665 (                                                                             \
666     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
667     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
668 )                                                                             \
669 {                                                                             \
670     typedef typename product<Type1, Type2>::type productType;                 \
671                                                                               \
672     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
673                                                                               \
674     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes =             \
675         reuseTmpGeometricField<productType, Type1, PatchField, GeoMesh>::New  \
676         (                                                                     \
677             tgf1,                                                             \
678             '(' + gf1.name() + #op + gf2.name() + ')',                        \
679             gf1.dimensions() op gf2.dimensions()                              \
680         );                                                                    \
681                                                                               \
682     Foam::opFunc(tRes(), gf1, gf2);                                           \
683                                                                               \
684     reuseTmpGeometricField<productType, Type1, PatchField, GeoMesh>           \
685     ::clear(tgf1);                                                            \
686                                                                               \
687     return tRes;                                                              \
688 }                                                                             \
689                                                                               \
690 template                                                                      \
691 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
692 tmp                                                                           \
693 <                                                                             \
694     GeometricField<typename product<Type1, Type2>::type, PatchField, GeoMesh> \
695 >                                                                             \
696 operator op                                                                   \
697 (                                                                             \
698     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
699     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
700 )                                                                             \
701 {                                                                             \
702     typedef typename product<Type1, Type2>::type productType;                 \
703                                                                               \
704     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
705     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
706                                                                               \
707     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes =             \
708         reuseTmpTmpGeometricField                                             \
709         <productType, Type1, Type1, Type2, PatchField, GeoMesh>::New          \
710         (                                                                     \
711             tgf1,                                                             \
712             tgf2,                                                             \
713             '(' + gf1.name() + #op + gf2.name() + ')',                        \
714             gf1.dimensions() op gf2.dimensions()                              \
715         );                                                                    \
716                                                                               \
717     Foam::opFunc(tRes(), gf1, gf2);                                           \
718                                                                               \
719     reuseTmpTmpGeometricField                                                 \
720         <productType, Type1, Type1, Type2, PatchField, GeoMesh>               \
721     ::clear(tgf1, tgf2);                                                      \
722                                                                               \
723     return tRes;                                                              \
724 }                                                                             \
725                                                                               \
726 template                                                                      \
727 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
728 void opFunc                                                                   \
729 (                                                                             \
730     GeometricField                                                            \
731     <typename product<Type, Form>::type, PatchField, GeoMesh>& gf,            \
732     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
733     const dimensioned<Form>& dvs                                              \
734 )                                                                             \
735 {                                                                             \
736     Foam::opFunc(gf.internalField(), gf1.internalField(), dvs.value());       \
737     Foam::opFunc(gf.boundaryField(), gf1.boundaryField(), dvs.value());       \
738 }                                                                             \
739                                                                               \
740 template                                                                      \
741 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
742 tmp<GeometricField<typename product<Type, Form>::type, PatchField, GeoMesh> > \
743 operator op                                                                   \
744 (                                                                             \
745     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
746     const dimensioned<Form>& dvs                                              \
747 )                                                                             \
748 {                                                                             \
749     typedef typename product<Type, Form>::type productType;                   \
750                                                                               \
751     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes               \
752     (                                                                         \
753         new GeometricField<productType, PatchField, GeoMesh>                  \
754         (                                                                     \
755             IOobject                                                          \
756             (                                                                 \
757                 '(' + gf1.name() + #op + dvs.name() + ')',                    \
758                 gf1.instance(),                                               \
759                 gf1.db(),                                                     \
760                 IOobject::NO_READ,                                            \
761                 IOobject::NO_WRITE                                            \
762             ),                                                                \
763             gf1.mesh(),                                                       \
764             gf1.dimensions() op dvs.dimensions()                              \
765         )                                                                     \
766     );                                                                        \
767                                                                               \
768     Foam::opFunc(tRes(), gf1, dvs);                                           \
769                                                                               \
770     return tRes;                                                              \
771 }                                                                             \
772                                                                               \
773 template                                                                      \
774 <                                                                             \
775     class Form,                                                               \
776     class Cmpt,                                                               \
777     int nCmpt,                                                                \
778     class Type, template<class> class PatchField,                             \
779     class GeoMesh                                                             \
780 >                                                                             \
781 tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh> > \
782 operator op                                                                   \
783 (                                                                             \
784     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
785     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
786 )                                                                             \
787 {                                                                             \
788     return gf1 op dimensioned<Form>(static_cast<const Form&>(vs));            \
789 }                                                                             \
790                                                                               \
791                                                                               \
792 template                                                                      \
793 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
794 tmp<GeometricField<typename product<Type, Form>::type, PatchField, GeoMesh> > \
795 operator op                                                                   \
796 (                                                                             \
797     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1,              \
798     const dimensioned<Form>& dvs                                              \
799 )                                                                             \
800 {                                                                             \
801     typedef typename product<Type, Form>::type productType;                   \
802                                                                               \
803     const GeometricField<Type, PatchField, GeoMesh>& gf1 = tgf1();            \
804                                                                               \
805     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes =             \
806         reuseTmpGeometricField<productType, Type, PatchField, GeoMesh>::New   \
807         (                                                                     \
808             tgf1,                                                             \
809             '(' + gf1.name() + #op + dvs.name() + ')',                        \
810             gf1.dimensions() op dvs.dimensions()                              \
811         );                                                                    \
812                                                                               \
813     Foam::opFunc(tRes(), gf1, dvs);                                           \
814                                                                               \
815     reuseTmpGeometricField<productType, Type, PatchField, GeoMesh>            \
816     ::clear(tgf1);                                                            \
817                                                                               \
818     return tRes;                                                              \
819 }                                                                             \
820                                                                               \
821 template                                                                      \
822 <                                                                             \
823     class Form,                                                               \
824     class Cmpt,                                                               \
825     int nCmpt,                                                                \
826     class Type, template<class> class PatchField,                             \
827     class GeoMesh                                                             \
828 >                                                                             \
829 tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh> > \
830 operator op                                                                   \
831 (                                                                             \
832     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1,              \
833     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
834 )                                                                             \
835 {                                                                             \
836     return tgf1 op dimensioned<Form>(static_cast<const Form&>(vs));           \
837 }                                                                             \
838                                                                               \
839                                                                               \
840 template                                                                      \
841 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
842 void opFunc                                                                   \
843 (                                                                             \
844     GeometricField                                                            \
845     <typename product<Form, Type>::type, PatchField, GeoMesh>& gf,            \
846     const dimensioned<Form>& dvs,                                             \
847     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
848 )                                                                             \
849 {                                                                             \
850     Foam::opFunc(gf.internalField(), dvs.value(), gf1.internalField());       \
851     Foam::opFunc(gf.boundaryField(), dvs.value(), gf1.boundaryField());       \
852 }                                                                             \
853                                                                               \
854 template                                                                      \
855 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
856 tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh> > \
857 operator op                                                                   \
858 (                                                                             \
859     const dimensioned<Form>& dvs,                                             \
860     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
861 )                                                                             \
862 {                                                                             \
863     typedef typename product<Form, Type>::type productType;                   \
864     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes               \
865     (                                                                         \
866         new GeometricField<productType, PatchField, GeoMesh>                  \
867         (                                                                     \
868             IOobject                                                          \
869             (                                                                 \
870                 '(' + dvs.name() + #op + gf1.name() + ')',                    \
871                 gf1.instance(),                                               \
872                 gf1.db(),                                                     \
873                 IOobject::NO_READ,                                            \
874                 IOobject::NO_WRITE                                            \
875             ),                                                                \
876             gf1.mesh(),                                                       \
877             dvs.dimensions() op gf1.dimensions()                              \
878         )                                                                     \
879     );                                                                        \
880                                                                               \
881     Foam::opFunc(tRes(), dvs, gf1);                                           \
882                                                                               \
883     return tRes;                                                              \
884 }                                                                             \
885                                                                               \
886 template                                                                      \
887 <                                                                             \
888     class Form,                                                               \
889     class Cmpt,                                                               \
890     int nCmpt,                                                                \
891     class Type, template<class> class PatchField,                             \
892     class GeoMesh                                                             \
893 >                                                                             \
894 tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh> > \
895 operator op                                                                   \
896 (                                                                             \
897     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
898     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
899 )                                                                             \
900 {                                                                             \
901     return dimensioned<Form>(static_cast<const Form&>(vs)) op gf1;            \
902 }                                                                             \
903                                                                               \
904 template                                                                      \
905 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
906 tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh> > \
907 operator op                                                                   \
908 (                                                                             \
909     const dimensioned<Form>& dvs,                                             \
910     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
911 )                                                                             \
912 {                                                                             \
913     typedef typename product<Form, Type>::type productType;                   \
914                                                                               \
915     const GeometricField<Type, PatchField, GeoMesh>& gf1 = tgf1();            \
916                                                                               \
917     tmp<GeometricField<productType, PatchField, GeoMesh> > tRes =             \
918         reuseTmpGeometricField<productType, Type, PatchField, GeoMesh>::New   \
919         (                                                                     \
920             tgf1,                                                             \
921             '(' + dvs.name() + #op + gf1.name() + ')',                        \
922             dvs.dimensions() op gf1.dimensions()                              \
923         );                                                                    \
924                                                                               \
925     Foam::opFunc(tRes(), dvs, gf1);                                           \
926                                                                               \
927     reuseTmpGeometricField<productType, Type, PatchField, GeoMesh>            \
928     ::clear(tgf1);                                                            \
929                                                                               \
930     return tRes;                                                              \
931 }                                                                             \
932                                                                               \
933 template                                                                      \
934 <                                                                             \
935     class Form,                                                               \
936     class Cmpt,                                                               \
937     int nCmpt,                                                                \
938     class Type, template<class> class PatchField,                             \
939     class GeoMesh                                                             \
940 >                                                                             \
941 tmp<GeometricField<typename product<Form, Type>::type, PatchField, GeoMesh> > \
942 operator op                                                                   \
943 (                                                                             \
944     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
945     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
946 )                                                                             \
947 {                                                                             \
948     return dimensioned<Form>(static_cast<const Form&>(vs)) op tgf1;           \
951 PRODUCT_OPERATOR(typeOfSum, +, add)
952 PRODUCT_OPERATOR(typeOfSum, -, subtract)
954 PRODUCT_OPERATOR(outerProduct, *, outer)
955 PRODUCT_OPERATOR(crossProduct, ^, cross)
956 PRODUCT_OPERATOR(innerProduct, &, dot)
957 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
959 #undef PRODUCT_OPERATOR
962 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
964 } // End namespace Foam
966 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
968 #include "undefFieldFunctionsM.H"
970 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //