FieldFieldFunctionsM.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-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Description
27 High performance macro functions for Field<Type> algebra.
28 These expand using either array element access (for vector machines)
29 or pointer dereferencing for scalar machines as appropriate.
30
31\*---------------------------------------------------------------------------*/
32
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34
35#define UNARY_FUNCTION(ReturnType, Type1, Func) \
36 \
37TEMPLATE \
38void Func \
39( \
40 FieldField<Field, ReturnType>& res, \
41 const FieldField<Field, Type1>& f \
42); \
43 \
44TEMPLATE \
45tmp<FieldField<Field, ReturnType>> Func \
46( \
47 const FieldField<Field, Type1>& f \
48); \
49 \
50TEMPLATE \
51tmp<FieldField<Field, ReturnType>> Func \
52( \
53 const tmp<FieldField<Field, Type1>>& tf \
54);
55
56
57// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58
59#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc) \
60 \
61TEMPLATE \
62void OpFunc \
63( \
64 FieldField<Field, ReturnType>& res, \
65 const FieldField<Field, Type1>& f \
66); \
67 \
68TEMPLATE \
69tmp<FieldField<Field, ReturnType>> operator Op \
70( \
71 const FieldField<Field, Type1>& f \
72); \
73 \
74TEMPLATE \
75tmp<FieldField<Field, ReturnType>> operator Op \
76( \
77 const tmp<FieldField<Field, Type1>>& tf \
78);
79
80
81// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82
83#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
84 \
85TEMPLATE \
86void func \
87( \
88 FieldField<Field, ReturnType>& f, \
89 const FieldField<Field, Type1>& f1, \
90 const FieldField<Field, Type2>& f2 \
91); \
92 \
93TEMPLATE \
94tmp<FieldField<Field, ReturnType>> func \
95( \
96 const FieldField<Field, Type1>& f1, \
97 const FieldField<Field, Type2>& f2 \
98); \
99 \
100TEMPLATE \
101tmp<FieldField<Field, ReturnType>> func \
102( \
103 const FieldField<Field, Type1>& f1, \
104 const tmp<FieldField<Field, Type2>>& tf2 \
105); \
106 \
107TEMPLATE \
108tmp<FieldField<Field, ReturnType>> func \
109( \
110 const tmp<FieldField<Field, Type1>>& tf1, \
111 const FieldField<Field, Type2>& f2 \
112); \
113 \
114TEMPLATE \
115tmp<FieldField<Field, ReturnType>> func \
116( \
117 const tmp<FieldField<Field, Type1>>& tf1, \
118 const tmp<FieldField<Field, Type2>>& tf2 \
119);
120
121
122// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123
124#define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
125 \
126TEMPLATE \
127void func \
128( \
129 FieldField<Field, ReturnType>& f, \
130 const Type1& s1, \
131 const FieldField<Field, Type2>& f2 \
132); \
133 \
134TEMPLATE \
135tmp<FieldField<Field, ReturnType>> func \
136( \
137 const Type1& s1, \
138 const FieldField<Field, Type1>& f2 \
139); \
140 \
141TEMPLATE \
142tmp<FieldField<Field, ReturnType>> func \
143( \
144 const Type1& s1, \
145 const tmp<FieldField<Field, Type1>>& tf2 \
146);
147
148
149#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
150 \
151TEMPLATE \
152void func \
153( \
154 FieldField<Field, ReturnType>& f, \
155 const FieldField<Field, Type1>& f1, \
156 const Type2& s \
157); \
158 \
159TEMPLATE \
160tmp<FieldField<Field, ReturnType>> func \
161( \
162 const FieldField<Field, Type1>& f1, \
163 const Type2& s \
164); \
165 \
166TEMPLATE \
167tmp<FieldField<Field, ReturnType>> func \
168( \
169 const tmp<FieldField<Field, Type1>>& tf1, \
170 const Type2& s \
171);
172
173
174#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func) \
175 BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
176 BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
177
178
179// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180
181#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
182 \
183TEMPLATE \
184void OpFunc \
185( \
186 FieldField<Field, ReturnType>& f, \
187 const FieldField<Field, Type1>& f1, \
188 const FieldField<Field, Type2>& f2 \
189); \
190 \
191TEMPLATE \
192tmp<FieldField<Field, ReturnType>> operator Op \
193( \
194 const FieldField<Field, Type1>& f1, \
195 const FieldField<Field, Type2>& f2 \
196); \
197 \
198TEMPLATE \
199tmp<FieldField<Field, ReturnType>> operator Op \
200( \
201 const FieldField<Field, Type1>& f1, \
202 const tmp<FieldField<Field, Type2>>& tf2 \
203); \
204 \
205TEMPLATE \
206tmp<FieldField<Field, ReturnType>> operator Op \
207( \
208 const tmp<FieldField<Field, Type1>>& tf1, \
209 const FieldField<Field, Type2>& f2 \
210); \
211 \
212TEMPLATE \
213tmp<FieldField<Field, ReturnType>> operator Op \
214( \
215 const tmp<FieldField<Field, Type1>>& tf1, \
216 const tmp<FieldField<Field, Type2>>& tf2 \
217);
218
219
220// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221
222#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
223 \
224TEMPLATE \
225void OpFunc \
226( \
227 FieldField<Field, ReturnType>& f, \
228 const Type1& s1, \
229 const FieldField<Field, Type2>& f2 \
230); \
231 \
232TEMPLATE \
233tmp<FieldField<Field, ReturnType>> operator Op \
234( \
235 const Type1& s1, \
236 const FieldField<Field, Type2>& f2 \
237); \
238 \
239TEMPLATE \
240tmp<FieldField<Field, ReturnType>> operator Op \
241( \
242 const Type1& s1, \
243 const tmp<FieldField<Field, Type2>>& tf2 \
244);
245
246
247#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc) \
248 \
249TEMPLATE \
250void OpFunc \
251( \
252 FieldField<Field, ReturnType>& f, \
253 const FieldField<Field, Type1>& f1, \
254 const Type2& s2 \
255); \
256 \
257TEMPLATE \
258tmp<FieldField<Field, ReturnType>> operator Op \
259( \
260 const FieldField<Field, Type1>& f1, \
261 const Type2& s2 \
262); \
263 \
264TEMPLATE \
265tmp<FieldField<Field, ReturnType>> operator Op \
266( \
267 const tmp<FieldField<Field, Type1>>& tf1, \
268 const Type2& s2 \
269);
270
271
272#define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
273 BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
274 BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)
275
276
277// ************************************************************************* //