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