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