Loading...
Searching...
No Matches
FieldFunctionsM.H
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) 2023 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Description
28 Macro functions for Field<Type> algebra.
29
30\*---------------------------------------------------------------------------*/
31
32// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34#define UNARY_FUNCTION(ReturnType, Type1, Func) \
35 \
36TEMPLATE \
37void Func(Field<ReturnType>& result, const UList<Type1>& f1); \
38 \
39TEMPLATE \
40tmp<Field<ReturnType>> Func(const UList<Type1>& f1); \
41 \
42TEMPLATE \
43tmp<Field<ReturnType>> Func(const tmp<Field<Type1>>& tf1);
44
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc) \
49 \
50TEMPLATE \
51void OpFunc(Field<ReturnType>& res, const UList<Type1>& f1); \
52 \
53TEMPLATE \
54tmp<Field<ReturnType>> operator Op(const UList<Type1>& f1); \
55 \
56TEMPLATE \
57tmp<Field<ReturnType>> operator Op(const tmp<Field<Type1>>& tf1);
58
59
60// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61
62#define BINARY_FUNCTION_TRANSFORM(ReturnType, Type1, Type2, Func) \
63 \
64TEMPLATE \
65void Func \
66( \
67 Field<ReturnType>& result, \
68 const UList<Type1>& f1, \
69 const UList<Type2>& f2 \
70);
71
72#define BINARY_FUNCTION_INTERFACE(ReturnType, Type1, Type2, Func) \
73 \
74TEMPLATE \
75tmp<Field<ReturnType>> Func \
76( \
77 const UList<Type1>& f1, \
78 const UList<Type2>& f2 \
79); \
80 \
81TEMPLATE \
82tmp<Field<ReturnType>> Func \
83( \
84 const UList<Type1>& f1, \
85 const tmp<Field<Type2>>& tf2 \
86); \
87 \
88TEMPLATE \
89tmp<Field<ReturnType>> Func \
90( \
91 const tmp<Field<Type1>>& tf1, \
92 const UList<Type2>& f2 \
93); \
94 \
95TEMPLATE \
96tmp<Field<ReturnType>> Func \
97( \
98 const tmp<Field<Type1>>& tf1, \
99 const tmp<Field<Type2>>& tf2 \
100);
101
102#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
103 BINARY_FUNCTION_TRANSFORM(ReturnType, Type1, Type2, Func) \
104 BINARY_FUNCTION_INTERFACE(ReturnType, Type1, Type2, Func)
105
106// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107
108#define BINARY_FUNCTION_TRANSFORM_SF(ReturnType, Type1, Type2, Func) \
109 \
110TEMPLATE \
111void Func \
112( \
113 Field<ReturnType>& result, \
114 const Type1& s1, \
115 const UList<Type2>& f2 \
116);
117
118#define BINARY_FUNCTION_INTERFACE_SF(ReturnType, Type1, Type2, Func) \
119 \
120TEMPLATE \
121tmp<Field<ReturnType>> Func \
122( \
123 const Type1& s1, \
124 const UList<Type2>& f2 \
125); \
126 \
127TEMPLATE \
128tmp<Field<ReturnType>> Func \
129( \
130 const Type1& s1, \
131 const tmp<Field<Type2>>& tf2 \
132);
134#define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
135 BINARY_FUNCTION_TRANSFORM_SF(ReturnType, Type1, Type2, Func) \
136 BINARY_FUNCTION_INTERFACE_SF(ReturnType, Type1, Type2, Func)
137
138
139#define BINARY_FUNCTION_TRANSFORM_FS(ReturnType, Type1, Type2, Func) \
140 \
141TEMPLATE \
142void Func \
143( \
144 Field<ReturnType>& result, \
145 const UList<Type1>& f1, \
146 const Type2& s2 \
147);
148
149#define BINARY_FUNCTION_INTERFACE_FS(ReturnType, Type1, Type2, Func) \
150 \
151TEMPLATE \
152tmp<Field<ReturnType>> Func \
153( \
154 const UList<Type1>& f1, \
155 const Type2& s2 \
156); \
157 \
158TEMPLATE \
159tmp<Field<ReturnType>> Func \
160( \
161 const tmp<Field<Type1>>& tf1, \
162 const Type2& s2 \
163);
165#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
166 BINARY_FUNCTION_TRANSFORM_FS(ReturnType, Type1, Type2, Func) \
167 BINARY_FUNCTION_INTERFACE_FS(ReturnType, Type1, Type2, Func)
168
169
170#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func) \
171 BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
172 BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
173
174
175// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176
177#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
178 \
179TEMPLATE \
180void OpFunc \
181( \
182 Field<ReturnType>& result, \
183 const UList<Type1>& f1, \
184 const UList<Type2>& f2 \
185); \
186 \
187TEMPLATE \
188tmp<Field<ReturnType>> operator Op \
189( \
190 const UList<Type1>& f1, \
191 const UList<Type2>& f2 \
192); \
193 \
194TEMPLATE \
195tmp<Field<ReturnType>> operator Op \
196( \
197 const UList<Type1>& f1, \
198 const tmp<Field<Type2>>& tf2 \
199); \
200 \
201TEMPLATE \
202tmp<Field<ReturnType>> operator Op \
203( \
204 const tmp<Field<Type1>>& tf1, \
205 const UList<Type2>& f2 \
206); \
207 \
208TEMPLATE \
209tmp<Field<ReturnType>> operator Op \
210( \
211 const tmp<Field<Type1>>& tf1, \
212 const tmp<Field<Type2>>& tf2 \
213);
214
215
216// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217
218#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
219 \
220TEMPLATE \
221void OpFunc \
222( \
223 Field<ReturnType>& result, \
224 const Type1& s1, \
225 const UList<Type2>& f2 \
226); \
227 \
228TEMPLATE \
229tmp<Field<ReturnType>> operator Op \
230( \
231 const Type1& s1, \
232 const UList<Type2>& f2 \
233); \
234 \
235TEMPLATE \
236tmp<Field<ReturnType>> operator Op \
237( \
238 const Type1& s1, \
239 const tmp<Field<Type2>>& tf2 \
240);
241
242
243#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc) \
244 \
245TEMPLATE \
246void OpFunc \
247( \
248 Field<ReturnType>& result, \
249 const UList<Type1>& f1, \
250 const Type2& s2 \
251); \
252 \
253TEMPLATE \
254tmp<Field<ReturnType>> operator Op \
255( \
256 const UList<Type1>& f1, \
257 const Type2& s2 \
258); \
259 \
260TEMPLATE \
261tmp<Field<ReturnType>> operator Op \
262( \
263 const tmp<Field<Type1>>& tf1, \
264 const Type2& s2 \
265);
266
267
268#define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
269 BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
270 BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)
271
272
273// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274
275#define TERNARY_FUNCTION(ReturnType, Type1, Type2, Type3, Func) \
276 \
277TEMPLATE \
278void Func \
279( \
280 Field<ReturnType>& result, \
281 const UList<Type1>& f1, \
282 const UList<Type2>& f2, \
283 const UList<Type3>& f3 \
284); \
285 \
286TEMPLATE \
287tmp<Field<ReturnType>> Func \
288( \
289 const UList<Type1>& f1, \
290 const UList<Type2>& f2, \
291 const UList<Type3>& f3 \
292); \
293 \
294TEMPLATE \
295tmp<Field<ReturnType>> Func \
296( \
297 const tmp<Field<Type1>>& tf1, \
298 const UList<Type2>& f2, \
299 const UList<Type3>& f3 \
300); \
301 \
302TEMPLATE \
303tmp<Field<ReturnType>> Func \
304( \
305 const UList<Type1>& f1, \
306 const tmp<Field<Type2>>& tf2, \
307 const UList<Type3>& f3 \
308); \
309 \
310TEMPLATE \
311tmp<Field<ReturnType>> Func \
312( \
313 const UList<Type1>& f1, \
314 const UList<Type2>& f2, \
315 const tmp<Field<Type3>>& tf3 \
316); \
317 \
318TEMPLATE \
319tmp<Field<ReturnType>> Func \
320( \
321 const tmp<Field<Type1>>& tf1, \
322 const tmp<Field<Type2>>& tf2, \
323 const UList<Type3>& f3 \
324); \
325 \
326TEMPLATE \
327tmp<Field<ReturnType>> Func \
328( \
329 const tmp<Field<Type1>>& tf1, \
330 const UList<Type2>& f2, \
331 const tmp<Field<Type3>>& tf3 \
332); \
333 \
334TEMPLATE \
335tmp<Field<ReturnType>> Func \
336( \
337 const UList<Type1>& f1, \
338 const tmp<Field<Type2>>& tf2, \
339 const tmp<Field<Type3>>& tf3 \
340); \
341 \
342TEMPLATE \
343tmp<Field<ReturnType>> Func \
344( \
345 const tmp<Field<Type1>>& tf1, \
346 const tmp<Field<Type2>>& tf2, \
347 const tmp<Field<Type3>>& tf3 \
348);
349
350
351// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
352// Permutations of ternary functions taking non-field argument(s)
353//
354// FFS (defined)
355// FSF (not defined)
356// SFF (not defined)
357// SSF (not defined)
358// SFS (not defined)
359// FSS (not defined)
360
361#define TERNARY_TYPE_FUNCTION_FFS(ReturnType, Type1, Type2, Type3, Func) \
362 \
363TEMPLATE \
364void Func \
365( \
366 Field<ReturnType>& result, \
367 const UList<Type1>& f1, \
368 const UList<Type2>& f2, \
369 const Type3& s3 \
370); \
371 \
372TEMPLATE \
373tmp<Field<ReturnType>> Func \
374( \
375 const UList<Type1>& f1, \
376 const UList<Type2>& f2, \
377 const Type3& s3 \
378); \
379 \
380TEMPLATE \
381tmp<Field<ReturnType>> Func \
382( \
383 const tmp<Field<Type1>>& tf1, \
384 const UList<Type2>& f2, \
385 const Type3& s3 \
386); \
387 \
388TEMPLATE \
389tmp<Field<ReturnType>> Func \
390( \
391 const UList<Type1>& f1, \
392 const tmp<Field<Type2>>& tf2, \
393 const Type3& s3 \
394); \
395 \
396TEMPLATE \
397tmp<Field<ReturnType>> Func \
398( \
399 const tmp<Field<Type1>>& tf1, \
400 const tmp<Field<Type2>>& tf2, \
401 const Type3& s3 \
402);
403
404
405// ************************************************************************* //