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