1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "FieldFieldReuseFunctions.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 #define UNARY_FUNCTION(ReturnType, Type, Func) \
36 FieldField<Field, ReturnType>& res, \
37 const FieldField<Field, Type>& f \
47 tmp<FieldField<Field, ReturnType> > Func \
49 const FieldField<Field, Type>& f \
52 tmp<FieldField<Field, ReturnType> > tRes \
54 FieldField<Field, ReturnType>::NewCalculatedType(f) \
61 tmp<FieldField<Field, ReturnType> > Func \
63 const tmp<FieldField<Field, Type> >& tf \
66 tmp<FieldField<Field, ReturnType> > tRes \
68 reuseTmpFieldField<Field, Type, Type>::New(tf) \
71 reuseTmpFieldField<Field, Type, Type>::clear(tf); \
76 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78 #define UNARY_OPERATOR(ReturnType, Type, Op, OpFunc) \
83 FieldField<Field, ReturnType>& res, \
84 const FieldField<Field, Type>& f \
89 OpFunc(res[i], f[i]); \
94 tmp<FieldField<Field, ReturnType> > operator Op \
96 const FieldField<Field, Type>& f \
99 tmp<FieldField<Field, ReturnType> > tRes \
101 FieldField<Field, Type>::NewCalculatedType(f) \
108 tmp<FieldField<Field, ReturnType> > operator Op \
110 const tmp<FieldField<Field, Type> >& tf \
113 tmp<FieldField<Field, ReturnType> > tRes \
115 reuseTmpFieldField<Field, Type, Type>::New(tf) \
117 OpFunc(tRes(), tf()); \
118 reuseTmpFieldField<Field, Type, Type>::clear(tf); \
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 #define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
130 FieldField<Field, ReturnType>& f, \
131 const FieldField<Field, Type1>& f1, \
132 const FieldField<Field, Type2>& f2 \
137 Func(f[i], f1[i], f2[i]); \
142 tmp<FieldField<Field, ReturnType> > Func \
144 const FieldField<Field, Type1>& f1, \
145 const FieldField<Field, Type2>& f2 \
148 tmp<FieldField<Field, ReturnType> > tRes \
150 FieldField<Field, Type1>::NewCalculatedType(f1) \
152 Func(tRes(), f1, f2); \
157 tmp<FieldField<Field, ReturnType> > Func \
159 const FieldField<Field, Type1>& f1, \
160 const tmp<FieldField<Field, Type2> >& tf2 \
163 tmp<FieldField<Field, ReturnType> > tRes \
165 reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
167 Func(tRes(), f1, tf2()); \
168 reuseTmpFieldField<Field, ReturnType, Type2>::clear(tf2); \
173 tmp<FieldField<Field, ReturnType> > Func \
175 const tmp<FieldField<Field, Type1> >& tf1, \
176 const FieldField<Field, Type2>& f2 \
179 tmp<FieldField<Field, ReturnType> > tRes \
181 reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
183 Func(tRes(), tf1(), f2); \
184 reuseTmpFieldField<Field, ReturnType, Type1>::clear(tf1); \
189 tmp<FieldField<Field, ReturnType> > Func \
191 const tmp<FieldField<Field, Type1> >& tf1, \
192 const tmp<FieldField<Field, Type2> >& tf2 \
195 tmp<FieldField<Field, ReturnType> > tRes \
197 reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type2>:: \
200 Func(tRes(), tf1(), tf2()); \
201 reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type2>:: \
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
214 FieldField<Field, ReturnType>& f, \
215 const FieldField<Field, Type1>& f1, \
221 Func(f[i], f1[i], s); \
226 tmp<FieldField<Field, ReturnType> > Func \
228 const FieldField<Field, Type1>& f1, \
232 tmp<FieldField<Field, ReturnType> > tRes \
234 FieldField<Field, Type1>::NewCalculatedType(f1) \
236 Func(tRes(), f1, s); \
241 tmp<FieldField<Field, ReturnType> > Func \
243 const tmp<FieldField<Field, Type1> >& tf1, \
247 tmp<FieldField<Field, ReturnType> > tRes \
249 reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
251 Func(tRes(), tf1(), s); \
252 reuseTmpFieldField<Field, ReturnType, Type1>::clear(tf1); \
257 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
262 FieldField<Field, ReturnType>& f, \
264 const FieldField<Field, Type2>& f2 \
269 Func(f[i], s, f2[i]); \
274 tmp<FieldField<Field, ReturnType> > Func \
277 const FieldField<Field, Type2>& f2 \
280 tmp<FieldField<Field, ReturnType> > tRes \
282 FieldField<Field, Type2>::NewCalculatedType(f2) \
284 Func(tRes(), s, f2); \
289 tmp<FieldField<Field, ReturnType> > Func \
292 const tmp<FieldField<Field, Type2> >& tf2 \
295 tmp<FieldField<Field, ReturnType> > tRes \
297 reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
299 Func(tRes(), s, tf2()); \
300 reuseTmpFieldField<Field, ReturnType, Type2>::clear(tf2); \
305 #define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func) \
306 BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
307 BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 #define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
317 FieldField<Field, ReturnType>& f, \
318 const FieldField<Field, Type1>& f1, \
319 const FieldField<Field, Type2>& f2 \
324 OpFunc(f[i], f1[i], f2[i]); \
329 tmp<FieldField<Field, ReturnType> > operator Op \
331 const FieldField<Field, Type1>& f1, \
332 const FieldField<Field, Type2>& f2 \
335 tmp<FieldField<Field, ReturnType> > tRes \
337 FieldField<Field, ReturnType>::NewCalculatedType(f1) \
339 OpFunc(tRes(), f1, f2); \
344 tmp<FieldField<Field, ReturnType> > operator Op \
346 const FieldField<Field, Type1>& f1, \
347 const tmp<FieldField<Field, Type2> >& tf2 \
350 tmp<FieldField<Field, ReturnType> > tRes \
352 reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
354 OpFunc(tRes(), f1, tf2()); \
355 reuseTmpFieldField<Field, ReturnType, Type2>::clear(tf2); \
360 tmp<FieldField<Field, ReturnType> > operator Op \
362 const tmp<FieldField<Field, Type1> >& tf1, \
363 const FieldField<Field, Type2>& f2 \
366 tmp<FieldField<Field, ReturnType> > tRes \
368 reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
370 OpFunc(tRes(), tf1(), f2); \
371 reuseTmpFieldField<Field, ReturnType, Type1>::clear(tf1); \
376 tmp<FieldField<Field, ReturnType> > operator Op \
378 const tmp<FieldField<Field, Type1> >& tf1, \
379 const tmp<FieldField<Field, Type2> >& tf2 \
382 tmp<FieldField<Field, ReturnType> > tRes \
384 reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type2>:: \
387 OpFunc(tRes(), tf1(), tf2()); \
388 reuseTmpTmpFieldField<Field, ReturnType, Type1, Type1, Type2>:: \
394 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
396 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
401 FieldField<Field, ReturnType>& f, \
403 const FieldField<Field, Type2>& f2 \
408 OpFunc(f[i], s, f2[i]); \
413 tmp<FieldField<Field, ReturnType> > operator Op \
416 const FieldField<Field, Type2>& f2 \
419 tmp<FieldField<Field, ReturnType> > tRes \
421 FieldField<Field, Type2>::NewCalculatedType(f2) \
423 OpFunc(tRes(), s, f2); \
428 tmp<FieldField<Field, ReturnType> > operator Op \
431 const tmp<FieldField<Field, Type2> >& tf2 \
434 tmp<FieldField<Field, ReturnType> > tRes \
436 reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
438 OpFunc(tRes(), s, tf2()); \
439 reuseTmpFieldField<Field, ReturnType, Type2>::clear(tf2); \
444 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc) \
449 FieldField<Field, ReturnType>& f, \
450 const FieldField<Field, Type1>& f1, \
456 OpFunc(f[i], f1[i], s); \
461 tmp<FieldField<Field, ReturnType> > operator Op \
463 const FieldField<Field, Type1>& f1, \
467 tmp<FieldField<Field, ReturnType> > tRes \
469 FieldField<Field, Type1>::NewCalculatedType(f1) \
471 OpFunc(tRes(), f1, s); \
476 tmp<FieldField<Field, ReturnType> > operator Op \
478 const tmp<FieldField<Field, Type1> >& tf1, \
482 tmp<FieldField<Field, ReturnType> > tRes \
484 reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
486 OpFunc(tRes(), tf1(), s); \
487 reuseTmpFieldField<Field, ReturnType, Type1>::clear(tf1); \
492 #define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
493 BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
494 BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)
496 // ************************************************************************* //