1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
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.
29 \*---------------------------------------------------------------------------*/
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 #define UNARY_FUNCTION(ReturnType, Type1, Func) \
36 void Func(Field<ReturnType>& res, const UList<Type1>& f); \
38 tmp<Field<ReturnType> > Func(const UList<Type1>& f); \
40 tmp<Field<ReturnType> > Func(const tmp<Field<Type1> >& tf);
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 #define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc) \
48 void OpFunc(Field<ReturnType>& res, const UList<Type1>& f); \
50 tmp<Field<ReturnType> > operator Op(const UList<Type1>& f); \
52 tmp<Field<ReturnType> > operator Op(const tmp<Field<Type1> >& tf);
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 #define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
62 Field<ReturnType>& f, \
63 const UList<Type1>& f1, \
64 const UList<Type2>& f2 \
68 tmp<Field<ReturnType> > Func \
70 const UList<Type1>& f1, \
71 const UList<Type2>& f2 \
75 tmp<Field<ReturnType> > Func \
77 const UList<Type1>& f1, \
78 const tmp<Field<Type2> >& tf2 \
82 tmp<Field<ReturnType> > Func \
84 const tmp<Field<Type1> >& tf1, \
85 const UList<Type2>& f2 \
89 tmp<Field<ReturnType> > Func \
91 const tmp<Field<Type1> >& tf1, \
92 const tmp<Field<Type2> >& tf2 \
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
103 Field<ReturnType>& f, \
105 const UList<Type2>& f2 \
109 tmp<Field<ReturnType> > Func \
112 const UList<Type2>& f2 \
116 tmp<Field<ReturnType> > Func \
119 const tmp<Field<Type2> >& tf2 \
123 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
128 Field<ReturnType>& f, \
129 const UList<Type1>& f1, \
134 tmp<Field<ReturnType> > Func \
136 const UList<Type1>& f1, \
141 tmp<Field<ReturnType> > Func \
143 const tmp<Field<Type1> >& tf1, \
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)
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 #define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
160 Field<ReturnType>& f, \
161 const UList<Type1>& f1, \
162 const UList<Type2>& f2 \
166 tmp<Field<ReturnType> > operator Op \
168 const UList<Type1>& f1, \
169 const UList<Type2>& f2 \
173 tmp<Field<ReturnType> > operator Op \
175 const UList<Type1>& f1, \
176 const tmp<Field<Type2> >& tf2 \
180 tmp<Field<ReturnType> > operator Op \
182 const tmp<Field<Type1> >& tf1, \
183 const UList<Type2>& f2 \
187 tmp<Field<ReturnType> > operator Op \
189 const tmp<Field<Type1> >& tf1, \
190 const tmp<Field<Type2> >& tf2 \
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
201 Field<ReturnType>& f, \
203 const UList<Type2>& f2 \
207 tmp<Field<ReturnType> > operator Op \
210 const UList<Type2>& f2 \
214 tmp<Field<ReturnType> > operator Op \
217 const tmp<Field<Type2> >& tf2 \
221 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc) \
226 Field<ReturnType>& f, \
227 const UList<Type1>& f1, \
232 tmp<Field<ReturnType> > operator Op \
234 const UList<Type1>& f1, \
239 tmp<Field<ReturnType> > operator Op \
241 const tmp<Field<Type1> >& tf1, \
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)
251 // ************************************************************************* //