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 -------------------------------------------------------------------------------
10 License
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 
26 Description
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  \
37 TEMPLATE \
38 void Func \
39 ( \
40  FieldField<Field, ReturnType>& res, \
41  const FieldField<Field, Type1>& f \
42 ); \
43  \
44 TEMPLATE \
45 tmp<FieldField<Field, ReturnType>> Func \
46 ( \
47  const FieldField<Field, Type1>& f \
48 ); \
49  \
50 TEMPLATE \
51 tmp<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  \
61 TEMPLATE \
62 void OpFunc \
63 ( \
64  FieldField<Field, ReturnType>& res, \
65  const FieldField<Field, Type1>& f \
66 ); \
67  \
68 TEMPLATE \
69 tmp<FieldField<Field, ReturnType>> operator Op \
70 ( \
71  const FieldField<Field, Type1>& f \
72 ); \
73  \
74 TEMPLATE \
75 tmp<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  \
85 TEMPLATE \
86 void func \
87 ( \
88  FieldField<Field, ReturnType>& f, \
89  const FieldField<Field, Type1>& f1, \
90  const FieldField<Field, Type2>& f2 \
91 ); \
92  \
93 TEMPLATE \
94 tmp<FieldField<Field, ReturnType>> func \
95 ( \
96  const FieldField<Field, Type1>& f1, \
97  const FieldField<Field, Type2>& f2 \
98 ); \
99  \
100 TEMPLATE \
101 tmp<FieldField<Field, ReturnType>> func \
102 ( \
103  const FieldField<Field, Type1>& f1, \
104  const tmp<FieldField<Field, Type2>>& tf2 \
105 ); \
106  \
107 TEMPLATE \
108 tmp<FieldField<Field, ReturnType>> func \
109 ( \
110  const tmp<FieldField<Field, Type1>>& tf1, \
111  const FieldField<Field, Type2>& f2 \
112 ); \
113  \
114 TEMPLATE \
115 tmp<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  \
126 TEMPLATE \
127 void func \
128 ( \
129  FieldField<Field, ReturnType>& f, \
130  const Type1& s1, \
131  const FieldField<Field, Type2>& f2 \
132 ); \
133  \
134 TEMPLATE \
135 tmp<FieldField<Field, ReturnType>> func \
136 ( \
137  const Type1& s1, \
138  const FieldField<Field, Type1>& f2 \
139 ); \
140  \
141 TEMPLATE \
142 tmp<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  \
151 TEMPLATE \
152 void func \
153 ( \
154  FieldField<Field, ReturnType>& f, \
155  const FieldField<Field, Type1>& f1, \
156  const Type2& s \
157 ); \
158  \
159 TEMPLATE \
160 tmp<FieldField<Field, ReturnType>> func \
161 ( \
162  const FieldField<Field, Type1>& f1, \
163  const Type2& s \
164 ); \
165  \
166 TEMPLATE \
167 tmp<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  \
183 TEMPLATE \
184 void OpFunc \
185 ( \
186  FieldField<Field, ReturnType>& f, \
187  const FieldField<Field, Type1>& f1, \
188  const FieldField<Field, Type2>& f2 \
189 ); \
190  \
191 TEMPLATE \
192 tmp<FieldField<Field, ReturnType>> operator Op \
193 ( \
194  const FieldField<Field, Type1>& f1, \
195  const FieldField<Field, Type2>& f2 \
196 ); \
197  \
198 TEMPLATE \
199 tmp<FieldField<Field, ReturnType>> operator Op \
200 ( \
201  const FieldField<Field, Type1>& f1, \
202  const tmp<FieldField<Field, Type2>>& tf2 \
203 ); \
204  \
205 TEMPLATE \
206 tmp<FieldField<Field, ReturnType>> operator Op \
207 ( \
208  const tmp<FieldField<Field, Type1>>& tf1, \
209  const FieldField<Field, Type2>& f2 \
210 ); \
211  \
212 TEMPLATE \
213 tmp<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  \
224 TEMPLATE \
225 void OpFunc \
226 ( \
227  FieldField<Field, ReturnType>& f, \
228  const Type1& s1, \
229  const FieldField<Field, Type2>& f2 \
230 ); \
231  \
232 TEMPLATE \
233 tmp<FieldField<Field, ReturnType>> operator Op \
234 ( \
235  const Type1& s1, \
236  const FieldField<Field, Type2>& f2 \
237 ); \
238  \
239 TEMPLATE \
240 tmp<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  \
249 TEMPLATE \
250 void OpFunc \
251 ( \
252  FieldField<Field, ReturnType>& f, \
253  const FieldField<Field, Type1>& f1, \
254  const Type2& s2 \
255 ); \
256  \
257 TEMPLATE \
258 tmp<FieldField<Field, ReturnType>> operator Op \
259 ( \
260  const FieldField<Field, Type1>& f1, \
261  const Type2& s2 \
262 ); \
263  \
264 TEMPLATE \
265 tmp<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 // ************************************************************************* //