1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
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.
26 These expand using either array element access (for vector machines)
27 or pointer dereferencing for scalar machines as appropriate.
29 \*---------------------------------------------------------------------------*/
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 #define UNARY_FUNCTION(ReturnType, Type1, Func) \
38 FieldField<Field, ReturnType>& res, \
39 const FieldField<Field, Type1>& f \
43 tmp<FieldField<Field, ReturnType> > Func \
45 const FieldField<Field, Type1>& f \
49 tmp<FieldField<Field, ReturnType> > Func \
51 const tmp<FieldField<Field, Type1> >& tf \
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 #define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc) \
62 FieldField<Field, ReturnType>& res, \
63 const FieldField<Field, Type1>& f \
67 tmp<FieldField<Field, ReturnType> > operator Op \
69 const FieldField<Field, Type1>& f \
73 tmp<FieldField<Field, ReturnType> > operator Op \
75 const tmp<FieldField<Field, Type1> >& tf \
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 #define BINARY_FUNCTION(ReturnType, Type1, Type2, Func) \
86 FieldField<Field, ReturnType>& f, \
87 const FieldField<Field, Type1>& f1, \
88 const FieldField<Field, Type2>& f2 \
92 tmp<FieldField<Field, ReturnType> > func \
94 const FieldField<Field, Type1>& f1, \
95 const FieldField<Field, Type2>& f2 \
99 tmp<FieldField<Field, ReturnType> > func \
101 const FieldField<Field, Type1>& f1, \
102 const tmp<FieldField<Field, Type2> >& tf2 \
106 tmp<FieldField<Field, ReturnType> > func \
108 const tmp<FieldField<Field, Type1> >& tf1, \
109 const FieldField<Field, Type2>& f2 \
113 tmp<FieldField<Field, ReturnType> > func \
115 const tmp<FieldField<Field, Type1> >& tf1, \
116 const tmp<FieldField<Field, Type2> >& tf2 \
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
127 FieldField<Field, ReturnType>& f, \
129 const FieldField<Field, Type2>& f2 \
133 tmp<FieldField<Field, ReturnType> > func \
136 const FieldField<Field, Type1>& f2 \
140 tmp<FieldField<Field, ReturnType> > func \
143 const tmp<FieldField<Field, Type1> >& tf2 \
147 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func) \
152 FieldField<Field, ReturnType>& f, \
153 const FieldField<Field, Type1>& f1, \
158 tmp<FieldField<Field, ReturnType> > func \
160 const FieldField<Field, Type1>& f1, \
165 tmp<FieldField<Field, ReturnType> > func \
167 const tmp<FieldField<Field, Type1> >& tf1, \
172 #define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func) \
173 BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \
174 BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 #define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
184 FieldField<Field, ReturnType>& f, \
185 const FieldField<Field, Type1>& f1, \
186 const FieldField<Field, Type2>& f2 \
190 tmp<FieldField<Field, ReturnType> > operator Op \
192 const FieldField<Field, Type1>& f1, \
193 const FieldField<Field, Type2>& f2 \
197 tmp<FieldField<Field, ReturnType> > operator Op \
199 const FieldField<Field, Type1>& f1, \
200 const tmp<FieldField<Field, Type2> >& tf2 \
204 tmp<FieldField<Field, ReturnType> > operator Op \
206 const tmp<FieldField<Field, Type1> >& tf1, \
207 const FieldField<Field, Type2>& f2 \
211 tmp<FieldField<Field, ReturnType> > operator Op \
213 const tmp<FieldField<Field, Type1> >& tf1, \
214 const tmp<FieldField<Field, Type2> >& tf2 \
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
225 FieldField<Field, ReturnType>& f, \
227 const FieldField<Field, Type2>& f2 \
231 tmp<FieldField<Field, ReturnType> > operator Op \
234 const FieldField<Field, Type2>& f2 \
238 tmp<FieldField<Field, ReturnType> > operator Op \
241 const tmp<FieldField<Field, Type2> >& tf2 \
245 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc) \
250 FieldField<Field, ReturnType>& f, \
251 const FieldField<Field, Type1>& f1, \
256 tmp<FieldField<Field, ReturnType> > operator Op \
258 const FieldField<Field, Type1>& f1, \
263 tmp<FieldField<Field, ReturnType> > operator Op \
265 const tmp<FieldField<Field, Type1> >& tf1, \
270 #define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc) \
271 BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc) \
272 BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)
275 // ************************************************************************* //