1 /*---------------------------------------------------------------------------* \
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 #define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc) \
41 GeometricField<ReturnType, PatchField, GeoMesh>& res, \
42 const GeometricField<Type1, PatchField, GeoMesh>& gf1 \
45 Foam::Func(res.internalField(), gf1.internalField()); \
46 Foam::Func(res.boundaryField(), gf1.boundaryField()); \
50 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
52 const GeometricField<Type1, PatchField, GeoMesh>& gf1 \
55 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
57 new GeometricField<ReturnType, PatchField, GeoMesh> \
61 #Func "(" + gf1.name() + ')', \
68 Dfunc(gf1.dimensions()) \
72 Foam::Func(tRes(), gf1); \
78 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
80 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1 \
83 const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
85 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
87 reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
90 #Func "(" + gf1.name() + ')', \
91 Dfunc(gf1.dimensions()) \
95 Foam::Func(tRes(), gf1); \
97 reuseTmpGeometricField \
98 <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1); \
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 #define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc) \
111 GeometricField<ReturnType, PatchField, GeoMesh>& res, \
112 const GeometricField<Type1, PatchField, GeoMesh>& gf1 \
115 Foam::OpFunc(res.internalField(), gf1.internalField()); \
116 Foam::OpFunc(res.boundaryField(), gf1.boundaryField()); \
120 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
122 const GeometricField<Type1, PatchField, GeoMesh>& gf1 \
125 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
127 new GeometricField<ReturnType, PatchField, GeoMesh> \
138 Dfunc(gf1.dimensions()) \
142 Foam::OpFunc(tRes(), gf1); \
148 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
150 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1 \
153 const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
155 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
157 reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
161 Dfunc(gf1.dimensions()) \
165 Foam::OpFunc(tRes(), gf1); \
167 reuseTmpGeometricField \
168 <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1); \
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 #define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
181 GeometricField<ReturnType, PatchField, GeoMesh>& res, \
182 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
183 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
186 Foam::Func(res.internalField(), gf1.internalField(), gf2.internalField());\
187 Foam::Func(res.boundaryField(), gf1.boundaryField(), gf2.boundaryField());\
191 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
193 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
194 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
197 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
199 new GeometricField<ReturnType, PatchField, GeoMesh> \
203 #Func "(" + gf1.name() + ',' + gf2.name() + ')', \
210 Func(gf1.dimensions(), gf2.dimensions()) \
214 Foam::Func(tRes(), gf1, gf2); \
220 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
222 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
223 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
226 const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
228 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
230 reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
233 #Func "(" + gf1.name() + ',' + gf2.name() + ')', \
234 Func(gf1.dimensions(), gf2.dimensions()) \
238 Foam::Func(tRes(), gf1, gf2); \
240 reuseTmpGeometricField \
241 <ReturnType, Type2, PatchField, GeoMesh>::clear(tgf2); \
247 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
249 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
250 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
253 const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
255 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
257 reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
260 #Func "(" + gf1.name() + ',' + gf2.name() + ')', \
261 Func(gf1.dimensions(), gf2.dimensions()) \
265 Foam::Func(tRes(), gf1, gf2); \
267 reuseTmpGeometricField \
268 <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1); \
274 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
276 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
277 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
280 const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
281 const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
283 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
285 reuseTmpTmpGeometricField \
286 <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh> \
291 #Func "(" + gf1.name() + ',' + gf2.name() + ')', \
292 Func(gf1.dimensions(), gf2.dimensions()) \
296 Foam::Func(tRes(), gf1, gf2); \
298 reuseTmpTmpGeometricField \
299 <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh> \
300 ::clear(tgf1, tgf2); \
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
312 GeometricField<ReturnType, PatchField, GeoMesh>& res, \
313 const dimensioned<Type1>& dt1, \
314 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
317 Foam::Func(res.internalField(), dt1.value(), gf2.internalField()); \
318 Foam::Func(res.boundaryField(), dt1.value(), gf2.boundaryField()); \
322 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
324 const dimensioned<Type1>& dt1, \
325 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
328 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
330 new GeometricField<ReturnType, PatchField, GeoMesh> \
334 #Func "(" + dt1.name() + ',' + gf2.name() + ')', \
341 Func(dt1.dimensions(), gf2.dimensions()) \
345 Foam::Func(tRes(), dt1, gf2); \
351 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
354 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
357 return Func(dimensioned<Type1>(t1), gf2); \
362 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
364 const dimensioned<Type1>& dt1, \
365 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
368 const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
370 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
372 reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
375 #Func "(" + dt1.name() + gf2.name() + ',' + ')', \
376 Func(dt1.dimensions(), gf2.dimensions()) \
380 Foam::Func(tRes(), dt1, gf2); \
382 reuseTmpGeometricField \
383 <ReturnType, Type2, PatchField, GeoMesh>::clear(tgf2); \
389 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
392 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
395 return Func(dimensioned<Type1>(t1), tgf2); \
399 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
404 GeometricField<ReturnType, PatchField, GeoMesh>& res, \
405 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
406 const dimensioned<Type2>& dt2 \
409 Foam::Func(res.internalField(), gf1.internalField(), dt2.value()); \
410 Foam::Func(res.boundaryField(), gf1.boundaryField(), dt2.value()); \
414 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
416 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
417 const dimensioned<Type2>& dt2 \
420 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
422 new GeometricField<ReturnType, PatchField, GeoMesh> \
426 #Func "(" + gf1.name() + ',' + dt2.name() + ')', \
433 Func(gf1.dimensions(), dt2.dimensions()) \
437 Foam::Func(tRes(), gf1, dt2); \
443 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
445 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
449 return Func(gf1, dimensioned<Type2>(t2)); \
454 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
456 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
457 const dimensioned<Type2>& dt2 \
460 const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
462 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
464 reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
467 #Func "(" + gf1.name() + ',' + dt2.name() + ')', \
468 Func(gf1.dimensions(), dt2.dimensions()) \
472 Foam::Func(tRes(), gf1, dt2); \
474 reuseTmpGeometricField \
475 <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1); \
481 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func \
483 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
487 return Func(tgf1, dimensioned<Type2>(t2)); \
491 #define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func) \
492 BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
493 BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
496 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
498 #define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
503 GeometricField<ReturnType, PatchField, GeoMesh>& res, \
504 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
505 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
509 (res.internalField(), gf1.internalField(), gf2.internalField()); \
511 (res.boundaryField(), gf1.boundaryField(), gf2.boundaryField()); \
515 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
517 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
518 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
521 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
523 new GeometricField<ReturnType, PatchField, GeoMesh> \
527 '(' + gf1.name() + OpName + gf2.name() + ')', \
534 gf1.dimensions() Op gf2.dimensions() \
538 Foam::OpFunc(tRes(), gf1, gf2); \
544 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
546 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
547 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
550 const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
552 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
554 reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
557 '(' + gf1.name() + OpName + gf2.name() + ')', \
558 gf1.dimensions() Op gf2.dimensions() \
562 Foam::OpFunc(tRes(), gf1, gf2); \
564 reuseTmpGeometricField \
565 <ReturnType, Type2, PatchField, GeoMesh>::clear(tgf2); \
571 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
573 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
574 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
577 const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
579 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
581 reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
584 '(' + gf1.name() + OpName + gf2.name() + ')', \
585 gf1.dimensions() Op gf2.dimensions() \
589 Foam::OpFunc(tRes(), gf1, gf2); \
591 reuseTmpGeometricField \
592 <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1); \
598 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
600 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
601 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
604 const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
605 const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
607 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
609 reuseTmpTmpGeometricField \
610 <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh>::New \
614 '(' + gf1.name() + OpName + gf2.name() + ')', \
615 gf1.dimensions() Op gf2.dimensions() \
619 Foam::OpFunc(tRes(), gf1, gf2); \
621 reuseTmpTmpGeometricField \
622 <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh> \
623 ::clear(tgf1, tgf2); \
629 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
631 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
636 GeometricField<ReturnType, PatchField, GeoMesh>& res, \
637 const dimensioned<Type1>& dt1, \
638 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
641 Foam::OpFunc(res.internalField(), dt1.value(), gf2.internalField()); \
642 Foam::OpFunc(res.boundaryField(), dt1.value(), gf2.boundaryField()); \
646 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
648 const dimensioned<Type1>& dt1, \
649 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
652 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
654 new GeometricField<ReturnType, PatchField, GeoMesh> \
658 '(' + dt1.name() + OpName + gf2.name() + ')', \
665 dt1.dimensions() Op gf2.dimensions() \
669 Foam::OpFunc(tRes(), dt1, gf2); \
675 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
678 const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
681 return dimensioned<Type1>(t1) Op gf2; \
686 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
688 const dimensioned<Type1>& dt1, \
689 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
692 const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2(); \
694 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
696 reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
699 '(' + dt1.name() + OpName + gf2.name() + ')', \
700 dt1.dimensions() Op gf2.dimensions() \
704 Foam::OpFunc(tRes(), dt1, gf2); \
706 reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh> \
713 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
716 const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2 \
719 return dimensioned<Type1>(t1) Op tgf2; \
723 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
728 GeometricField<ReturnType, PatchField, GeoMesh>& res, \
729 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
730 const dimensioned<Type2>& dt2 \
733 Foam::OpFunc(res.internalField(), gf1.internalField(), dt2.value()); \
734 Foam::OpFunc(res.boundaryField(), gf1.boundaryField(), dt2.value()); \
738 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
740 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
741 const dimensioned<Type2>& dt2 \
744 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
746 new GeometricField<ReturnType, PatchField, GeoMesh> \
750 '(' + gf1.name() + OpName + dt2.name() + ')', \
757 gf1.dimensions() Op dt2.dimensions() \
761 Foam::OpFunc(tRes(), gf1, dt2); \
767 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
769 const GeometricField<Type1, PatchField, GeoMesh>& gf1, \
773 return gf1 Op dimensioned<Type2>(t2); \
778 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
780 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
781 const dimensioned<Type2>& dt2 \
784 const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1(); \
786 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes \
788 reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
791 '(' + gf1.name() + OpName + dt2.name() + ')', \
792 gf1.dimensions() Op dt2.dimensions() \
796 Foam::OpFunc(tRes(), gf1, dt2); \
798 reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh> \
805 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op \
807 const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1, \
811 return tgf1 Op dimensioned<Type2>(t2); \
815 #define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
816 BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
817 BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
820 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
822 } // End namespace Foam
824 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //