OpenFOAM
9
The OpenFOAM Foundation
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
FieldFieldFunctionsM.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-2020 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
26
#include "
FieldM.H
"
27
#include "
FieldFieldReuseFunctions.H
"
28
29
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30
31
#define UNARY_FUNCTION(ReturnType, Type, Func) \
32
\
33
TEMPLATE \
34
void Func \
35
( \
36
FieldField<Field, ReturnType>& res, \
37
const FieldField<Field, Type>& f \
38
) \
39
{ \
40
forAll(res, i) \
41
{ \
42
Func(res[i], f[i]); \
43
} \
44
} \
45
\
46
TEMPLATE \
47
tmp<FieldField<Field, ReturnType>> Func \
48
( \
49
const FieldField<Field, Type>& f \
50
) \
51
{ \
52
tmp<FieldField<Field, ReturnType>> tRes \
53
( \
54
FieldField<Field, ReturnType>::NewCalculatedType(f) \
55
); \
56
Func(tRes.ref(), f); \
57
return tRes; \
58
} \
59
\
60
TEMPLATE \
61
tmp<FieldField<Field, ReturnType>> Func \
62
( \
63
const tmp<FieldField<Field, Type>>& tf \
64
) \
65
{ \
66
tmp<FieldField<Field, ReturnType>> tRes(New(tf)); \
67
Func(tRes.ref(), tf()); \
68
tf.clear(); \
69
return tRes; \
70
}
71
72
73
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74
75
#define UNARY_OPERATOR(ReturnType, Type, Op, OpFunc) \
76
\
77
TEMPLATE \
78
void OpFunc \
79
( \
80
FieldField<Field, ReturnType>& res, \
81
const FieldField<Field, Type>& f \
82
) \
83
{ \
84
forAll(res, i) \
85
{ \
86
OpFunc(res[i], f[i]); \
87
} \
88
} \
89
\
90
TEMPLATE \
91
tmp<FieldField<Field, ReturnType>> operator Op \
92
( \
93
const FieldField<Field, Type>& f \
94
) \
95
{ \
96
tmp<FieldField<Field, ReturnType>> tRes \
97
( \
98
FieldField<Field, Type>::NewCalculatedType(f) \
99
); \
100
OpFunc(tRes.ref(), f); \
101
return tRes; \
102
} \
103
\
104
TEMPLATE \
105
tmp<FieldField<Field, ReturnType>> operator Op \
106
( \
107
const tmp<FieldField<Field, Type>>& tf \
108
) \
109
{ \
110
tmp<FieldField<Field, ReturnType>> tRes(New(tf)); \
111
OpFunc(tRes.ref(), tf()); \
112
tf.clear(); \
113
return tRes; \
114
}
115
116
117
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118
119
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
120
\
121
TEMPLATE \
122
void Func \
123
( \
124
FieldField<Field, ReturnType>& f, \
125
const FieldField<Field, Type1>& f1, \
126
const FieldField<Field, Type2>& f2 \
127
) \
128
{ \
129
forAll(f, i) \
130
{ \
131
Func(f[i], f1[i], f2[i]); \
132
} \
133
} \
134
\
135
TEMPLATE \
136
tmp<FieldField<Field, ReturnType>> Func \
137
( \
138
const FieldField<Field, Type1>& f1, \
139
const FieldField<Field, Type2>& f2 \
140
) \
141
{ \
142
tmp<FieldField<Field, ReturnType>> tRes \
143
( \
144
FieldField<Field, Type1>::NewCalculatedType(f1) \
145
); \
146
Func(tRes.ref(), f1, f2); \
147
return tRes; \
148
} \
149
\
150
TEMPLATE \
151
tmp<FieldField<Field, ReturnType>> Func \
152
( \
153
const FieldField<Field, Type1>& f1, \
154
const tmp<FieldField<Field, Type2>>& tf2 \
155
) \
156
{ \
157
tmp<FieldField<Field, ReturnType>> tRes \
158
( \
159
reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
160
); \
161
Func(tRes.ref(), f1, tf2()); \
162
tf2.clear(); \
163
return tRes; \
164
} \
165
\
166
TEMPLATE \
167
tmp<FieldField<Field, ReturnType>> Func \
168
( \
169
const tmp<FieldField<Field, Type1>>& tf1, \
170
const FieldField<Field, Type2>& f2 \
171
) \
172
{ \
173
tmp<FieldField<Field, ReturnType>> tRes \
174
( \
175
reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
176
); \
177
Func(tRes.ref(), tf1(), f2); \
178
tf1.clear(); \
179
return tRes; \
180
} \
181
\
182
TEMPLATE \
183
tmp<FieldField<Field, ReturnType>> Func \
184
( \
185
const tmp<FieldField<Field, Type1>>& tf1, \
186
const tmp<FieldField<Field, Type2>>& tf2 \
187
) \
188
{ \
189
tmp<FieldField<Field, ReturnType>> tRes \
190
( \
191
reuseTmpTmpFieldField<Field, ReturnType, Type1, Type2>::New(tf1, tf2) \
192
); \
193
Func(tRes.ref(), tf1(), tf2()); \
194
tf1.clear(); \
195
tf2.clear(); \
196
return tRes; \
197
}
198
199
200
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201
202
#define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
203
\
204
TEMPLATE \
205
void Func \
206
( \
207
FieldField<Field, ReturnType>& f, \
208
const Type1& s, \
209
const FieldField<Field, Type2>& f2 \
210
) \
211
{ \
212
forAll(f, i) \
213
{ \
214
Func(f[i], s, f2[i]); \
215
} \
216
} \
217
\
218
TEMPLATE \
219
tmp<FieldField<Field, ReturnType>> Func \
220
( \
221
const Type1& s, \
222
const FieldField<Field, Type2>& f2 \
223
) \
224
{ \
225
tmp<FieldField<Field, ReturnType>> tRes \
226
( \
227
FieldField<Field, Type2>::NewCalculatedType(f2) \
228
); \
229
Func(tRes.ref(), s, f2); \
230
return tRes; \
231
} \
232
\
233
TEMPLATE \
234
tmp<FieldField<Field, ReturnType>> Func \
235
( \
236
const Type1& s, \
237
const tmp<FieldField<Field, Type2>>& tf2 \
238
) \
239
{ \
240
tmp<FieldField<Field, ReturnType>> tRes \
241
( \
242
reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
243
); \
244
Func(tRes.ref(), s, tf2()); \
245
tf2.clear(); \
246
return tRes; \
247
}
248
249
250
#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
251
\
252
TEMPLATE \
253
void Func \
254
( \
255
FieldField<Field, ReturnType>& f, \
256
const FieldField<Field, Type1>& f1, \
257
const Type2& s \
258
) \
259
{ \
260
forAll(f, i) \
261
{ \
262
Func(f[i], f1[i], s); \
263
} \
264
} \
265
\
266
TEMPLATE \
267
tmp<FieldField<Field, ReturnType>> Func \
268
( \
269
const FieldField<Field, Type1>& f1, \
270
const Type2& s \
271
) \
272
{ \
273
tmp<FieldField<Field, ReturnType>> tRes \
274
( \
275
FieldField<Field, Type1>::NewCalculatedType(f1) \
276
); \
277
Func(tRes.ref(), f1, s); \
278
return tRes; \
279
} \
280
\
281
TEMPLATE \
282
tmp<FieldField<Field, ReturnType>> Func \
283
( \
284
const tmp<FieldField<Field, Type1>>& tf1, \
285
const Type2& s \
286
) \
287
{ \
288
tmp<FieldField<Field, ReturnType>> tRes \
289
( \
290
reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
291
); \
292
Func(tRes.ref(), tf1(), s); \
293
tf1.clear(); \
294
return tRes; \
295
}
296
297
298
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func) \
299
BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
300
BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
301
302
303
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304
305
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
306
\
307
TEMPLATE \
308
void OpFunc \
309
( \
310
FieldField<Field, ReturnType>& f, \
311
const FieldField<Field, Type1>& f1, \
312
const FieldField<Field, Type2>& f2 \
313
) \
314
{ \
315
forAll(f, i) \
316
{ \
317
OpFunc(f[i], f1[i], f2[i]); \
318
} \
319
} \
320
\
321
TEMPLATE \
322
tmp<FieldField<Field, ReturnType>> operator Op \
323
( \
324
const FieldField<Field, Type1>& f1, \
325
const FieldField<Field, Type2>& f2 \
326
) \
327
{ \
328
tmp<FieldField<Field, ReturnType>> tRes \
329
( \
330
FieldField<Field, ReturnType>::NewCalculatedType(f1) \
331
); \
332
OpFunc(tRes.ref(), f1, f2); \
333
return tRes; \
334
} \
335
\
336
TEMPLATE \
337
tmp<FieldField<Field, ReturnType>> operator Op \
338
( \
339
const FieldField<Field, Type1>& f1, \
340
const tmp<FieldField<Field, Type2>>& tf2 \
341
) \
342
{ \
343
tmp<FieldField<Field, ReturnType>> tRes \
344
( \
345
reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
346
); \
347
OpFunc(tRes.ref(), f1, tf2()); \
348
tf2.clear(); \
349
return tRes; \
350
} \
351
\
352
TEMPLATE \
353
tmp<FieldField<Field, ReturnType>> operator Op \
354
( \
355
const tmp<FieldField<Field, Type1>>& tf1, \
356
const FieldField<Field, Type2>& f2 \
357
) \
358
{ \
359
tmp<FieldField<Field, ReturnType>> tRes \
360
( \
361
reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
362
); \
363
OpFunc(tRes.ref(), tf1(), f2); \
364
tf1.clear(); \
365
return tRes; \
366
} \
367
\
368
TEMPLATE \
369
tmp<FieldField<Field, ReturnType>> operator Op \
370
( \
371
const tmp<FieldField<Field, Type1>>& tf1, \
372
const tmp<FieldField<Field, Type2>>& tf2 \
373
) \
374
{ \
375
tmp<FieldField<Field, ReturnType>> tRes \
376
( \
377
reuseTmpTmpFieldField<Field, ReturnType, Type1, Type2>::New(tf1, tf2) \
378
); \
379
OpFunc(tRes.ref(), tf1(), tf2()); \
380
tf1.clear(); \
381
tf2.clear(); \
382
return tRes; \
383
}
384
385
386
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
387
388
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
389
\
390
TEMPLATE \
391
void OpFunc \
392
( \
393
FieldField<Field, ReturnType>& f, \
394
const Type1& s, \
395
const FieldField<Field, Type2>& f2 \
396
) \
397
{ \
398
forAll(f, i) \
399
{ \
400
OpFunc(f[i], s, f2[i]); \
401
} \
402
} \
403
\
404
TEMPLATE \
405
tmp<FieldField<Field, ReturnType>> operator Op \
406
( \
407
const Type1& s, \
408
const FieldField<Field, Type2>& f2 \
409
) \
410
{ \
411
tmp<FieldField<Field, ReturnType>> tRes \
412
( \
413
FieldField<Field, Type2>::NewCalculatedType(f2) \
414
); \
415
OpFunc(tRes.ref(), s, f2); \
416
return tRes; \
417
} \
418
\
419
TEMPLATE \
420
tmp<FieldField<Field, ReturnType>> operator Op \
421
( \
422
const Type1& s, \
423
const tmp<FieldField<Field, Type2>>& tf2 \
424
) \
425
{ \
426
tmp<FieldField<Field, ReturnType>> tRes \
427
( \
428
reuseTmpFieldField<Field, ReturnType, Type2>::New(tf2) \
429
); \
430
OpFunc(tRes.ref(), s, tf2()); \
431
tf2.clear(); \
432
return tRes; \
433
}
434
435
436
#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc) \
437
\
438
TEMPLATE \
439
void OpFunc \
440
( \
441
FieldField<Field, ReturnType>& f, \
442
const FieldField<Field, Type1>& f1, \
443
const Type2& s \
444
) \
445
{ \
446
forAll(f, i) \
447
{ \
448
OpFunc(f[i], f1[i], s); \
449
} \
450
} \
451
\
452
TEMPLATE \
453
tmp<FieldField<Field, ReturnType>> operator Op \
454
( \
455
const FieldField<Field, Type1>& f1, \
456
const Type2& s \
457
) \
458
{ \
459
tmp<FieldField<Field, ReturnType>> tRes \
460
( \
461
FieldField<Field, Type1>::NewCalculatedType(f1) \
462
); \
463
OpFunc(tRes.ref(), f1, s); \
464
return tRes; \
465
} \
466
\
467
TEMPLATE \
468
tmp<FieldField<Field, ReturnType>> operator Op \
469
( \
470
const tmp<FieldField<Field, Type1>>& tf1, \
471
const Type2& s \
472
) \
473
{ \
474
tmp<FieldField<Field, ReturnType>> tRes \
475
( \
476
reuseTmpFieldField<Field, ReturnType, Type1>::New(tf1) \
477
); \
478
OpFunc(tRes.ref(), tf1(), s); \
479
tf1.clear(); \
480
return tRes; \
481
}
482
483
484
#define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
485
BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
486
BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)
487
488
// ************************************************************************* //
FieldFieldReuseFunctions.H
FieldM.H
High performance macro functions for Field<Type> algebra. These expand using either array element acc...
src
OpenFOAM
fields
FieldFields
FieldField
FieldFieldFunctionsM.C
Generated by
1.8.13