1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "DimensionedFieldReuseFunctions.H"
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 #define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc) \
33 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
35 const DimensionedField<Type1, GeoMesh>& df1 \
38 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
40 new DimensionedField<ReturnType, GeoMesh> \
44 #Func "(" + df1.name() + ')', \
49 Dfunc(df1.dimensions()) \
53 Func(tRes().field(), df1.field()); \
59 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
61 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1 \
64 const DimensionedField<Type1, GeoMesh>& df1 = tdf1(); \
66 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
68 reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::New \
71 #Func "(" + df1.name() + ')', \
72 Dfunc(df1.dimensions()) \
76 Func(tRes().field(), df1.field()); \
78 reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::clear(tdf1); \
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86 #define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc) \
89 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
91 const DimensionedField<Type1, GeoMesh>& df1 \
94 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
96 new DimensionedField<ReturnType, GeoMesh> \
105 Dfunc(df1.dimensions()) \
109 Foam::OpFunc(tRes().field(), df1.field()); \
115 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
117 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1 \
120 const DimensionedField<Type1, GeoMesh>& df1 = tdf1(); \
122 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
124 reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::New \
128 Dfunc(df1.dimensions()) \
132 Foam::OpFunc(tRes().field(), df1.field()); \
134 reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::clear(tdf1); \
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 #define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
145 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
147 const DimensionedField<Type1, GeoMesh>& df1, \
148 const DimensionedField<Type2, GeoMesh>& df2 \
151 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
153 new DimensionedField<ReturnType, GeoMesh> \
157 #Func "(" + df1.name() + ',' + df2.name() + ')', \
162 Func(df1.dimensions(), df2.dimensions()) \
166 Func(tRes().field(), df1.field(), df2.field()); \
172 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
174 const DimensionedField<Type1, GeoMesh>& df1, \
175 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2 \
178 const DimensionedField<Type2, GeoMesh>& df2 = tdf2(); \
180 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
182 reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::New \
185 #Func "(" + df1.name() + ',' + df2.name() + ')', \
186 Func(df1.dimensions(), df2.dimensions()) \
190 Func(tRes().field(), df1.field(), df2.field()); \
192 reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::clear(tdf2); \
198 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
200 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1, \
201 const DimensionedField<Type2, GeoMesh>& df2 \
204 const DimensionedField<Type1, GeoMesh>& df1 = tdf1(); \
206 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
208 reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::New \
211 #Func "(" + df1.name() + ',' + df2.name() + ')', \
212 Func(df1.dimensions(), df2.dimensions()) \
216 Func(tRes().field(), df1.field(), df2.field()); \
218 reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::clear(tdf1); \
224 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
226 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1, \
227 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2 \
230 const DimensionedField<Type1, GeoMesh>& df1 = tdf1(); \
231 const DimensionedField<Type2, GeoMesh>& df2 = tdf2(); \
233 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
235 reuseTmpTmpDimensionedField \
236 <ReturnType, Type1, Type1, Type2, GeoMesh>::New \
240 #Func "(" + df1.name() + ',' + df2.name() + ')', \
241 Func(df1.dimensions(), df2.dimensions()) \
245 Func(tRes().field(), df1.field(), df2.field()); \
247 reuseTmpTmpDimensionedField<ReturnType, Type1, Type1, Type2, GeoMesh> \
248 ::clear(tdf1, tdf2); \
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
259 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
261 const dimensioned<Type1>& dt1, \
262 const DimensionedField<Type2, GeoMesh>& df2 \
265 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
267 new DimensionedField<ReturnType, GeoMesh> \
271 #Func "(" + dt1.name() + ',' + df2.name() + ')', \
276 Func(dt1.dimensions(), df2.dimensions()) \
280 Func(tRes().field(), dt1.value(), df2.field()); \
286 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
289 const DimensionedField<Type2, GeoMesh>& df2 \
292 return Func(dimensioned<Type1>(t1), df2); \
297 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
299 const dimensioned<Type1>& dt1, \
300 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2 \
303 const DimensionedField<Type2, GeoMesh>& df2 = tdf2(); \
305 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
307 reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::New \
310 #Func "(" + dt1.name() + ',' + df2.name() + ')', \
311 Func(dt1.dimensions(), df2.dimensions()) \
315 Func(tRes().field(), dt1.value(), df2.field()); \
317 reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::clear(tdf2); \
323 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
326 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2 \
329 return Func(dimensioned<Type2>(t1), tdf2); \
333 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
336 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
338 const DimensionedField<Type1, GeoMesh>& df1, \
339 const dimensioned<Type2>& dt2 \
342 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
344 new DimensionedField<ReturnType, GeoMesh> \
348 #Func "(" + df1.name() + ',' + dt2.name() + ')', \
353 Func(df1.dimensions(), dt2.dimensions()) \
357 Func(tRes().field(), df1.field(), dt2.value()); \
363 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
365 const DimensionedField<Type1, GeoMesh>& df1, \
369 return Func(df1, dimensioned<Type2>(t2)); \
374 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
376 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1, \
377 const dimensioned<Type2>& dt2 \
380 const DimensionedField<Type1, GeoMesh>& df1 = tdf1(); \
382 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
384 reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::New \
387 #Func "(" + df1.name() + ',' + dt2.name() + ')', \
388 Func(df1.dimensions(), dt2.dimensions()) \
392 Func(tRes().field(), df1.field(), dt2.value()); \
394 reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::clear(tdf1); \
400 tmp<DimensionedField<ReturnType, GeoMesh> > Func \
402 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1, \
406 return Func(tdf1, dimensioned<Type2>(t2)); \
410 #define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func) \
411 BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
412 BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
415 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
417 #define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
420 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
422 const DimensionedField<Type1, GeoMesh>& df1, \
423 const DimensionedField<Type2, GeoMesh>& df2 \
426 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
428 new DimensionedField<ReturnType, GeoMesh> \
432 '(' + df1.name() + OpName + df2.name() + ')', \
437 df1.dimensions() Op df2.dimensions() \
441 Foam::OpFunc(tRes().field(), df1.field(), df2.field()); \
447 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
449 const DimensionedField<Type1, GeoMesh>& df1, \
450 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2 \
453 const DimensionedField<Type2, GeoMesh>& df2 = tdf2(); \
455 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
457 reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::New \
460 '(' + df1.name() + OpName + df2.name() + ')', \
461 df1.dimensions() Op df2.dimensions() \
465 Foam::OpFunc(tRes().field(), df1.field(), df2.field()); \
467 reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::clear(tdf2); \
473 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
475 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1, \
476 const DimensionedField<Type2, GeoMesh>& df2 \
479 const DimensionedField<Type1, GeoMesh>& df1 = tdf1(); \
481 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
483 reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::New \
486 '(' + df1.name() + OpName + df2.name() + ')', \
487 df1.dimensions() Op df2.dimensions() \
491 Foam::OpFunc(tRes().field(), df1.field(), df2.field()); \
493 reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::clear(tdf1); \
499 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
501 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1, \
502 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2 \
505 const DimensionedField<Type1, GeoMesh>& df1 = tdf1(); \
506 const DimensionedField<Type2, GeoMesh>& df2 = tdf2(); \
508 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
510 reuseTmpTmpDimensionedField \
511 <ReturnType, Type1, Type1, Type2, GeoMesh>::New \
515 '(' + df1.name() + OpName + df2.name() + ')', \
516 df1.dimensions() Op df2.dimensions() \
520 Foam::OpFunc(tRes().field(), df1.field(), df2.field()); \
522 reuseTmpTmpDimensionedField<ReturnType, Type1, Type1, Type2, GeoMesh>:: \
529 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
531 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
534 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
536 const dimensioned<Type1>& dt1, \
537 const DimensionedField<Type2, GeoMesh>& df2 \
540 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
542 new DimensionedField<ReturnType, GeoMesh> \
546 '(' + dt1.name() + OpName + df2.name() + ')', \
551 dt1.dimensions() Op df2.dimensions() \
555 Foam::OpFunc(tRes().field(), dt1.value(), df2.field()); \
561 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
564 const DimensionedField<Type2, GeoMesh>& df2 \
567 return dimensioned<Type1>(t1) Op df2; \
572 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
574 const dimensioned<Type1>& dt1, \
575 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2 \
578 const DimensionedField<Type2, GeoMesh>& df2 = tdf2(); \
580 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
582 reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::New \
585 '(' + dt1.name() + OpName + df2.name() + ')', \
586 dt1.dimensions() Op df2.dimensions() \
590 Foam::OpFunc(tRes().field(), dt1.value(), tdf2().field()); \
592 reuseTmpDimensionedField<ReturnType, Type2, GeoMesh>::clear(tdf2); \
598 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
601 const tmp<DimensionedField<Type2, GeoMesh> >& tdf2 \
604 return dimensioned<Type1>(t1) Op tdf2; \
608 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
611 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
613 const DimensionedField<Type1, GeoMesh>& df1, \
614 const dimensioned<Type2>& dt2 \
617 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
619 new DimensionedField<ReturnType, GeoMesh> \
623 '(' + df1.name() + OpName + dt2.name() + ')', \
628 df1.dimensions() Op dt2.dimensions() \
632 Foam::OpFunc(tRes().field(), df1.field(), dt2.value()); \
638 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
640 const DimensionedField<Type1, GeoMesh>& df1, \
644 return df1 Op dimensioned<Type2>(t2); \
649 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
651 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1, \
652 const dimensioned<Type2>& dt2 \
655 const DimensionedField<Type1, GeoMesh>& df1 = tdf1(); \
657 tmp<DimensionedField<ReturnType, GeoMesh> > tRes \
659 reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::New \
662 '(' + df1.name() + OpName + dt2.name() + ')', \
663 df1.dimensions() Op dt2.dimensions() \
667 Foam::OpFunc(tRes().field(), tdf1().field(), dt2.value()); \
669 reuseTmpDimensionedField<ReturnType, Type1, GeoMesh>::clear(tdf1); \
675 tmp<DimensionedField<ReturnType, GeoMesh> > operator Op \
677 const tmp<DimensionedField<Type1, GeoMesh> >& tdf1, \
681 return tdf1 Op dimensioned<Type2>(t2); \
684 #define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
685 BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
686 BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
689 // ************************************************************************* //