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