initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / GeometricFields / GeometricField / GeometricFieldFunctionsM.C
blob0d4f4eb99d69d47d1af4a48b6c0f6951ae75f147
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 #define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc)                        \
37                                                                               \
38 TEMPLATE                                                                      \
39 void Func                                                                     \
40 (                                                                             \
41     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
42     const GeometricField<Type1, PatchField, GeoMesh>& gf1                     \
43 )                                                                             \
44 {                                                                             \
45     Foam::Func(res.internalField(), gf1.internalField());                     \
46     Foam::Func(res.boundaryField(), gf1.boundaryField());                     \
47 }                                                                             \
48                                                                               \
49 TEMPLATE                                                                      \
50 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
51 (                                                                             \
52     const GeometricField<Type1, PatchField, GeoMesh>& gf1                     \
53 )                                                                             \
54 {                                                                             \
55     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
56     (                                                                         \
57         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
58         (                                                                     \
59             IOobject                                                          \
60             (                                                                 \
61                 #Func "(" + gf1.name() + ')',                                 \
62                 gf1.instance(),                                               \
63                 gf1.db(),                                                     \
64                 IOobject::NO_READ,                                            \
65                 IOobject::NO_WRITE                                            \
66             ),                                                                \
67             gf1.mesh(),                                                       \
68             Dfunc(gf1.dimensions())                                           \
69         )                                                                     \
70     );                                                                        \
71                                                                               \
72     Foam::Func(tRes(), gf1);                                                  \
73                                                                               \
74     return tRes;                                                              \
75 }                                                                             \
76                                                                               \
77 TEMPLATE                                                                      \
78 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
79 (                                                                             \
80     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1              \
81 )                                                                             \
82 {                                                                             \
83     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
84                                                                               \
85     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
86     (                                                                         \
87         reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New   \
88         (                                                                     \
89             tgf1,                                                             \
90             #Func "(" + gf1.name() + ')',                                     \
91             Dfunc(gf1.dimensions())                                           \
92         )                                                                     \
93     );                                                                        \
94                                                                               \
95     Foam::Func(tRes(), gf1);                                                  \
96                                                                               \
97     reuseTmpGeometricField                                                    \
98         <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1);                \
99                                                                               \
100     return tRes;                                                              \
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 #define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)                  \
107                                                                               \
108 TEMPLATE                                                                      \
109 void OpFunc                                                                   \
110 (                                                                             \
111     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
112     const GeometricField<Type1, PatchField, GeoMesh>& gf1                     \
113 )                                                                             \
114 {                                                                             \
115     Foam::OpFunc(res.internalField(), gf1.internalField());                   \
116     Foam::OpFunc(res.boundaryField(), gf1.boundaryField());                   \
117 }                                                                             \
118                                                                               \
119 TEMPLATE                                                                      \
120 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
121 (                                                                             \
122     const GeometricField<Type1, PatchField, GeoMesh>& gf1                     \
123 )                                                                             \
124 {                                                                             \
125     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
126     (                                                                         \
127         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
128         (                                                                     \
129             IOobject                                                          \
130             (                                                                 \
131                 #Op + gf1.name(),                                             \
132                 gf1.instance(),                                               \
133                 gf1.db(),                                                     \
134                 IOobject::NO_READ,                                            \
135                 IOobject::NO_WRITE                                            \
136             ),                                                                \
137             gf1.mesh(),                                                       \
138             Dfunc(gf1.dimensions())                                           \
139         )                                                                     \
140     );                                                                        \
141                                                                               \
142     Foam::OpFunc(tRes(), gf1);                                                \
143                                                                               \
144     return tRes;                                                              \
145 }                                                                             \
146                                                                               \
147 TEMPLATE                                                                      \
148 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
149 (                                                                             \
150     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1              \
151 )                                                                             \
152 {                                                                             \
153     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
154                                                                               \
155     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
156     (                                                                         \
157         reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New   \
158         (                                                                     \
159             tgf1,                                                             \
160             #Op + gf1.name(),                                                 \
161             Dfunc(gf1.dimensions())                                           \
162         )                                                                     \
163     );                                                                        \
164                                                                               \
165     Foam::OpFunc(tRes(), gf1);                                                \
166                                                                               \
167     reuseTmpGeometricField                                                    \
168         <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1);                \
169                                                                               \
170     return tRes;                                                              \
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 #define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)                       \
177                                                                               \
178 TEMPLATE                                                                      \
179 void Func                                                                     \
180 (                                                                             \
181     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
182     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
183     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
184 )                                                                             \
185 {                                                                             \
186     Foam::Func(res.internalField(), gf1.internalField(), gf2.internalField());\
187     Foam::Func(res.boundaryField(), gf1.boundaryField(), gf2.boundaryField());\
188 }                                                                             \
189                                                                               \
190 TEMPLATE                                                                      \
191 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
192 (                                                                             \
193     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
194     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
195 )                                                                             \
196 {                                                                             \
197     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
198     (                                                                         \
199         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
200         (                                                                     \
201             IOobject                                                          \
202             (                                                                 \
203                 #Func "(" + gf1.name() + ',' + gf2.name() + ')',              \
204                 gf1.instance(),                                               \
205                 gf1.db(),                                                     \
206                 IOobject::NO_READ,                                            \
207                 IOobject::NO_WRITE                                            \
208             ),                                                                \
209             gf1.mesh(),                                                       \
210             Func(gf1.dimensions(), gf2.dimensions())                          \
211         )                                                                     \
212     );                                                                        \
213                                                                               \
214     Foam::Func(tRes(), gf1, gf2);                                             \
215                                                                               \
216     return tRes;                                                              \
217 }                                                                             \
218                                                                               \
219 TEMPLATE                                                                      \
220 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
221 (                                                                             \
222     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
223     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
224 )                                                                             \
225 {                                                                             \
226     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
227                                                                               \
228     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
229     (                                                                         \
230         reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New   \
231         (                                                                     \
232             tgf2,                                                             \
233             #Func "(" + gf1.name() + ',' + gf2.name() + ')',                  \
234             Func(gf1.dimensions(), gf2.dimensions())                          \
235         )                                                                     \
236     );                                                                        \
237                                                                               \
238     Foam::Func(tRes(), gf1, gf2);                                             \
239                                                                               \
240     reuseTmpGeometricField                                                    \
241         <ReturnType, Type2, PatchField, GeoMesh>::clear(tgf2);                \
242                                                                               \
243     return tRes;                                                              \
244 }                                                                             \
245                                                                               \
246 TEMPLATE                                                                      \
247 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
248 (                                                                             \
249     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
250     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
251 )                                                                             \
252 {                                                                             \
253     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
254                                                                               \
255     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
256     (                                                                         \
257         reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New   \
258         (                                                                     \
259             tgf1,                                                             \
260             #Func "(" + gf1.name() + ',' + gf2.name() + ')',                  \
261             Func(gf1.dimensions(), gf2.dimensions())                          \
262         )                                                                     \
263     );                                                                        \
264                                                                               \
265     Foam::Func(tRes(), gf1, gf2);                                             \
266                                                                               \
267     reuseTmpGeometricField                                                    \
268         <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1);                \
269                                                                               \
270     return tRes;                                                              \
271 }                                                                             \
272                                                                               \
273 TEMPLATE                                                                      \
274 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
275 (                                                                             \
276     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
277     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
278 )                                                                             \
279 {                                                                             \
280     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
281     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
282                                                                               \
283     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
284     (                                                                         \
285         reuseTmpTmpGeometricField                                             \
286             <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh>            \
287         ::New                                                                 \
288         (                                                                     \
289             tgf1,                                                             \
290             tgf2,                                                             \
291             #Func "(" + gf1.name() + ',' + gf2.name() + ')',                  \
292             Func(gf1.dimensions(), gf2.dimensions())                          \
293         )                                                                     \
294     );                                                                        \
295                                                                               \
296     Foam::Func(tRes(), gf1, gf2);                                             \
297                                                                               \
298     reuseTmpTmpGeometricField                                                 \
299         <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh>                \
300         ::clear(tgf1, tgf2);                                                  \
301                                                                               \
302     return tRes;                                                              \
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)               \
308                                                                               \
309 TEMPLATE                                                                      \
310 void Func                                                                     \
311 (                                                                             \
312     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
313     const dimensioned<Type1>& dt1,                                            \
314     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
315 )                                                                             \
316 {                                                                             \
317     Foam::Func(res.internalField(), dt1.value(), gf2.internalField());        \
318     Foam::Func(res.boundaryField(), dt1.value(), gf2.boundaryField());        \
319 }                                                                             \
320                                                                               \
321 TEMPLATE                                                                      \
322 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
323 (                                                                             \
324     const dimensioned<Type1>& dt1,                                            \
325     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
326 )                                                                             \
327 {                                                                             \
328     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
329     (                                                                         \
330         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
331         (                                                                     \
332             IOobject                                                          \
333             (                                                                 \
334                 #Func "(" + dt1.name() + ',' + gf2.name() + ')',              \
335                 gf2.instance(),                                               \
336                 gf2.db(),                                                     \
337                 IOobject::NO_READ,                                            \
338                 IOobject::NO_WRITE                                            \
339             ),                                                                \
340             gf2.mesh(),                                                       \
341             Func(dt1.dimensions(), gf2.dimensions())                          \
342         )                                                                     \
343     );                                                                        \
344                                                                               \
345     Foam::Func(tRes(), dt1, gf2);                                             \
346                                                                               \
347     return tRes;                                                              \
348 }                                                                             \
349                                                                               \
350 TEMPLATE                                                                      \
351 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
352 (                                                                             \
353     const Type1& t1,                                                          \
354     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
355 )                                                                             \
356 {                                                                             \
357     return Func(dimensioned<Type1>(t1), gf2);                                 \
358 }                                                                             \
359                                                                               \
360                                                                               \
361 TEMPLATE                                                                      \
362 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
363 (                                                                             \
364     const dimensioned<Type1>& dt1,                                            \
365     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
366 )                                                                             \
367 {                                                                             \
368     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
369                                                                               \
370     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
371     (                                                                         \
372         reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New   \
373         (                                                                     \
374             tgf2,                                                             \
375             #Func "(" + dt1.name() + gf2.name() + ',' + ')',                  \
376             Func(dt1.dimensions(), gf2.dimensions())                          \
377         )                                                                     \
378     );                                                                        \
379                                                                               \
380     Foam::Func(tRes(), dt1, gf2);                                             \
381                                                                               \
382     reuseTmpGeometricField                                                    \
383         <ReturnType, Type2, PatchField, GeoMesh>::clear(tgf2);                \
384                                                                               \
385     return tRes;                                                              \
386 }                                                                             \
387                                                                               \
388 TEMPLATE                                                                      \
389 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
390 (                                                                             \
391     const Type1& t1,                                                          \
392     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
393 )                                                                             \
394 {                                                                             \
395     return Func(dimensioned<Type1>(t1), tgf2);                                \
399 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)               \
400                                                                               \
401 TEMPLATE                                                                      \
402 void Func                                                                     \
403 (                                                                             \
404     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
405     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
406     const dimensioned<Type2>& dt2                                             \
407 )                                                                             \
408 {                                                                             \
409     Foam::Func(res.internalField(), gf1.internalField(), dt2.value());        \
410     Foam::Func(res.boundaryField(), gf1.boundaryField(), dt2.value());        \
411 }                                                                             \
412                                                                               \
413 TEMPLATE                                                                      \
414 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
415 (                                                                             \
416     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
417     const dimensioned<Type2>& dt2                                             \
418 )                                                                             \
419 {                                                                             \
420     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
421     (                                                                         \
422         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
423         (                                                                     \
424             IOobject                                                          \
425             (                                                                 \
426                 #Func "(" + gf1.name() + ',' + dt2.name() + ')',              \
427                 gf1.instance(),                                               \
428                 gf1.db(),                                                     \
429                 IOobject::NO_READ,                                            \
430                 IOobject::NO_WRITE                                            \
431             ),                                                                \
432             gf1.mesh(),                                                       \
433             Func(gf1.dimensions(), dt2.dimensions())                          \
434         )                                                                     \
435     );                                                                        \
436                                                                               \
437     Foam::Func(tRes(), gf1, dt2);                                             \
438                                                                               \
439     return tRes;                                                              \
440 }                                                                             \
441                                                                               \
442 TEMPLATE                                                                      \
443 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
444 (                                                                             \
445     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
446     const Type2& t2                                                           \
447 )                                                                             \
448 {                                                                             \
449     return Func(gf1, dimensioned<Type2>(t2));                                 \
450 }                                                                             \
451                                                                               \
452                                                                               \
453 TEMPLATE                                                                      \
454 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
455 (                                                                             \
456     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
457     const dimensioned<Type2>& dt2                                             \
458 )                                                                             \
459 {                                                                             \
460     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
461                                                                               \
462     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
463     (                                                                         \
464         reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New   \
465         (                                                                     \
466             tgf1,                                                             \
467             #Func "(" + gf1.name() + ',' + dt2.name() + ')',                  \
468             Func(gf1.dimensions(), dt2.dimensions())                          \
469         )                                                                     \
470     );                                                                        \
471                                                                               \
472     Foam::Func(tRes(), gf1, dt2);                                             \
473                                                                               \
474     reuseTmpGeometricField                                                    \
475         <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1);                \
476                                                                               \
477     return tRes;                                                              \
478 }                                                                             \
479                                                                               \
480 TEMPLATE                                                                      \
481 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > Func                    \
482 (                                                                             \
483     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
484     const Type2& t2                                                           \
485 )                                                                             \
486 {                                                                             \
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)         \
499                                                                               \
500 TEMPLATE                                                                      \
501 void OpFunc                                                                   \
502 (                                                                             \
503     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
504     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
505     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
506 )                                                                             \
507 {                                                                             \
508     Foam::OpFunc                                                              \
509         (res.internalField(), gf1.internalField(), gf2.internalField());      \
510     Foam::OpFunc                                                              \
511         (res.boundaryField(), gf1.boundaryField(), gf2.boundaryField());      \
512 }                                                                             \
513                                                                               \
514 TEMPLATE                                                                      \
515 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
516 (                                                                             \
517     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
518     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
519 )                                                                             \
520 {                                                                             \
521     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
522     (                                                                         \
523         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
524         (                                                                     \
525             IOobject                                                          \
526             (                                                                 \
527                 '(' + gf1.name() + OpName + gf2.name() + ')',                 \
528                 gf1.instance(),                                               \
529                 gf1.db(),                                                     \
530                 IOobject::NO_READ,                                            \
531                 IOobject::NO_WRITE                                            \
532             ),                                                                \
533             gf1.mesh(),                                                       \
534             gf1.dimensions() Op gf2.dimensions()                              \
535         )                                                                     \
536     );                                                                        \
537                                                                               \
538     Foam::OpFunc(tRes(), gf1, gf2);                                           \
539                                                                               \
540     return tRes;                                                              \
541 }                                                                             \
542                                                                               \
543 TEMPLATE                                                                      \
544 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
545 (                                                                             \
546     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
547     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
548 )                                                                             \
549 {                                                                             \
550     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
551                                                                               \
552     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
553     (                                                                         \
554         reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New   \
555         (                                                                     \
556             tgf2,                                                             \
557             '(' + gf1.name() + OpName + gf2.name() + ')',                     \
558             gf1.dimensions() Op gf2.dimensions()                              \
559         )                                                                     \
560     );                                                                        \
561                                                                               \
562     Foam::OpFunc(tRes(), gf1, gf2);                                           \
563                                                                               \
564     reuseTmpGeometricField                                                    \
565         <ReturnType, Type2, PatchField, GeoMesh>::clear(tgf2);                \
566                                                                               \
567     return tRes;                                                              \
568 }                                                                             \
569                                                                               \
570 TEMPLATE                                                                      \
571 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
572 (                                                                             \
573     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
574     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
575 )                                                                             \
576 {                                                                             \
577     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
578                                                                               \
579     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
580     (                                                                         \
581         reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New   \
582         (                                                                     \
583             tgf1,                                                             \
584             '(' + gf1.name() + OpName + gf2.name() + ')',                     \
585             gf1.dimensions() Op gf2.dimensions()                              \
586         )                                                                     \
587     );                                                                        \
588                                                                               \
589     Foam::OpFunc(tRes(), gf1, gf2);                                           \
590                                                                               \
591     reuseTmpGeometricField                                                    \
592         <ReturnType, Type1, PatchField, GeoMesh>::clear(tgf1);                \
593                                                                               \
594     return tRes;                                                              \
595 }                                                                             \
596                                                                               \
597 TEMPLATE                                                                      \
598 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
599 (                                                                             \
600     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
601     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
602 )                                                                             \
603 {                                                                             \
604     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
605     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
606                                                                               \
607     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
608     (                                                                         \
609         reuseTmpTmpGeometricField                                             \
610             <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh>::New       \
611         (                                                                     \
612             tgf1,                                                             \
613             tgf2,                                                             \
614             '(' + gf1.name() + OpName + gf2.name() + ')',                     \
615             gf1.dimensions() Op gf2.dimensions()                              \
616         )                                                                     \
617     );                                                                        \
618                                                                               \
619     Foam::OpFunc(tRes(), gf1, gf2);                                           \
620                                                                               \
621     reuseTmpTmpGeometricField                                                 \
622         <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh>                \
623         ::clear(tgf1, tgf2);                                                  \
624                                                                               \
625     return tRes;                                                              \
629 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
631 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
632                                                                               \
633 TEMPLATE                                                                      \
634 void OpFunc                                                                   \
635 (                                                                             \
636     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
637     const dimensioned<Type1>& dt1,                                            \
638     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
639 )                                                                             \
640 {                                                                             \
641     Foam::OpFunc(res.internalField(), dt1.value(), gf2.internalField());      \
642     Foam::OpFunc(res.boundaryField(), dt1.value(), gf2.boundaryField());      \
643 }                                                                             \
644                                                                               \
645 TEMPLATE                                                                      \
646 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
647 (                                                                             \
648     const dimensioned<Type1>& dt1,                                            \
649     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
650 )                                                                             \
651 {                                                                             \
652     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
653     (                                                                         \
654         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
655         (                                                                     \
656             IOobject                                                          \
657             (                                                                 \
658                 '(' + dt1.name() + OpName + gf2.name() + ')',                 \
659                 gf2.instance(),                                               \
660                 gf2.db(),                                                     \
661                 IOobject::NO_READ,                                            \
662                 IOobject::NO_WRITE                                            \
663             ),                                                                \
664             gf2.mesh(),                                                       \
665             dt1.dimensions() Op gf2.dimensions()                              \
666         )                                                                     \
667     );                                                                        \
668                                                                               \
669     Foam::OpFunc(tRes(), dt1, gf2);                                           \
670                                                                               \
671     return tRes;                                                              \
672 }                                                                             \
673                                                                               \
674 TEMPLATE                                                                      \
675 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
676 (                                                                             \
677     const Type1& t1,                                                          \
678     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
679 )                                                                             \
680 {                                                                             \
681     return dimensioned<Type1>(t1) Op gf2;                                     \
682 }                                                                             \
683                                                                               \
684                                                                               \
685 TEMPLATE                                                                      \
686 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
687 (                                                                             \
688     const dimensioned<Type1>& dt1,                                            \
689     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
690 )                                                                             \
691 {                                                                             \
692     const GeometricField<Type2, PatchField, GeoMesh>& gf2 = tgf2();           \
693                                                                               \
694     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
695     (                                                                         \
696         reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New   \
697         (                                                                     \
698             tgf2,                                                             \
699             '(' + dt1.name() + OpName + gf2.name() + ')',                     \
700             dt1.dimensions() Op gf2.dimensions()                              \
701         )                                                                     \
702     );                                                                        \
703                                                                               \
704     Foam::OpFunc(tRes(), dt1, gf2);                                           \
705                                                                               \
706     reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>            \
707         ::clear(tgf2);                                                        \
708                                                                               \
709     return tRes;                                                              \
710 }                                                                             \
711                                                                               \
712 TEMPLATE                                                                      \
713 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
714 (                                                                             \
715     const Type1& t1,                                                          \
716     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
717 )                                                                             \
718 {                                                                             \
719     return dimensioned<Type1>(t1) Op tgf2;                                    \
723 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
724                                                                               \
725 TEMPLATE                                                                      \
726 void OpFunc                                                                   \
727 (                                                                             \
728     GeometricField<ReturnType, PatchField, GeoMesh>& res,                     \
729     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
730     const dimensioned<Type2>& dt2                                             \
731 )                                                                             \
732 {                                                                             \
733     Foam::OpFunc(res.internalField(), gf1.internalField(), dt2.value());      \
734     Foam::OpFunc(res.boundaryField(), gf1.boundaryField(), dt2.value());      \
735 }                                                                             \
736                                                                               \
737 TEMPLATE                                                                      \
738 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
739 (                                                                             \
740     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
741     const dimensioned<Type2>& dt2                                             \
742 )                                                                             \
743 {                                                                             \
744     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
745     (                                                                         \
746         new GeometricField<ReturnType, PatchField, GeoMesh>                   \
747         (                                                                     \
748             IOobject                                                          \
749             (                                                                 \
750                 '(' + gf1.name() + OpName + dt2.name() + ')',                 \
751                 gf1.instance(),                                               \
752                 gf1.db(),                                                     \
753                 IOobject::NO_READ,                                            \
754                 IOobject::NO_WRITE                                            \
755             ),                                                                \
756             gf1.mesh(),                                                       \
757             gf1.dimensions() Op dt2.dimensions()                              \
758         )                                                                     \
759     );                                                                        \
760                                                                               \
761     Foam::OpFunc(tRes(), gf1, dt2);                                           \
762                                                                               \
763     return tRes;                                                              \
764 }                                                                             \
765                                                                               \
766 TEMPLATE                                                                      \
767 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
768 (                                                                             \
769     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
770     const Type2& t2                                                           \
771 )                                                                             \
772 {                                                                             \
773     return gf1 Op dimensioned<Type2>(t2);                                     \
774 }                                                                             \
775                                                                               \
776                                                                               \
777 TEMPLATE                                                                      \
778 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
779 (                                                                             \
780     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
781     const dimensioned<Type2>& dt2                                             \
782 )                                                                             \
783 {                                                                             \
784     const GeometricField<Type1, PatchField, GeoMesh>& gf1 = tgf1();           \
785                                                                               \
786     tmp<GeometricField<ReturnType, PatchField, GeoMesh> > tRes                \
787     (                                                                         \
788         reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New   \
789         (                                                                     \
790             tgf1,                                                             \
791             '(' + gf1.name() + OpName + dt2.name() + ')',                     \
792             gf1.dimensions() Op dt2.dimensions()                              \
793         )                                                                     \
794     );                                                                        \
795                                                                               \
796     Foam::OpFunc(tRes(), gf1, dt2);                                           \
797                                                                               \
798     reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>            \
799         ::clear(tgf1);                                                        \
800                                                                               \
801     return tRes;                                                              \
802 }                                                                             \
803                                                                               \
804 TEMPLATE                                                                      \
805 tmp<GeometricField<ReturnType, PatchField, GeoMesh> > operator Op             \
806 (                                                                             \
807     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
808     const Type2& t2                                                           \
809 )                                                                             \
810 {                                                                             \
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //