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-------------------------------------------------------------------------------
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. 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 \
37TEMPLATE \
38void Func(Field<ReturnType>& res, const UList<Type1>& f); \
39TEMPLATE \
40tmp<Field<ReturnType>> Func(const UList<Type1>& f); \
41TEMPLATE \
42tmp<Field<ReturnType>> Func(const tmp<Field<Type1>>& tf);
43
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc) \
48 \
49TEMPLATE \
50void OpFunc(Field<ReturnType>& res, const UList<Type1>& f); \
51TEMPLATE \
52tmp<Field<ReturnType>> operator Op(const UList<Type1>& f); \
53TEMPLATE \
54tmp<Field<ReturnType>> operator Op(const tmp<Field<Type1>>& tf);
55
56
57// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58
59#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
60 \
61TEMPLATE \
62void Func \
63( \
64 Field<ReturnType>& f, \
65 const UList<Type1>& f1, \
66 const UList<Type2>& f2 \
67); \
68 \
69TEMPLATE \
70tmp<Field<ReturnType>> Func \
71( \
72 const UList<Type1>& f1, \
73 const UList<Type2>& f2 \
74); \
75 \
76TEMPLATE \
77tmp<Field<ReturnType>> Func \
78( \
79 const UList<Type1>& f1, \
80 const tmp<Field<Type2>>& tf2 \
81); \
82 \
83TEMPLATE \
84tmp<Field<ReturnType>> Func \
85( \
86 const tmp<Field<Type1>>& tf1, \
87 const UList<Type2>& f2 \
88); \
89 \
90TEMPLATE \
91tmp<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 \
102TEMPLATE \
103void Func \
104( \
105 Field<ReturnType>& f, \
106 const Type1& s1, \
107 const UList<Type2>& f2 \
108); \
109 \
110TEMPLATE \
111tmp<Field<ReturnType>> Func \
112( \
113 const Type1& s1, \
114 const UList<Type2>& f2 \
115); \
116 \
117TEMPLATE \
118tmp<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 \
127TEMPLATE \
128void Func \
129( \
130 Field<ReturnType>& f, \
131 const UList<Type1>& f1, \
132 const Type2& s2 \
133); \
134 \
135TEMPLATE \
136tmp<Field<ReturnType>> Func \
137( \
138 const UList<Type1>& f1, \
139 const Type2& s2 \
140); \
141 \
142TEMPLATE \
143tmp<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 \
159TEMPLATE \
160void OpFunc \
161( \
162 Field<ReturnType>& f, \
163 const UList<Type1>& f1, \
164 const UList<Type2>& f2 \
165); \
166 \
167TEMPLATE \
168tmp<Field<ReturnType>> operator Op \
169( \
170 const UList<Type1>& f1, \
171 const UList<Type2>& f2 \
172); \
173 \
174TEMPLATE \
175tmp<Field<ReturnType>> operator Op \
176( \
177 const UList<Type1>& f1, \
178 const tmp<Field<Type2>>& tf2 \
179); \
180 \
181TEMPLATE \
182tmp<Field<ReturnType>> operator Op \
183( \
184 const tmp<Field<Type1>>& tf1, \
185 const UList<Type2>& f2 \
186); \
187 \
188TEMPLATE \
189tmp<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 \
200TEMPLATE \
201void OpFunc \
202( \
203 Field<ReturnType>& f, \
204 const Type1& s1, \
205 const UList<Type2>& f2 \
206); \
207 \
208TEMPLATE \
209tmp<Field<ReturnType>> operator Op \
210( \
211 const Type1& s1, \
212 const UList<Type2>& f2 \
213); \
214 \
215TEMPLATE \
216tmp<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 \
225TEMPLATE \
226void OpFunc \
227( \
228 Field<ReturnType>& f, \
229 const UList<Type1>& f1, \
230 const Type2& s2 \
231); \
232 \
233TEMPLATE \
234tmp<Field<ReturnType>> operator Op \
235( \
236 const UList<Type1>& f1, \
237 const Type2& s2 \
238); \
239 \
240TEMPLATE \
241tmp<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// ************************************************************************* //