1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 \*---------------------------------------------------------------------------*/
28 #include "FieldFieldReuseFunctions.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 #define UNARY_FUNCTION(ReturnType, Type, Func) \
37 FieldField<Field, ReturnType>& res, \
38 const FieldField<Field, Type>& f \
48 tmp<FieldField<Field, ReturnType> > Func \
50 const FieldField<Field, Type>& f \
53 tmp<FieldField<Field, ReturnType> > tRes \
55 FieldField<Field, ReturnType>::NewCalculatedType(f) \
62 tmp<FieldField<Field, ReturnType> > Func \
64 const tmp<FieldField<Field, Type> >& tf \
67 tmp<FieldField<Field, ReturnType> > tRes \
69 reuseTmpFieldField<Field, Type, Type>::New(tf) \
72 reuseTmpFieldField<Field, Type, Type>::clear(tf); \
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 #define UNARY_OPERATOR(ReturnType, Type, Op, OpFunc) \
84 FieldField<Field, ReturnType>& res, \
85 const FieldField<Field, Type>& f \
90 OpFunc(res[i], f[i]); \
95 tmp<FieldField<Field, ReturnType> > operator Op \
97 const FieldField<Field, Type>& f \
100 tmp<FieldField<Field, ReturnType> > tRes \
102 FieldField<Field, Type>::NewCalculatedType(f) \
109 tmp<FieldField<Field, ReturnType> > operator Op \
111 const tmp<FieldField<Field, Type> >& tf \
114 tmp<FieldField<Field, ReturnType> > tRes \
116 reuseTmpFieldField<Field, Type, Type>::New(tf) \
118 OpFunc(tRes(), tf()); \
119 reuseTmpFieldField<Field, Type, Type>::clear(tf); \
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 #define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
131 FieldField<Field, ReturnType>& f, \
132 const FieldField<Field, Type1>& f1, \
133 const FieldField<Field, Type2>& f2 \
138 Func(f[i], f1[i], f2[i]); \
143 tmp<FieldField<Field, ReturnType> > Func \
145 const FieldField<Field, Type1>& f1, \
146 const FieldField<Field, Type2>& f2 \
149 tmp<FieldField<Field, ReturnType> > tRes \
151 FieldField<Field, Type1>::NewCalculatedType(f1) \
153 Func(tRes(), f1, f2); \
158 tmp<FieldField<Field, ReturnType> > Func \
160 const FieldField<Field, Type1>& f1, \
161 const tmp<FieldField<Field, Type2> >& tf2 \
164 tmp<FieldField<Field, ReturnType> > tRes \
166 reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
168 Func(tRes(), f1, tf2()); \
169 reuseTmpFieldField<Field, ReturnType, Type2>::clear(tf2); \
174 tmp<FieldField<Field, ReturnType> > Func \
176 const tmp<FieldField<Field, Type1> >& tf1, \
177 const FieldField<Field, Type2>& f2 \
180 tmp<FieldField<Field, ReturnType> > tRes \
182 reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
184 Func(tRes(), tf1(), f2); \
185 reuseTmpFieldField<Field, ReturnType, Type1>::clear(tf1); \
190 tmp<FieldField<Field, ReturnType> > Func \
192 const tmp<FieldField<Field, Type1> >& tf1, \
193 const tmp<FieldField<Field, Type2> >& tf2 \
196 tmp<FieldField<Field, ReturnType> > tRes \
198 reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type2>:: \
201 Func(tRes(), tf1(), tf2()); \
202 reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type2>:: \
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
215 FieldField<Field, ReturnType>& f, \
216 const FieldField<Field, Type1>& f1, \
222 Func(f[i], f1[i], s); \
227 tmp<FieldField<Field, ReturnType> > Func \
229 const FieldField<Field, Type1>& f1, \
233 tmp<FieldField<Field, ReturnType> > tRes \
235 FieldField<Field, Type1>::NewCalculatedType(f1) \
237 Func(tRes(), f1, s); \
242 tmp<FieldField<Field, ReturnType> > Func \
244 const tmp<FieldField<Field, Type1> >& tf1, \
248 tmp<FieldField<Field, ReturnType> > tRes \
250 reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
252 Func(tRes(), tf1(), s); \
253 reuseTmpFieldField<Field, ReturnType, Type1>::clear(tf1); \
258 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
263 FieldField<Field, ReturnType>& f, \
265 const FieldField<Field, Type2>& f2 \
270 Func(f[i], s, f2[i]); \
275 tmp<FieldField<Field, ReturnType> > Func \
278 const FieldField<Field, Type2>& f2 \
281 tmp<FieldField<Field, ReturnType> > tRes \
283 FieldField<Field, Type2>::NewCalculatedType(f2) \
285 Func(tRes(), s, f2); \
290 tmp<FieldField<Field, ReturnType> > Func \
293 const tmp<FieldField<Field, Type2> >& tf2 \
296 tmp<FieldField<Field, ReturnType> > tRes \
298 reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
300 Func(tRes(), s, tf2()); \
301 reuseTmpFieldField<Field, ReturnType, Type2>::clear(tf2); \
306 #define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func) \
307 BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
308 BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 #define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
318 FieldField<Field, ReturnType>& f, \
319 const FieldField<Field, Type1>& f1, \
320 const FieldField<Field, Type2>& f2 \
325 OpFunc(f[i], f1[i], f2[i]); \
330 tmp<FieldField<Field, ReturnType> > operator Op \
332 const FieldField<Field, Type1>& f1, \
333 const FieldField<Field, Type2>& f2 \
336 tmp<FieldField<Field, ReturnType> > tRes \
338 FieldField<Field, ReturnType>::NewCalculatedType(f1) \
340 OpFunc(tRes(), f1, f2); \
345 tmp<FieldField<Field, ReturnType> > operator Op \
347 const FieldField<Field, Type1>& f1, \
348 const tmp<FieldField<Field, Type2> >& tf2 \
351 tmp<FieldField<Field, ReturnType> > tRes \
353 reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
355 OpFunc(tRes(), f1, tf2()); \
356 reuseTmpFieldField<Field, ReturnType, Type2>::clear(tf2); \
361 tmp<FieldField<Field, ReturnType> > operator Op \
363 const tmp<FieldField<Field, Type1> >& tf1, \
364 const FieldField<Field, Type2>& f2 \
367 tmp<FieldField<Field, ReturnType> > tRes \
369 reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
371 OpFunc(tRes(), tf1(), f2); \
372 reuseTmpFieldField<Field, ReturnType, Type1>::clear(tf1); \
377 tmp<FieldField<Field, ReturnType> > operator Op \
379 const tmp<FieldField<Field, Type1> >& tf1, \
380 const tmp<FieldField<Field, Type2> >& tf2 \
383 tmp<FieldField<Field, ReturnType> > tRes \
385 reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type2>:: \
388 OpFunc(tRes(), tf1(), tf2()); \
389 reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type2>:: \
395 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
397 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
402 FieldField<Field, ReturnType>& f, \
404 const FieldField<Field, Type2>& f2 \
409 OpFunc(f[i], s, f2[i]); \
414 tmp<FieldField<Field, ReturnType> > operator Op \
417 const FieldField<Field, Type2>& f2 \
420 tmp<FieldField<Field, ReturnType> > tRes \
422 FieldField<Field, Type2>::NewCalculatedType(f2) \
424 OpFunc(tRes(), s, f2); \
429 tmp<FieldField<Field, ReturnType> > operator Op \
432 const tmp<FieldField<Field, Type2> >& tf2 \
435 tmp<FieldField<Field, ReturnType> > tRes \
437 reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
439 OpFunc(tRes(), s, tf2()); \
440 reuseTmpFieldField<Field, ReturnType, Type2>::clear(tf2); \
445 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc) \
450 FieldField<Field, ReturnType>& f, \
451 const FieldField<Field, Type1>& f1, \
457 OpFunc(f[i], f1[i], s); \
462 tmp<FieldField<Field, ReturnType> > operator Op \
464 const FieldField<Field, Type1>& f1, \
468 tmp<FieldField<Field, ReturnType> > tRes \
470 FieldField<Field, Type1>::NewCalculatedType(f1) \
472 OpFunc(tRes(), f1, s); \
477 tmp<FieldField<Field, ReturnType> > operator Op \
479 const tmp<FieldField<Field, Type1> >& tf1, \
483 tmp<FieldField<Field, ReturnType> > tRes \
485 reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
487 OpFunc(tRes(), tf1(), s); \
488 reuseTmpFieldField<Field, ReturnType, Type1>::clear(tf1); \
493 #define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
494 BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
495 BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)
497 // ************************************************************************* //