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