GeometricFieldFunctionsM.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------* \
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 #define UNARY_FUNCTION(ReturnType, Type1, Func, Dfunc) \
39  \
40 TEMPLATE \
41 void Func \
42 ( \
43  GeometricField<ReturnType, PatchField, GeoMesh>& result, \
44  const GeometricField<Type1, PatchField, GeoMesh>& f1 \
45 ) \
46 { \
47  Foam::Func(result.primitiveFieldRef(), f1.primitiveField()); \
48  Foam::Func(result.boundaryFieldRef(), f1.boundaryField()); \
49  result.oriented() = f1.oriented(); \
50 } \
51  \
52  \
53 TEMPLATE \
54 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
55 ( \
56  const GeometricField<Type1, PatchField, GeoMesh>& f1 \
57 ) \
58 { \
59  auto tres = \
60  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
61  ( \
62  f1, \
63  #Func "(" + f1.name() + ')', \
64  Dfunc(f1.dimensions()) \
65  ); \
66  \
67  Foam::Func(tres.ref(), f1); \
68  return tres; \
69 } \
70  \
71  \
72 TEMPLATE \
73 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
74 ( \
75  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1 \
76 ) \
77 { \
78  const auto& f1 = tf1(); \
79  \
80  auto tres = \
81  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
82  ( \
83  tf1, \
84  #Func "(" + f1.name() + ')', \
85  Dfunc(f1.dimensions()) \
86  ); \
87  \
88  Foam::Func(tres.ref(), f1); \
89  tf1.clear(); \
90  return tres; \
91 }
92 
93 
94 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
95 
96 #define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc) \
97  \
98 TEMPLATE \
99 void OpFunc \
100 ( \
101  GeometricField<ReturnType, PatchField, GeoMesh>& result, \
102  const GeometricField<Type1, PatchField, GeoMesh>& f1 \
103 ) \
104 { \
105  Foam::OpFunc(result.primitiveFieldRef(), f1.primitiveField()); \
106  Foam::OpFunc(result.boundaryFieldRef(), f1.boundaryField()); \
107  result.oriented() = f1.oriented(); \
108 } \
109  \
110  \
111 TEMPLATE \
112 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
113 ( \
114  const GeometricField<Type1, PatchField, GeoMesh>& f1 \
115 ) \
116 { \
117  auto tres = \
118  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
119  ( \
120  f1, \
121  #Op + f1.name(), \
122  Dfunc(f1.dimensions()) \
123  ); \
124  \
125  Foam::OpFunc(tres.ref(), f1); \
126  return tres; \
127 } \
128  \
129  \
130 TEMPLATE \
131 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
132 ( \
133  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1 \
134 ) \
135 { \
136  const auto& f1 = tf1(); \
137  \
138  auto tres = \
139  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
140  ( \
141  tf1, \
142  #Op + f1.name(), \
143  Dfunc(f1.dimensions()) \
144  ); \
145  \
146  Foam::OpFunc(tres.ref(), f1); \
147  tf1.clear(); \
148  return tres; \
149 }
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
155  \
156 TEMPLATE \
157 void Func \
158 ( \
159  GeometricField<ReturnType, PatchField, GeoMesh>& result, \
160  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
161  const GeometricField<Type2, PatchField, GeoMesh>& f2 \
162 ) \
163 { \
164  Foam::Func \
165  ( \
166  result.primitiveFieldRef(), \
167  f1.primitiveField(), \
168  f2.primitiveField() \
169  ); \
170  Foam::Func \
171  ( \
172  result.boundaryFieldRef(), \
173  f1.boundaryField(), \
174  f2.boundaryField() \
175  ); \
176  result.oriented() = Func(f1.oriented(), f2.oriented()); \
177 } \
178  \
179  \
180 TEMPLATE \
181 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
182 ( \
183  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
184  const GeometricField<Type2, PatchField, GeoMesh>& f2 \
185 ) \
186 { \
187  auto tres = \
188  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
189  ( \
190  f1, \
191  #Func "(" + f1.name() + ',' + f2.name() + ')', \
192  Func(f1.dimensions(), f2.dimensions()) \
193  ); \
194  \
195  Foam::Func(tres.ref(), f1, f2); \
196  return tres; \
197 } \
198  \
199  \
200 TEMPLATE \
201 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
202 ( \
203  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
204  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
205 ) \
206 { \
207  const auto& f2 = tf2(); \
208  \
209  auto tres = \
210  reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
211  ( \
212  tf2, \
213  #Func "(" + f1.name() + ',' + f2.name() + ')', \
214  Func(f1.dimensions(), f2.dimensions()) \
215  ); \
216  \
217  Foam::Func(tres.ref(), f1, f2); \
218  tf2.clear(); \
219  return tres; \
220 } \
221  \
222  \
223 TEMPLATE \
224 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
225 ( \
226  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
227  const GeometricField<Type2, PatchField, GeoMesh>& f2 \
228 ) \
229 { \
230  const auto& f1 = tf1(); \
231  \
232  auto tres = \
233  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
234  ( \
235  tf1, \
236  #Func "(" + f1.name() + ',' + f2.name() + ')', \
237  Func(f1.dimensions(), f2.dimensions()) \
238  ); \
239  \
240  Foam::Func(tres.ref(), f1, f2); \
241  tf1.clear(); \
242  return tres; \
243 } \
244  \
245  \
246 TEMPLATE \
247 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
248 ( \
249  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
250  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
251 ) \
252 { \
253  const auto& f1 = tf1(); \
254  const auto& f2 = tf2(); \
255  \
256  auto tres = \
257  reuseTmpTmpGeometricField \
258  <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh> \
259  ::New \
260  ( \
261  tf1, \
262  tf2, \
263  #Func "(" + f1.name() + ',' + f2.name() + ')', \
264  Func(f1.dimensions(), f2.dimensions()) \
265  ); \
266  \
267  Foam::Func(tres.ref(), f1, f2); \
268  tf1.clear(); \
269  tf2.clear(); \
270  return tres; \
271 }
272 
273 
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 
276 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
277  \
278 TEMPLATE \
279 void Func \
280 ( \
281  GeometricField<ReturnType, PatchField, GeoMesh>& result, \
282  const dimensioned<Type1>& dt1, \
283  const GeometricField<Type2, PatchField, GeoMesh>& f2 \
284 ) \
285 { \
286  Foam::Func(result.primitiveFieldRef(), dt1.value(), f2.primitiveField()); \
287  Foam::Func(result.boundaryFieldRef(), dt1.value(), f2.boundaryField()); \
288  result.oriented() = f2.oriented(); \
289 } \
290  \
291  \
292 TEMPLATE \
293 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
294 ( \
295  const dimensioned<Type1>& dt1, \
296  const GeometricField<Type2, PatchField, GeoMesh>& f2 \
297 ) \
298 { \
299  auto tres = \
300  reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
301  ( \
302  f2, \
303  #Func "(" + dt1.name() + ',' + f2.name() + ')', \
304  Func(dt1.dimensions(), f2.dimensions()) \
305  ); \
306  \
307  Foam::Func(tres.ref(), dt1, f2); \
308  return tres; \
309 } \
310  \
311  \
312 TEMPLATE \
313 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
314 ( \
315  const Type1& s1, \
316  const GeometricField<Type2, PatchField, GeoMesh>& f2 \
317 ) \
318 { \
319  return Func(dimensioned<Type1>(s1), f2); \
320 } \
321  \
322  \
323 TEMPLATE \
324 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
325 ( \
326  const dimensioned<Type1>& dt1, \
327  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
328 ) \
329 { \
330  const auto& f2 = tf2(); \
331  \
332  auto tres = \
333  reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
334  ( \
335  tf2, \
336  #Func "(" + dt1.name() + ',' + f2.name() + ')', \
337  Func(dt1.dimensions(), f2.dimensions()) \
338  ); \
339  \
340  Foam::Func(tres.ref(), dt1, f2); \
341  tf2.clear(); \
342  return tres; \
343 } \
344  \
345  \
346 TEMPLATE \
347 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
348 ( \
349  const Type1& s1, \
350  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
351 ) \
352 { \
353  return Func(dimensioned<Type1>(s1), tf2); \
354 }
355 
356 
357 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
358  \
359 TEMPLATE \
360 void Func \
361 ( \
362  GeometricField<ReturnType, PatchField, GeoMesh>& result, \
363  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
364  const dimensioned<Type2>& dt2 \
365 ) \
366 { \
367  Foam::Func(result.primitiveFieldRef(), f1.primitiveField(), dt2.value()); \
368  Foam::Func(result.boundaryFieldRef(), f1.boundaryField(), dt2.value()); \
369  result.oriented() = f1.oriented(); \
370 } \
371  \
372  \
373 TEMPLATE \
374 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
375 ( \
376  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
377  const dimensioned<Type2>& dt2 \
378 ) \
379 { \
380  auto tres = \
381  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
382  ( \
383  f1, \
384  #Func "(" + f1.name() + ',' + dt2.name() + ')', \
385  Func(f1.dimensions(), dt2.dimensions()) \
386  ); \
387  \
388  Foam::Func(tres.ref(), f1, dt2); \
389  return tres; \
390 } \
391  \
392  \
393 TEMPLATE \
394 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
395 ( \
396  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
397  const Type2& s2 \
398 ) \
399 { \
400  return Func(f1, dimensioned<Type2>(s2)); \
401 } \
402  \
403  \
404 TEMPLATE \
405 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
406 ( \
407  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
408  const dimensioned<Type2>& dt2 \
409 ) \
410 { \
411  const auto& f1 = tf1(); \
412  \
413  auto tres = \
414  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
415  ( \
416  tf1, \
417  #Func "(" + f1.name() + ',' + dt2.name() + ')', \
418  Func(f1.dimensions(), dt2.dimensions()) \
419  ); \
420  \
421  Foam::Func(tres.ref(), f1, dt2); \
422  tf1.clear(); \
423  return tres; \
424 } \
425  \
426  \
427 TEMPLATE \
428 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
429 ( \
430  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
431  const Type2& s2 \
432 ) \
433 { \
434  return Func(tf1, dimensioned<Type2>(s2)); \
435 }
436 
437 
438 #define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func) \
439  BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
440  BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
441 
442 
443 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
444 
445 #define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
446  \
447 TEMPLATE \
448 void OpFunc \
449 ( \
450  GeometricField<ReturnType, PatchField, GeoMesh>& result, \
451  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
452  const GeometricField<Type2, PatchField, GeoMesh>& f2 \
453 ) \
454 { \
455  Foam::OpFunc \
456  ( \
457  result.primitiveFieldRef(), \
458  f1.primitiveField(), \
459  f2.primitiveField() \
460  ); \
461  Foam::OpFunc \
462  ( \
463  result.boundaryFieldRef(), \
464  f1.boundaryField(), \
465  f2.boundaryField() \
466  ); \
467  result.oriented() = (f1.oriented() Op f2.oriented()); \
468 } \
469  \
470  \
471 TEMPLATE \
472 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
473 ( \
474  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
475  const GeometricField<Type2, PatchField, GeoMesh>& f2 \
476 ) \
477 { \
478  auto tres = \
479  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
480  ( \
481  f1, \
482  '(' + f1.name() + OpName + f2.name() + ')', \
483  (f1.dimensions() Op f2.dimensions()) \
484  ); \
485  \
486  Foam::OpFunc(tres.ref(), f1, f2); \
487  return tres; \
488 } \
489  \
490  \
491 TEMPLATE \
492 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
493 ( \
494  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
495  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
496 ) \
497 { \
498  const auto& f2 = tf2(); \
499  \
500  auto tres = \
501  reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
502  ( \
503  tf2, \
504  '(' + f1.name() + OpName + f2.name() + ')', \
505  (f1.dimensions() Op f2.dimensions()) \
506  ); \
507  \
508  Foam::OpFunc(tres.ref(), f1, f2); \
509  tf2.clear(); \
510  return tres; \
511 } \
512  \
513  \
514 TEMPLATE \
515 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
516 ( \
517  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
518  const GeometricField<Type2, PatchField, GeoMesh>& f2 \
519 ) \
520 { \
521  const auto& f1 = tf1(); \
522  \
523  auto tres = \
524  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
525  ( \
526  tf1, \
527  '(' + f1.name() + OpName + f2.name() + ')', \
528  (f1.dimensions() Op f2.dimensions()) \
529  ); \
530  \
531  Foam::OpFunc(tres.ref(), f1, f2); \
532  tf1.clear(); \
533  return tres; \
534 } \
535  \
536  \
537 TEMPLATE \
538 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
539 ( \
540  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
541  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
542 ) \
543 { \
544  const auto& f1 = tf1(); \
545  const auto& f2 = tf2(); \
546  \
547  auto tres = \
548  reuseTmpTmpGeometricField \
549  <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh>::New \
550  ( \
551  tf1, \
552  tf2, \
553  '(' + f1.name() + OpName + f2.name() + ')', \
554  (f1.dimensions() Op f2.dimensions()) \
555  ); \
556  \
557  Foam::OpFunc(tres.ref(), f1, f2); \
558  tf1.clear(); \
559  tf2.clear(); \
560  return tres; \
561 }
562 
563 
564 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
565 
566 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
567  \
568 TEMPLATE \
569 void OpFunc \
570 ( \
571  GeometricField<ReturnType, PatchField, GeoMesh>& result, \
572  const dimensioned<Type1>& dt1, \
573  const GeometricField<Type2, PatchField, GeoMesh>& f2 \
574 ) \
575 { \
576  Foam::OpFunc(result.primitiveFieldRef(), dt1.value(), f2.primitiveField());\
577  Foam::OpFunc(result.boundaryFieldRef(), dt1.value(), f2.boundaryField()); \
578  result.oriented() = f2.oriented(); \
579  \
580 } \
581  \
582 TEMPLATE \
583 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
584 ( \
585  const dimensioned<Type1>& dt1, \
586  const GeometricField<Type2, PatchField, GeoMesh>& f2 \
587 ) \
588 { \
589  auto tres = \
590  reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
591  ( \
592  f2, \
593  '(' + dt1.name() + OpName + f2.name() + ')', \
594  (dt1.dimensions() Op f2.dimensions()) \
595  ); \
596  \
597  Foam::OpFunc(tres.ref(), dt1, f2); \
598  return tres; \
599 } \
600  \
601  \
602 TEMPLATE \
603 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
604 ( \
605  const Type1& t1, \
606  const GeometricField<Type2, PatchField, GeoMesh>& f2 \
607 ) \
608 { \
609  return dimensioned<Type1>(t1) Op f2; \
610 } \
611  \
612  \
613 TEMPLATE \
614 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
615 ( \
616  const dimensioned<Type1>& dt1, \
617  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
618 ) \
619 { \
620  const auto& f2 = tf2(); \
621  \
622  auto tres = \
623  reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
624  ( \
625  tf2, \
626  '(' + dt1.name() + OpName + f2.name() + ')', \
627  (dt1.dimensions() Op f2.dimensions()) \
628  ); \
629  \
630  Foam::OpFunc(tres.ref(), dt1, f2); \
631  tf2.clear(); \
632  return tres; \
633 } \
634  \
635  \
636 TEMPLATE \
637 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
638 ( \
639  const Type1& s1, \
640  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2 \
641 ) \
642 { \
643  return dimensioned<Type1>(s1) Op tf2; \
644 }
645 
646 
647 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
648  \
649 TEMPLATE \
650 void OpFunc \
651 ( \
652  GeometricField<ReturnType, PatchField, GeoMesh>& result, \
653  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
654  const dimensioned<Type2>& dt2 \
655 ) \
656 { \
657  Foam::OpFunc(result.primitiveFieldRef(), f1.primitiveField(), dt2.value());\
658  Foam::OpFunc(result.boundaryFieldRef(), f1.boundaryField(), dt2.value()); \
659  result.oriented() = f1.oriented(); \
660 } \
661  \
662  \
663 TEMPLATE \
664 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
665 ( \
666  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
667  const dimensioned<Type2>& dt2 \
668 ) \
669 { \
670  auto tres = \
671  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
672  ( \
673  f1, \
674  '(' + f1.name() + OpName + dt2.name() + ')', \
675  (f1.dimensions() Op dt2.dimensions()) \
676  ); \
677  \
678  Foam::OpFunc(tres.ref(), f1, dt2); \
679  return tres; \
680 } \
681  \
682  \
683 TEMPLATE \
684 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
685 ( \
686  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
687  const Type2& s2 \
688 ) \
689 { \
690  return f1 Op dimensioned<Type2>(s2); \
691 } \
692  \
693  \
694 TEMPLATE \
695 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
696 ( \
697  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
698  const dimensioned<Type2>& dt2 \
699 ) \
700 { \
701  const auto& f1 = tf1(); \
702  \
703  auto tres = \
704  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
705  ( \
706  tf1, \
707  '(' + f1.name() + OpName + dt2.name() + ')', \
708  (f1.dimensions() Op dt2.dimensions()) \
709  ); \
710  \
711  Foam::OpFunc(tres.ref(), f1, dt2); \
712  tf1.clear(); \
713  return tres; \
714 } \
715  \
716  \
717 TEMPLATE \
718 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> operator Op \
719 ( \
720  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
721  const Type2& s2 \
722 ) \
723 { \
724  return tf1 Op dimensioned<Type2>(s2); \
725 }
726 
727 
728 #define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
729  BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc) \
730  BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
731 
732 
733 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
734 
735 #define TERNARY_FUNCTION(ReturnType, Type1, Type2, Type3, Func) \
736  \
737 TEMPLATE \
738 void Func \
739 ( \
740  GeometricField<ReturnType, PatchField, GeoMesh>& result, \
741  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
742  const GeometricField<Type2, PatchField, GeoMesh>& f2, \
743  const GeometricField<Type3, PatchField, GeoMesh>& f3 \
744 ) \
745 { \
746  Foam::Func \
747  ( \
748  result.primitiveFieldRef(), \
749  f1.primitiveField(), \
750  f2.primitiveField(), \
751  f3.primitiveField() \
752  ); \
753  Foam::Func \
754  ( \
755  result.boundaryFieldRef(), \
756  f1.boundaryField(), \
757  f2.boundaryField(), \
758  f3.boundaryField() \
759  ); \
760  result.oriented() = Func(f1.oriented(), f2.oriented()); \
761 } \
762  \
763 TEMPLATE \
764 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
765 ( \
766  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
767  const GeometricField<Type2, PatchField, GeoMesh>& f2, \
768  const GeometricField<Type3, PatchField, GeoMesh>& f3 \
769 ) \
770 { \
771  auto tres = \
772  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
773  ( \
774  f1, \
775  #Func "(" + f1.name() + ',' + f2.name() + ',' + f3.name() + ')', \
776  Func(f1.dimensions(), f2.dimensions()) \
777  ); \
778  \
779  Foam::Func(tres.ref(), f1, f2, f3); \
780  return tres; \
781 } \
782  \
783 TEMPLATE \
784 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
785 ( \
786  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
787  const GeometricField<Type2, PatchField, GeoMesh>& f2, \
788  const GeometricField<Type3, PatchField, GeoMesh>& f3 \
789 ) \
790 { \
791  const auto& f1 = tf1(); \
792  \
793  auto tres = \
794  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
795  ( \
796  f1, \
797  #Func "(" + f1.name() + ',' + f2.name() + ',' + f3.name() + ')', \
798  Func(f1.dimensions(), f2.dimensions()) \
799  ); \
800  \
801  Foam::Func(tres.ref(), f1, f2, f3); \
802  tf1.clear(); \
803  return tres; \
804 } \
805  \
806 TEMPLATE \
807 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
808 ( \
809  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
810  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
811  const GeometricField<Type3, PatchField, GeoMesh>& f3 \
812 ) \
813 { \
814  const auto& f2 = tf2(); \
815  \
816  auto tres = \
817  reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
818  ( \
819  f2, \
820  #Func "(" + f1.name() + ',' + f2.name() + ',' + f3.name() + ')', \
821  Func(f1.dimensions(), f2.dimensions()) \
822  ); \
823  \
824  Foam::Func(tres.ref(), f1, f2, f3); \
825  tf2.clear(); \
826  return tres; \
827 } \
828  \
829 TEMPLATE \
830 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
831 ( \
832  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
833  const GeometricField<Type2, PatchField, GeoMesh>& f2, \
834  const tmp<GeometricField<Type3, PatchField, GeoMesh>>& tf3 \
835 ) \
836 { \
837  const auto& f3 = tf3(); \
838  \
839  auto tres = \
840  reuseTmpGeometricField<ReturnType, Type3, PatchField, GeoMesh>::New \
841  ( \
842  f3, \
843  #Func "(" + f1.name() + ',' + f2.name() + ',' + f3.name() + ')', \
844  Func(f1.dimensions(), f2.dimensions()) \
845  ); \
846  \
847  Foam::Func(tres.ref(), f1, f2, f3); \
848  tf3.clear(); \
849  return tres; \
850 } \
851  \
852 TEMPLATE \
853 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
854 ( \
855  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
856  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
857  const GeometricField<Type3, PatchField, GeoMesh>& f3 \
858 ) \
859 { \
860  const auto& f1 = tf1(); \
861  const auto& f2 = tf2(); \
862  \
863  auto tres = \
864  reuseTmpTmpGeometricField \
865  <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh> \
866  ::New \
867  ( \
868  tf1, \
869  tf2, \
870  #Func "(" + f1.name() + ',' + f2.name() + ',' + f3.name() + ')', \
871  Func(f1.dimensions(), f2.dimensions()) \
872  ); \
873  \
874  Foam::Func(tres.ref(), f1, f2, f3); \
875  tf1.clear(); \
876  tf2.clear(); \
877  return tres; \
878 } \
879  \
880 TEMPLATE \
881 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
882 ( \
883  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
884  const GeometricField<Type2, PatchField, GeoMesh>& f2, \
885  const tmp<GeometricField<Type3, PatchField, GeoMesh>>& tf3 \
886 ) \
887 { \
888  const auto& f1 = tf1(); \
889  const auto& f3 = tf3(); \
890  \
891  auto tres = \
892  reuseTmpTmpGeometricField \
893  <ReturnType, Type1, Type1, Type3, PatchField, GeoMesh> \
894  ::New \
895  ( \
896  tf1, \
897  tf3, \
898  #Func "(" + f1.name() + ',' + f2.name() + ',' + f3.name() + ')', \
899  Func(f1.dimensions(), f2.dimensions()) \
900  ); \
901  \
902  Foam::Func(tres.ref(), f1, f2, f3); \
903  tf1.clear(); \
904  tf3.clear(); \
905  return tres; \
906 } \
907  \
908 TEMPLATE \
909 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
910 ( \
911  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
912  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
913  const tmp<GeometricField<Type3, PatchField, GeoMesh>>& tf3 \
914 ) \
915 { \
916  const auto& f2 = tf2(); \
917  const auto& f3 = tf3(); \
918  \
919  auto tres = \
920  reuseTmpTmpGeometricField \
921  <ReturnType, Type2, Type2, Type3, PatchField, GeoMesh> \
922  ::New \
923  ( \
924  tf2, \
925  tf3, \
926  #Func "(" + f1.name() + ',' + f2.name() + ',' + f3.name() + ')', \
927  Func(f1.dimensions(), f2.dimensions()) \
928  ); \
929  \
930  Foam::Func(tres.ref(), f1, f2, f3); \
931  tf2.clear(); \
932  tf3.clear(); \
933  return tres; \
934 } \
935  \
936 TEMPLATE \
937 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
938 ( \
939  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
940  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
941  const tmp<GeometricField<Type3, PatchField, GeoMesh>>& tf3 \
942 ) \
943 { \
944  const auto& f1 = tf1(); \
945  const auto& f2 = tf2(); \
946  const auto& f3 = tf3(); \
947  \
948  auto tres = \
949  reuseTmpTmpGeometricField \
950  <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh> \
951  ::New \
952  ( \
953  tf1, \
954  tf2, \
955  #Func "(" + f1.name() + ',' + f2.name() + ',' + f3.name() + ')', \
956  Func(f1.dimensions(), f2.dimensions()) \
957  ); \
958  \
959  Foam::Func(tres.ref(), f1, f2, f3); \
960  tf1.clear(); \
961  tf2.clear(); \
962  tf3.clear(); \
963  return tres; \
964 }
965 
966 
967 #define TERNARY_TYPE_FUNCTION_FFS(ReturnType, Type1, Type2, Type3, Func) \
968  \
969 TEMPLATE \
970 void Func \
971 ( \
972  GeometricField<ReturnType, PatchField, GeoMesh>& result, \
973  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
974  const GeometricField<Type2, PatchField, GeoMesh>& f2, \
975  const dimensioned<Type3>& dt3 \
976 ) \
977 { \
978  Foam::Func \
979  ( \
980  result.primitiveFieldRef(), \
981  f1.primitiveField(), \
982  f2.primitiveField(), \
983  dt3.value() \
984  ); \
985  Foam::Func \
986  ( \
987  result.boundaryFieldRef(), \
988  f1.boundaryField(), \
989  f2.boundaryField(), \
990  dt3.value() \
991  ); \
992  result.oriented() = Func(f1.oriented(), f2.oriented()); \
993 } \
994  \
995 TEMPLATE \
996 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
997 ( \
998  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
999  const GeometricField<Type2, PatchField, GeoMesh>& f2, \
1000  const dimensioned<Type3>& dt3 \
1001 ) \
1002 { \
1003  auto tres = \
1004  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
1005  ( \
1006  f1, \
1007  #Func "(" + f1.name() + ',' + f2.name() + ',' + dt3.name() + ')', \
1008  Func(f1.dimensions(), f2.dimensions()) \
1009  ); \
1010  \
1011  Foam::Func(tres.ref(), f1, f2, dt3.value()); \
1012  return tres; \
1013 } \
1014  \
1015 TEMPLATE \
1016 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
1017 ( \
1018  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
1019  const GeometricField<Type2, PatchField, GeoMesh>& f2, \
1020  const Type3& s3 \
1021 ) \
1022 { \
1023  return Foam::Func(f1, f2, dimensioned<Type>(s3)); \
1024 } \
1025  \
1026 TEMPLATE \
1027 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
1028 ( \
1029  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
1030  const GeometricField<Type2, PatchField, GeoMesh>& f2, \
1031  const dimensioned<Type3>& dt3 \
1032 ) \
1033 { \
1034  const auto& f1 = tf1(); \
1035  \
1036  auto tres = \
1037  reuseTmpGeometricField<ReturnType, Type1, PatchField, GeoMesh>::New \
1038  ( \
1039  f1, \
1040  #Func "(" + f1.name() + ',' + f2.name() + ',' + dt3.name() + ')', \
1041  Func(f1.dimensions(), f2.dimensions()) \
1042  ); \
1043  \
1044  Foam::Func(tres.ref(), f1, f2, dt3.value()); \
1045  tf1.clear(); \
1046  return tres; \
1047 } \
1048  \
1049 TEMPLATE \
1050 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
1051 ( \
1052  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
1053  const GeometricField<Type2, PatchField, GeoMesh>& f2, \
1054  const Type3& s3 \
1055 ) \
1056 { \
1057  return Foam::Func(tf1, f2, dimensioned<Type>(s3)); \
1058 } \
1059  \
1060 TEMPLATE \
1061 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
1062 ( \
1063  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
1064  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
1065  const dimensioned<Type3>& dt3 \
1066 ) \
1067 { \
1068  const auto& f2 = tf2(); \
1069  \
1070  auto tres = \
1071  reuseTmpGeometricField<ReturnType, Type2, PatchField, GeoMesh>::New \
1072  ( \
1073  tf2, \
1074  #Func "(" + f1.name() + ',' + f2.name() + ',' + dt3.name() + ')', \
1075  Func(f1.dimensions(), f2.dimensions()) \
1076  ); \
1077  \
1078  Foam::Func(tres.ref(), f1, f2, dt3.value()); \
1079  tf2.clear(); \
1080  return tres; \
1081 } \
1082  \
1083 TEMPLATE \
1084 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
1085 ( \
1086  const GeometricField<Type1, PatchField, GeoMesh>& f1, \
1087  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
1088  const Type3& s3 \
1089 ) \
1090 { \
1091  return Foam::Func(f1, tf2, dimensioned<Type>(s3)); \
1092 } \
1093  \
1094 TEMPLATE \
1095 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
1096 ( \
1097  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
1098  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
1099  const dimensioned<Type3>& dt3 \
1100 ) \
1101 { \
1102  const auto& f1 = tf1(); \
1103  const auto& f2 = tf2(); \
1104  \
1105  auto tres = \
1106  reuseTmpTmpGeometricField \
1107  <ReturnType, Type1, Type1, Type2, PatchField, GeoMesh> \
1108  ::New \
1109  ( \
1110  tf1, \
1111  tf2, \
1112  #Func "(" + f1.name() + ',' + f2.name() + ',' + dt3.name() + ')', \
1113  Func(f1.dimensions(), f2.dimensions()) \
1114  ); \
1115  \
1116  Foam::Func(tres.ref(), f1, f2, dt3.value()); \
1117  tf1.clear(); \
1118  tf2.clear(); \
1119  return tres; \
1120 } \
1121  \
1122 TEMPLATE \
1123 tmp<GeometricField<ReturnType, PatchField, GeoMesh>> Func \
1124 ( \
1125  const tmp<GeometricField<Type1, PatchField, GeoMesh>>& tf1, \
1126  const tmp<GeometricField<Type2, PatchField, GeoMesh>>& tf2, \
1127  const Type3& s3 \
1128 ) \
1129 { \
1130  return Foam::Func(tf1, tf2, dimensioned<Type>(s3)); \
1131 }
1132 
1133 
1134 // ************************************************************************* //
1135 
1136 } // End namespace Foam
1137 
1138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Namespace for OpenFOAM.