OpenFOAM logo
Open Source CFD Toolkit

FieldFunctionsM.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026     High performance macro functions for Field<Type> algebra.  These expand
00027     using either array element access (for vector machines) or pointer
00028     dereferencing for scalar machines as appropriate.
00029 
00030 \*---------------------------------------------------------------------------*/
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 #define UNARY_FUNCTION(ReturnType, Type1, Func)                               \
00035                                                                               \
00036 void Func(Field<ReturnType>& f, const UList<Type1>& f1);                      \
00037 tmp<Field<ReturnType> > Func(const UList<Type1>& f1);
00038 
00039 #define UNARY_FUNCTION_N(ReturnType, Type1, Func)                             \
00040                                                                               \
00041 UNARY_FUNCTION(ReturnType, Type1, Func)                                       \
00042 tmp<Field<ReturnType> > Func(const tmp<Field<Type1> >& tf1);
00043 
00044 #define UNARY_FUNCTION_R(ReturnType, Type1, Func)                             \
00045                                                                               \
00046 UNARY_FUNCTION(ReturnType, Type1, Func)                                       \
00047 tmp<Field<ReturnType> > Func(const tmp<Field<Type1> >& tf1);
00048 
00049 
00050 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00051 
00052 #define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc)                         \
00053                                                                               \
00054 void OpFunc(Field<ReturnType>& f, const UList<Type1>& f1);                    \
00055 tmp<Field<ReturnType> > operator Op(const UList<Type1>& f1);
00056 
00057 #define UNARY_OPERATOR_N(ReturnType, Type1, Op, OpFunc)                       \
00058                                                                               \
00059 UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc)                                 \
00060 tmp<Field<ReturnType> > operator Op(const tmp<Field<Type1> >& tf1);
00061 
00062 #define UNARY_OPERATOR_R(ReturnType, Type1, Op, OpFunc)                       \
00063                                                                               \
00064 UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc)                                 \
00065 tmp<Field<ReturnType> > operator Op(const tmp<Field<Type1> >& tf1);
00066 
00067 
00068 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00069 
00070 #define BINARY_FUNCTION_FF(ReturnType, Type1, Type2, Func)                    \
00071                                                                               \
00072 void Func                                                                     \
00073 (                                                                             \
00074     Field<ReturnType>& f,                                                     \
00075     const UList<Type1>& f1,                                                   \
00076     const UList<Type2>& f2                                                    \
00077 );                                                                            \
00078                                                                               \
00079 tmp<Field<ReturnType> > Func                                                  \
00080 (                                                                             \
00081     const UList<Type1>& f1,                                                   \
00082     const UList<Type2>& f2                                                    \
00083 );
00084 
00085 #define BINARY_FUNCTION_FT(ReturnType, Type1, Type2, Func)                    \
00086 tmp<Field<ReturnType> > Func                                                  \
00087 (                                                                             \
00088     const UList<Type1>& f1,                                                   \
00089     const tmp<Field<Type2> >& tf2                                             \
00090 );
00091 
00092 #define BINARY_FUNCTION_FR(ReturnType, Type1, Type2, Func)                    \
00093 tmp<Field<ReturnType> > Func                                                  \
00094 (                                                                             \
00095     const UList<Type1>& f1,                                                   \
00096     const tmp<Field<Type2> >& tf2                                             \
00097 );
00098 
00099 
00100 #define BINARY_FUNCTION_TF(ReturnType, Type1, Type2, Func)                    \
00101 tmp<Field<ReturnType> > Func                                                  \
00102 (                                                                             \
00103     const tmp<Field<Type1> >& tf1,                                            \
00104     const UList<Type2>& f2                                                    \
00105 );
00106 
00107 #define BINARY_FUNCTION_TT(ReturnType, Type1, Type2, Func)                    \
00108 tmp<Field<ReturnType> > Func                                                  \
00109 (                                                                             \
00110     const tmp<Field<Type1> >& tf1,                                            \
00111     const tmp<Field<Type2> >& tf2                                             \
00112 );
00113 
00114 #define BINARY_FUNCTION_TR(ReturnType, Type1, Type2, Func)                    \
00115 tmp<Field<ReturnType> > Func                                                  \
00116 (                                                                             \
00117     const tmp<Field<Type1> >& tf1,                                            \
00118     const tmp<Field<Type2> >& tf2                                             \
00119 );
00120 
00121 
00122 #define BINARY_FUNCTION_RF(ReturnType, Type1, Type2, Func)                    \
00123 tmp<Field<ReturnType> > Func                                                  \
00124 (                                                                             \
00125     const tmp<Field<Type1> >& tf1,                                            \
00126     const UList<Type2>& f2                                                    \
00127 );
00128 
00129 #define BINARY_FUNCTION_RT(ReturnType, Type1, Type2, Func)                    \
00130 tmp<Field<ReturnType> > Func                                                  \
00131 (                                                                             \
00132     const tmp<Field<Type1> >& tf1,                                            \
00133     const tmp<Field<Type2> >& tf2                                             \
00134 );
00135 
00136 
00137 #define BINARY_FUNCTION_NN(ReturnType, Type1, Type2, Func)                    \
00138     BINARY_FUNCTION_FF(ReturnType, Type1, Type2, Func)                        \
00139     BINARY_FUNCTION_FT(ReturnType, Type1, Type2, Func)                        \
00140     BINARY_FUNCTION_TF(ReturnType, Type1, Type2, Func)                        \
00141     BINARY_FUNCTION_TT(ReturnType, Type1, Type2, Func)
00142 
00143 #define BINARY_FUNCTION_NR(ReturnType, Type1, Type2, Func)                    \
00144     BINARY_FUNCTION_FF(ReturnType, Type1, Type2, Func)                        \
00145     BINARY_FUNCTION_FR(ReturnType, Type1, Type2, Func)                        \
00146     BINARY_FUNCTION_TF(ReturnType, Type1, Type2, Func)                        \
00147     BINARY_FUNCTION_TR(ReturnType, Type1, Type2, Func)
00148 
00149 #define BINARY_FUNCTION_RN(ReturnType, Type1, Type2, Func)                    \
00150     BINARY_FUNCTION_FF(ReturnType, Type1, Type2, Func)                        \
00151     BINARY_FUNCTION_FT(ReturnType, Type1, Type2, Func)                        \
00152     BINARY_FUNCTION_RF(ReturnType, Type1, Type2, Func)                        \
00153     BINARY_FUNCTION_RT(ReturnType, Type1, Type2, Func)
00154 
00155 #define BINARY_FUNCTION_RR(ReturnType, Type1, Type2, Func)                    \
00156     BINARY_FUNCTION_FF(ReturnType, Type1, Type2, Func)                        \
00157     BINARY_FUNCTION_FR(ReturnType, Type1, Type2, Func)                        \
00158     BINARY_FUNCTION_RF(ReturnType, Type1, Type2, Func)                        \
00159     BINARY_FUNCTION_RT(ReturnType, Type1, Type2, Func)
00160 
00161 
00162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00163 
00164 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)               \
00165                                                                               \
00166 void Func                                                                     \
00167 (                                                                             \
00168     Field<ReturnType>& f,                                                     \
00169     const Type1& s1,                                                          \
00170     const UList<Type2>& f2                                                    \
00171 );                                                                            \
00172                                                                               \
00173 tmp<Field<ReturnType> > Func                                                  \
00174 (                                                                             \
00175     const Type1& s1,                                                          \
00176     const UList<Type2>& f2                                                    \
00177 );
00178 
00179 #define BINARY_TYPE_FUNCTION_ST(ReturnType, Type1, Type2, Func)               \
00180 tmp<Field<ReturnType> > Func                                                  \
00181 (                                                                             \
00182     const Type1& s1,                                                          \
00183     const tmp<Field<Type2> >& tf2                                             \
00184 );
00185 
00186 #define BINARY_TYPE_FUNCTION_SR(ReturnType, Type1, Type2, Func)               \
00187 tmp<Field<ReturnType> > Func                                                  \
00188 (                                                                             \
00189     const Type1& s1,                                                          \
00190     const tmp<Field<Type2> >& tf2                                             \
00191 );
00192 
00193 
00194 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)               \
00195                                                                               \
00196 void Func                                                                     \
00197 (                                                                             \
00198     Field<ReturnType>& f,                                                     \
00199     const UList<Type1>& f1,                                                   \
00200     const Type2& s2                                                           \
00201 );                                                                            \
00202                                                                               \
00203 tmp<Field<ReturnType> > Func                                                  \
00204 (                                                                             \
00205     const UList<Type1>& f1,                                                   \
00206     const Type2& s2                                                           \
00207 );
00208 
00209 #define BINARY_TYPE_FUNCTION_TS(ReturnType, Type1, Type2, Func)               \
00210 tmp<Field<ReturnType> > Func                                                  \
00211 (                                                                             \
00212     const tmp<Field<Type1> >& tf1,                                            \
00213     const Type2& s2                                                           \
00214 );
00215 
00216 #define BINARY_TYPE_FUNCTION_RS(ReturnType, Type1, Type2, Func)               \
00217 tmp<Field<ReturnType> > Func                                                  \
00218 (                                                                             \
00219     const tmp<Field<Type1> >& tf1,                                            \
00220     const Type2& s2                                                           \
00221 );
00222 
00223 
00224 #define BINARY_TYPE_FUNCTION_NN(ReturnType, Type1, Type2, Func)               \
00225     BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)                   \
00226     BINARY_TYPE_FUNCTION_ST(ReturnType, Type1, Type2, Func)                   \
00227     BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)                   \
00228     BINARY_TYPE_FUNCTION_TS(ReturnType, Type1, Type2, Func)
00229 
00230 #define BINARY_TYPE_FUNCTION_NR(ReturnType, Type1, Type2, Func)               \
00231     BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)                   \
00232     BINARY_TYPE_FUNCTION_SR(ReturnType, Type1, Type2, Func)                   \
00233     BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)                   \
00234     BINARY_TYPE_FUNCTION_TS(ReturnType, Type1, Type2, Func)
00235 
00236 #define BINARY_TYPE_FUNCTION_RN(ReturnType, Type1, Type2, Func)               \
00237     BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)                   \
00238     BINARY_TYPE_FUNCTION_ST(ReturnType, Type1, Type2, Func)                   \
00239     BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)                   \
00240     BINARY_TYPE_FUNCTION_RS(ReturnType, Type1, Type2, Func)
00241 
00242 #define BINARY_TYPE_FUNCTION_RR(ReturnType, Type1, Type2, Func)               \
00243     BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)                   \
00244     BINARY_TYPE_FUNCTION_SR(ReturnType, Type1, Type2, Func)                   \
00245     BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)                   \
00246     BINARY_TYPE_FUNCTION_RS(ReturnType, Type1, Type2, Func)
00247 
00248 
00249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00250 
00251 #define BINARY_OPERATOR_FF(ReturnType, Type1, Type2, Op, OpFunc)              \
00252                                                                               \
00253 void OpFunc                                                                   \
00254 (                                                                             \
00255     Field<ReturnType>& f,                                                     \
00256     const UList<Type1>& f1,                                                   \
00257     const UList<Type2>& f2                                                    \
00258 );                                                                            \
00259                                                                               \
00260 tmp<Field<ReturnType> > operator Op                                           \
00261 (                                                                             \
00262     const UList<Type1>& f1,                                                   \
00263     const UList<Type2>& f2                                                    \
00264 );
00265 
00266 #define BINARY_OPERATOR_FT(ReturnType, Type1, Type2, Op, OpFunc)              \
00267 tmp<Field<ReturnType> > operator Op                                           \
00268 (                                                                             \
00269     const UList<Type1>& f1,                                                   \
00270     const tmp<Field<Type2> >& tf2                                             \
00271 );
00272 
00273 #define BINARY_OPERATOR_FR(ReturnType, Type1, Type2, Op, OpFunc)              \
00274 tmp<Field<ReturnType> > operator Op                                           \
00275 (                                                                             \
00276     const UList<Type1>& f1,                                                   \
00277     const tmp<Field<Type2> >& tf2                                             \
00278 );
00279 
00280 
00281 #define BINARY_OPERATOR_TF(ReturnType, Type1, Type2, Op, OpFunc)              \
00282 tmp<Field<ReturnType> > operator Op                                           \
00283 (                                                                             \
00284     const tmp<Field<Type1> >& tf1,                                            \
00285     const UList<Type2>& f2                                                    \
00286 );
00287 
00288 #define BINARY_OPERATOR_TT(ReturnType, Type1, Type2, Op, OpFunc)              \
00289 tmp<Field<ReturnType> > operator Op                                           \
00290 (                                                                             \
00291     const tmp<Field<Type1> >& tf1,                                            \
00292     const tmp<Field<Type2> >& tf2                                             \
00293 );
00294 
00295 #define BINARY_OPERATOR_TR(ReturnType, Type1, Type2, Op, OpFunc)              \
00296 tmp<Field<ReturnType> > operator Op                                           \
00297 (                                                                             \
00298     const tmp<Field<Type1> >& tf1,                                            \
00299     const tmp<Field<Type2> >& tf2                                             \
00300 );
00301 
00302 
00303 #define BINARY_OPERATOR_RF(ReturnType, Type1, Type2, Op, OpFunc)              \
00304 tmp<Field<ReturnType> > operator Op                                           \
00305 (                                                                             \
00306     const tmp<Field<Type1> >& tf1,                                            \
00307     const UList<Type2>& f2                                                    \
00308 );
00309 
00310 #define BINARY_OPERATOR_RT(ReturnType, Type1, Type2, Op, OpFunc)              \
00311 tmp<Field<ReturnType> > operator Op                                           \
00312 (                                                                             \
00313     const tmp<Field<Type1> >& tf1,                                            \
00314     const tmp<Field<Type2> >& tf2                                             \
00315 );
00316 
00317 
00318 #define BINARY_OPERATOR_NN(ReturnType, Type1, Type2, Op, OpFunc)              \
00319     BINARY_OPERATOR_FF(ReturnType, Type1, Type2, Op, OpFunc)                  \
00320     BINARY_OPERATOR_FT(ReturnType, Type1, Type2, Op, OpFunc)                  \
00321     BINARY_OPERATOR_TF(ReturnType, Type1, Type2, Op, OpFunc)                  \
00322     BINARY_OPERATOR_TT(ReturnType, Type1, Type2, Op, OpFunc)
00323 
00324 #define BINARY_OPERATOR_NR(ReturnType, Type1, Type2, Op, OpFunc)              \
00325     BINARY_OPERATOR_FF(ReturnType, Type1, Type2, Op, OpFunc)                  \
00326     BINARY_OPERATOR_FR(ReturnType, Type1, Type2, Op, OpFunc)                  \
00327     BINARY_OPERATOR_TF(ReturnType, Type1, Type2, Op, OpFunc)                  \
00328     BINARY_OPERATOR_TR(ReturnType, Type1, Type2, Op, OpFunc)
00329 
00330 #define BINARY_OPERATOR_RN(ReturnType, Type1, Type2, Op, OpFunc)              \
00331     BINARY_OPERATOR_FF(ReturnType, Type1, Type2, Op, OpFunc)                  \
00332     BINARY_OPERATOR_FT(ReturnType, Type1, Type2, Op, OpFunc)                  \
00333     BINARY_OPERATOR_RF(ReturnType, Type1, Type2, Op, OpFunc)                  \
00334     BINARY_OPERATOR_RT(ReturnType, Type1, Type2, Op, OpFunc)
00335 
00336 #define BINARY_OPERATOR_RR(ReturnType, Type1, Type2, Op, OpFunc)              \
00337     BINARY_OPERATOR_FF(ReturnType, Type1, Type2, Op, OpFunc)                  \
00338     BINARY_OPERATOR_FR(ReturnType, Type1, Type2, Op, OpFunc)                  \
00339     BINARY_OPERATOR_RF(ReturnType, Type1, Type2, Op, OpFunc)                  \
00340     BINARY_OPERATOR_RT(ReturnType, Type1, Type2, Op, OpFunc)
00341 
00342 
00343 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00344 
00345 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc)         \
00346                                                                               \
00347 void OpFunc                                                                   \
00348 (                                                                             \
00349     Field<ReturnType>& f,                                                     \
00350     const Type1& s1,                                                          \
00351     const UList<Type2>& f2                                                    \
00352 );                                                                            \
00353                                                                               \
00354 tmp<Field<ReturnType> > operator Op                                           \
00355 (                                                                             \
00356     const Type1& s1,                                                          \
00357     const UList<Type2>& f2                                                    \
00358 );
00359 
00360 #define BINARY_TYPE_OPERATOR_ST(ReturnType, Type1, Type2, Op, OpFunc)         \
00361 tmp<Field<ReturnType> > operator Op                                           \
00362 (                                                                             \
00363     const Type1& s1,                                                          \
00364     const tmp<Field<Type2> >& tf2                                             \
00365 );
00366 
00367 #define BINARY_TYPE_OPERATOR_SR(ReturnType, Type1, Type2, Op, OpFunc)         \
00368 tmp<Field<ReturnType> > operator Op                                           \
00369 (                                                                             \
00370     const Type1& s1,                                                          \
00371     const tmp<Field<Type2> >& tf2                                             \
00372 );
00373 
00374 
00375 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)         \
00376                                                                               \
00377 void OpFunc                                                                   \
00378 (                                                                             \
00379     Field<ReturnType>& f,                                                     \
00380     const UList<Type1>& f1,                                                   \
00381     const Type2& s2                                                           \
00382 );                                                                            \
00383                                                                               \
00384 tmp<Field<ReturnType> > operator Op                                           \
00385 (                                                                             \
00386     const UList<Type1>& f1,                                                   \
00387     const Type2& s2                                                           \
00388 );
00389 
00390 #define BINARY_TYPE_OPERATOR_TS(ReturnType, Type1, Type2, Op, OpFunc)         \
00391 tmp<Field<ReturnType> > operator Op                                           \
00392 (                                                                             \
00393     const tmp<Field<Type1> >& tf1,                                            \
00394     const Type2& s2                                                           \
00395 );
00396 
00397 #define BINARY_TYPE_OPERATOR_RS(ReturnType, Type1, Type2, Op, OpFunc)         \
00398 tmp<Field<ReturnType> > operator Op                                           \
00399 (                                                                             \
00400     const tmp<Field<Type1> >& tf1,                                            \
00401     const Type2& s2                                                           \
00402 );
00403 
00404 
00405 #define BINARY_TYPE_OPERATOR_NN(ReturnType, Type1, Type2, Op, OpFunc)         \
00406     BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc)             \
00407     BINARY_TYPE_OPERATOR_ST(ReturnType, Type1, Type2, Op, OpFunc)             \
00408     BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)             \
00409     BINARY_TYPE_OPERATOR_TS(ReturnType, Type1, Type2, Op, OpFunc)
00410 
00411 #define BINARY_TYPE_OPERATOR_NR(ReturnType, Type1, Type2, Op, OpFunc)         \
00412     BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc)             \
00413     BINARY_TYPE_OPERATOR_SR(ReturnType, Type1, Type2, Op, OpFunc)             \
00414     BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)             \
00415     BINARY_TYPE_OPERATOR_TS(ReturnType, Type1, Type2, Op, OpFunc)
00416 
00417 #define BINARY_TYPE_OPERATOR_RN(ReturnType, Type1, Type2, Op, OpFunc)         \
00418     BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc)             \
00419     BINARY_TYPE_OPERATOR_ST(ReturnType, Type1, Type2, Op, OpFunc)             \
00420     BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)             \
00421     BINARY_TYPE_OPERATOR_RS(ReturnType, Type1, Type2, Op, OpFunc)
00422 
00423 #define BINARY_TYPE_OPERATOR_RR(ReturnType, Type1, Type2, Op, OpFunc)         \
00424     BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc)             \
00425     BINARY_TYPE_OPERATOR_SR(ReturnType, Type1, Type2, Op, OpFunc)             \
00426     BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)             \
00427     BINARY_TYPE_OPERATOR_RS(ReturnType, Type1, Type2, Op, OpFunc)
00428 
00429 
00430 // ************************************************************************* //
For further information go to www.openfoam.org