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 -------------------------------------------------------------------------------
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 Description
28  Macro functions for Field<Type> algebra.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 #define UNARY_FUNCTION(ReturnType, Type1, Func) \
35  \
36 TEMPLATE \
37 void Func(Field<ReturnType>& result, const UList<Type1>& f1); \
38  \
39 TEMPLATE \
40 tmp<Field<ReturnType>> Func(const UList<Type1>& f1); \
41  \
42 TEMPLATE \
43 tmp<Field<ReturnType>> Func(const tmp<Field<Type1>>& tf1);
44 
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 #define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc) \
49  \
50 TEMPLATE \
51 void OpFunc(Field<ReturnType>& res, const UList<Type1>& f1); \
52  \
53 TEMPLATE \
54 tmp<Field<ReturnType>> operator Op(const UList<Type1>& f1); \
55  \
56 TEMPLATE \
57 tmp<Field<ReturnType>> operator Op(const tmp<Field<Type1>>& tf1);
58 
59 
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 
62 #define BINARY_FUNCTION_TRANSFORM(ReturnType, Type1, Type2, Func) \
63  \
64 TEMPLATE \
65 void 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  \
74 TEMPLATE \
75 tmp<Field<ReturnType>> Func \
76 ( \
77  const UList<Type1>& f1, \
78  const UList<Type2>& f2 \
79 ); \
80  \
81 TEMPLATE \
82 tmp<Field<ReturnType>> Func \
83 ( \
84  const UList<Type1>& f1, \
85  const tmp<Field<Type2>>& tf2 \
86 ); \
87  \
88 TEMPLATE \
89 tmp<Field<ReturnType>> Func \
90 ( \
91  const tmp<Field<Type1>>& tf1, \
92  const UList<Type2>& f2 \
93 ); \
94  \
95 TEMPLATE \
96 tmp<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  \
110 TEMPLATE \
111 void 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  \
120 TEMPLATE \
121 tmp<Field<ReturnType>> Func \
122 ( \
123  const Type1& s1, \
124  const UList<Type2>& f2 \
125 ); \
126  \
127 TEMPLATE \
128 tmp<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  \
141 TEMPLATE \
142 void 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  \
151 TEMPLATE \
152 tmp<Field<ReturnType>> Func \
153 ( \
154  const UList<Type1>& f1, \
155  const Type2& s2 \
156 ); \
157  \
158 TEMPLATE \
159 tmp<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  \
179 TEMPLATE \
180 void OpFunc \
181 ( \
182  Field<ReturnType>& result, \
183  const UList<Type1>& f1, \
184  const UList<Type2>& f2 \
185 ); \
186  \
187 TEMPLATE \
188 tmp<Field<ReturnType>> operator Op \
189 ( \
190  const UList<Type1>& f1, \
191  const UList<Type2>& f2 \
192 ); \
193  \
194 TEMPLATE \
195 tmp<Field<ReturnType>> operator Op \
196 ( \
197  const UList<Type1>& f1, \
198  const tmp<Field<Type2>>& tf2 \
199 ); \
200  \
201 TEMPLATE \
202 tmp<Field<ReturnType>> operator Op \
203 ( \
204  const tmp<Field<Type1>>& tf1, \
205  const UList<Type2>& f2 \
206 ); \
207  \
208 TEMPLATE \
209 tmp<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  \
220 TEMPLATE \
221 void OpFunc \
222 ( \
223  Field<ReturnType>& result, \
224  const Type1& s1, \
225  const UList<Type2>& f2 \
226 ); \
227  \
228 TEMPLATE \
229 tmp<Field<ReturnType>> operator Op \
230 ( \
231  const Type1& s1, \
232  const UList<Type2>& f2 \
233 ); \
234  \
235 TEMPLATE \
236 tmp<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  \
245 TEMPLATE \
246 void OpFunc \
247 ( \
248  Field<ReturnType>& result, \
249  const UList<Type1>& f1, \
250  const Type2& s2 \
251 ); \
252  \
253 TEMPLATE \
254 tmp<Field<ReturnType>> operator Op \
255 ( \
256  const UList<Type1>& f1, \
257  const Type2& s2 \
258 ); \
259  \
260 TEMPLATE \
261 tmp<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  \
277 TEMPLATE \
278 void Func \
279 ( \
280  Field<ReturnType>& result, \
281  const UList<Type1>& f1, \
282  const UList<Type2>& f2, \
283  const UList<Type3>& f3 \
284 ); \
285  \
286 TEMPLATE \
287 tmp<Field<ReturnType>> Func \
288 ( \
289  const UList<Type1>& f1, \
290  const UList<Type2>& f2, \
291  const UList<Type3>& f3 \
292 ); \
293  \
294 TEMPLATE \
295 tmp<Field<ReturnType>> Func \
296 ( \
297  const tmp<Field<Type1>>& tf1, \
298  const UList<Type2>& f2, \
299  const UList<Type3>& f3 \
300 ); \
301  \
302 TEMPLATE \
303 tmp<Field<ReturnType>> Func \
304 ( \
305  const UList<Type1>& f1, \
306  const tmp<Field<Type2>>& tf2, \
307  const UList<Type3>& f3 \
308 ); \
309  \
310 TEMPLATE \
311 tmp<Field<ReturnType>> Func \
312 ( \
313  const UList<Type1>& f1, \
314  const UList<Type2>& f2, \
315  const tmp<Field<Type3>>& tf3 \
316 ); \
317  \
318 TEMPLATE \
319 tmp<Field<ReturnType>> Func \
320 ( \
321  const tmp<Field<Type1>>& tf1, \
322  const tmp<Field<Type2>>& tf2, \
323  const UList<Type3>& f3 \
324 ); \
325  \
326 TEMPLATE \
327 tmp<Field<ReturnType>> Func \
328 ( \
329  const tmp<Field<Type1>>& tf1, \
330  const UList<Type2>& f2, \
331  const tmp<Field<Type3>>& tf3 \
332 ); \
333  \
334 TEMPLATE \
335 tmp<Field<ReturnType>> Func \
336 ( \
337  const UList<Type1>& f1, \
338  const tmp<Field<Type2>>& tf2, \
339  const tmp<Field<Type3>>& tf3 \
340 ); \
341  \
342 TEMPLATE \
343 tmp<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  \
363 TEMPLATE \
364 void Func \
365 ( \
366  Field<ReturnType>& result, \
367  const UList<Type1>& f1, \
368  const UList<Type2>& f2, \
369  const Type3& s3 \
370 ); \
371  \
372 TEMPLATE \
373 tmp<Field<ReturnType>> Func \
374 ( \
375  const UList<Type1>& f1, \
376  const UList<Type2>& f2, \
377  const Type3& s3 \
378 ); \
379  \
380 TEMPLATE \
381 tmp<Field<ReturnType>> Func \
382 ( \
383  const tmp<Field<Type1>>& tf1, \
384  const UList<Type2>& f2, \
385  const Type3& s3 \
386 ); \
387  \
388 TEMPLATE \
389 tmp<Field<ReturnType>> Func \
390 ( \
391  const UList<Type1>& f1, \
392  const tmp<Field<Type2>>& tf2, \
393  const Type3& s3 \
394 ); \
395  \
396 TEMPLATE \
397 tmp<Field<ReturnType>> Func \
398 ( \
399  const tmp<Field<Type1>>& tf1, \
400  const tmp<Field<Type2>>& tf2, \
401  const Type3& s3 \
402 );
403 
404 
405 // ************************************************************************* //