FieldFieldFunctionsM.H
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-2018 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 Description
25  High performance macro functions for Field<Type> algebra.
26  These expand using either array element access (for vector machines)
27  or pointer dereferencing for scalar machines as appropriate.
28 
29 \*---------------------------------------------------------------------------*/
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 #define UNARY_FUNCTION(ReturnType, Type1, Func) \
34  \
35 TEMPLATE \
36 void Func \
37 ( \
38  FieldField<Field, ReturnType>& res, \
39  const FieldField<Field, Type1>& f \
40 ); \
41  \
42 TEMPLATE \
43 tmp<FieldField<Field, ReturnType>> Func \
44 ( \
45  const FieldField<Field, Type1>& f \
46 ); \
47  \
48 TEMPLATE \
49 tmp<FieldField<Field, ReturnType>> Func \
50 ( \
51  const tmp<FieldField<Field, Type1>>& tf \
52 );
53 
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 #define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc) \
58  \
59 TEMPLATE \
60 void OpFunc \
61 ( \
62  FieldField<Field, ReturnType>& res, \
63  const FieldField<Field, Type1>& f \
64 ); \
65  \
66 TEMPLATE \
67 tmp<FieldField<Field, ReturnType>> operator Op \
68 ( \
69  const FieldField<Field, Type1>& f \
70 ); \
71  \
72 TEMPLATE \
73 tmp<FieldField<Field, ReturnType>> operator Op \
74 ( \
75  const tmp<FieldField<Field, Type1>>& tf \
76 );
77 
78 
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 
81 #define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
82  \
83 TEMPLATE \
84 void func \
85 ( \
86  FieldField<Field, ReturnType>& f, \
87  const FieldField<Field, Type1>& f1, \
88  const FieldField<Field, Type2>& f2 \
89 ); \
90  \
91 TEMPLATE \
92 tmp<FieldField<Field, ReturnType>> func \
93 ( \
94  const FieldField<Field, Type1>& f1, \
95  const FieldField<Field, Type2>& f2 \
96 ); \
97  \
98 TEMPLATE \
99 tmp<FieldField<Field, ReturnType>> func \
100 ( \
101  const FieldField<Field, Type1>& f1, \
102  const tmp<FieldField<Field, Type2>>& tf2 \
103 ); \
104  \
105 TEMPLATE \
106 tmp<FieldField<Field, ReturnType>> func \
107 ( \
108  const tmp<FieldField<Field, Type1>>& tf1, \
109  const FieldField<Field, Type2>& f2 \
110 ); \
111  \
112 TEMPLATE \
113 tmp<FieldField<Field, ReturnType>> func \
114 ( \
115  const tmp<FieldField<Field, Type1>>& tf1, \
116  const tmp<FieldField<Field, Type2>>& tf2 \
117 );
118 
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
123  \
124 TEMPLATE \
125 void func \
126 ( \
127  FieldField<Field, ReturnType>& f, \
128  const Type1& s1, \
129  const FieldField<Field, Type2>& f2 \
130 ); \
131  \
132 TEMPLATE \
133 tmp<FieldField<Field, ReturnType>> func \
134 ( \
135  const Type1& s1, \
136  const FieldField<Field, Type1>& f2 \
137 ); \
138  \
139 TEMPLATE \
140 tmp<FieldField<Field, ReturnType>> func \
141 ( \
142  const Type1& s1, \
143  const tmp<FieldField<Field, Type1>>& tf2 \
144 );
145 
146 
147 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
148  \
149 TEMPLATE \
150 void func \
151 ( \
152  FieldField<Field, ReturnType>& f, \
153  const FieldField<Field, Type1>& f1, \
154  const Type2& s \
155 ); \
156  \
157 TEMPLATE \
158 tmp<FieldField<Field, ReturnType>> func \
159 ( \
160  const FieldField<Field, Type1>& f1, \
161  const Type2& s \
162 ); \
163  \
164 TEMPLATE \
165 tmp<FieldField<Field, ReturnType>> func \
166 ( \
167  const tmp<FieldField<Field, Type1>>& tf1, \
168  const Type2& s \
169 );
170 
171 
172 #define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func) \
173  BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
174  BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
175 
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
180  \
181 TEMPLATE \
182 void OpFunc \
183 ( \
184  FieldField<Field, ReturnType>& f, \
185  const FieldField<Field, Type1>& f1, \
186  const FieldField<Field, Type2>& f2 \
187 ); \
188  \
189 TEMPLATE \
190 tmp<FieldField<Field, ReturnType>> operator Op \
191 ( \
192  const FieldField<Field, Type1>& f1, \
193  const FieldField<Field, Type2>& f2 \
194 ); \
195  \
196 TEMPLATE \
197 tmp<FieldField<Field, ReturnType>> operator Op \
198 ( \
199  const FieldField<Field, Type1>& f1, \
200  const tmp<FieldField<Field, Type2>>& tf2 \
201 ); \
202  \
203 TEMPLATE \
204 tmp<FieldField<Field, ReturnType>> operator Op \
205 ( \
206  const tmp<FieldField<Field, Type1>>& tf1, \
207  const FieldField<Field, Type2>& f2 \
208 ); \
209  \
210 TEMPLATE \
211 tmp<FieldField<Field, ReturnType>> operator Op \
212 ( \
213  const tmp<FieldField<Field, Type1>>& tf1, \
214  const tmp<FieldField<Field, Type2>>& tf2 \
215 );
216 
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
221  \
222 TEMPLATE \
223 void OpFunc \
224 ( \
225  FieldField<Field, ReturnType>& f, \
226  const Type1& s1, \
227  const FieldField<Field, Type2>& f2 \
228 ); \
229  \
230 TEMPLATE \
231 tmp<FieldField<Field, ReturnType>> operator Op \
232 ( \
233  const Type1& s1, \
234  const FieldField<Field, Type2>& f2 \
235 ); \
236  \
237 TEMPLATE \
238 tmp<FieldField<Field, ReturnType>> operator Op \
239 ( \
240  const Type1& s1, \
241  const tmp<FieldField<Field, Type2>>& tf2 \
242 );
243 
244 
245 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc) \
246  \
247 TEMPLATE \
248 void OpFunc \
249 ( \
250  FieldField<Field, ReturnType>& f, \
251  const FieldField<Field, Type1>& f1, \
252  const Type2& s2 \
253 ); \
254  \
255 TEMPLATE \
256 tmp<FieldField<Field, ReturnType>> operator Op \
257 ( \
258  const FieldField<Field, Type1>& f1, \
259  const Type2& s2 \
260 ); \
261  \
262 TEMPLATE \
263 tmp<FieldField<Field, ReturnType>> operator Op \
264 ( \
265  const tmp<FieldField<Field, Type1>>& tf1, \
266  const Type2& s2 \
267 );
268 
269 
270 #define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
271  BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
272  BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)
273 
274 
275 // ************************************************************************* //