OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 TEMPLATE                                                                      \
00037 void Func(Field<ReturnType>& res, const UList<Type1>& f);                     \
00038 TEMPLATE                                                                      \
00039 tmp<Field<ReturnType> > Func(const UList<Type1>& f);                          \
00040 TEMPLATE                                                                      \
00041 tmp<Field<ReturnType> > Func(const tmp<Field<Type1> >& tf);
00042 
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 #define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc)                         \
00047                                                                               \
00048 TEMPLATE                                                                      \
00049 void OpFunc(Field<ReturnType>& res, const UList<Type1>& f);                   \
00050 TEMPLATE                                                                      \
00051 tmp<Field<ReturnType> > operator Op(const UList<Type1>& f);                   \
00052 TEMPLATE                                                                      \
00053 tmp<Field<ReturnType> > operator Op(const tmp<Field<Type1> >& tf);
00054 
00055 
00056 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00057 
00058 #define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)                       \
00059                                                                               \
00060 TEMPLATE                                                                      \
00061 void Func                                                                     \
00062 (                                                                             \
00063     Field<ReturnType>& f,                                                     \
00064     const UList<Type1>& f1,                                                   \
00065     const UList<Type2>& f2                                                    \
00066 );                                                                            \
00067                                                                               \
00068 TEMPLATE                                                                      \
00069 tmp<Field<ReturnType> > Func                                                  \
00070 (                                                                             \
00071     const UList<Type1>& f1,                                                   \
00072     const UList<Type2>& f2                                                    \
00073 );                                                                            \
00074                                                                               \
00075 TEMPLATE                                                                      \
00076 tmp<Field<ReturnType> > Func                                                  \
00077 (                                                                             \
00078     const UList<Type1>& f1,                                                   \
00079     const tmp<Field<Type2> >& tf2                                             \
00080 );                                                                            \
00081                                                                               \
00082 TEMPLATE                                                                      \
00083 tmp<Field<ReturnType> > Func                                                  \
00084 (                                                                             \
00085     const tmp<Field<Type1> >& tf1,                                            \
00086     const UList<Type2>& f2                                                    \
00087 );                                                                            \
00088                                                                               \
00089 TEMPLATE                                                                      \
00090 tmp<Field<ReturnType> > Func                                                  \
00091 (                                                                             \
00092     const tmp<Field<Type1> >& tf1,                                            \
00093     const tmp<Field<Type2> >& tf2                                             \
00094 );
00095 
00096 
00097 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00098 
00099 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)               \
00100                                                                               \
00101 TEMPLATE                                                                      \
00102 void Func                                                                     \
00103 (                                                                             \
00104     Field<ReturnType>& f,                                                     \
00105     const Type1& s1,                                                          \
00106     const UList<Type2>& f2                                                    \
00107 );                                                                            \
00108                                                                               \
00109 TEMPLATE                                                                      \
00110 tmp<Field<ReturnType> > Func                                                  \
00111 (                                                                             \
00112     const Type1& s1,                                                          \
00113     const UList<Type2>& f2                                                    \
00114 );                                                                            \
00115                                                                               \
00116 TEMPLATE                                                                      \
00117 tmp<Field<ReturnType> > Func                                                  \
00118 (                                                                             \
00119     const Type1& s1,                                                          \
00120     const tmp<Field<Type2> >& tf2                                             \
00121 );
00122 
00123 
00124 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)               \
00125                                                                               \
00126 TEMPLATE                                                                      \
00127 void Func                                                                     \
00128 (                                                                             \
00129     Field<ReturnType>& f,                                                     \
00130     const UList<Type1>& f1,                                                   \
00131     const Type2& s2                                                           \
00132 );                                                                            \
00133                                                                               \
00134 TEMPLATE                                                                      \
00135 tmp<Field<ReturnType> > Func                                                  \
00136 (                                                                             \
00137     const UList<Type1>& f1,                                                   \
00138     const Type2& s2                                                           \
00139 );                                                                            \
00140                                                                               \
00141 TEMPLATE                                                                      \
00142 tmp<Field<ReturnType> > Func                                                  \
00143 (                                                                             \
00144     const tmp<Field<Type1> >& tf1,                                            \
00145     const Type2& s2                                                           \
00146 );
00147 
00148 
00149 #define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)                  \
00150     BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)                   \
00151     BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
00152 
00153 
00154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00155 
00156 #define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc)                 \
00157                                                                               \
00158 TEMPLATE                                                                      \
00159 void OpFunc                                                                   \
00160 (                                                                             \
00161     Field<ReturnType>& f,                                                     \
00162     const UList<Type1>& f1,                                                   \
00163     const UList<Type2>& f2                                                    \
00164 );                                                                            \
00165                                                                               \
00166 TEMPLATE                                                                      \
00167 tmp<Field<ReturnType> > operator Op                                           \
00168 (                                                                             \
00169     const UList<Type1>& f1,                                                   \
00170     const UList<Type2>& f2                                                    \
00171 );                                                                            \
00172                                                                               \
00173 TEMPLATE                                                                      \
00174 tmp<Field<ReturnType> > operator Op                                           \
00175 (                                                                             \
00176     const UList<Type1>& f1,                                                   \
00177     const tmp<Field<Type2> >& tf2                                             \
00178 );                                                                            \
00179                                                                               \
00180 TEMPLATE                                                                      \
00181 tmp<Field<ReturnType> > operator Op                                           \
00182 (                                                                             \
00183     const tmp<Field<Type1> >& tf1,                                            \
00184     const UList<Type2>& f2                                                    \
00185 );                                                                            \
00186                                                                               \
00187 TEMPLATE                                                                      \
00188 tmp<Field<ReturnType> > operator Op                                           \
00189 (                                                                             \
00190     const tmp<Field<Type1> >& tf1,                                            \
00191     const tmp<Field<Type2> >& tf2                                             \
00192 );
00193 
00194 
00195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00196 
00197 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc)         \
00198                                                                               \
00199 TEMPLATE                                                                      \
00200 void OpFunc                                                                   \
00201 (                                                                             \
00202     Field<ReturnType>& f,                                                     \
00203     const Type1& s1,                                                          \
00204     const UList<Type2>& f2                                                    \
00205 );                                                                            \
00206                                                                               \
00207 TEMPLATE                                                                      \
00208 tmp<Field<ReturnType> > operator Op                                           \
00209 (                                                                             \
00210     const Type1& s1,                                                          \
00211     const UList<Type2>& f2                                                    \
00212 );                                                                            \
00213                                                                               \
00214 TEMPLATE                                                                      \
00215 tmp<Field<ReturnType> > operator Op                                           \
00216 (                                                                             \
00217     const Type1& s1,                                                          \
00218     const tmp<Field<Type2> >& tf2                                             \
00219 );
00220 
00221 
00222 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)         \
00223                                                                               \
00224 TEMPLATE                                                                      \
00225 void OpFunc                                                                   \
00226 (                                                                             \
00227     Field<ReturnType>& f,                                                     \
00228     const UList<Type1>& f1,                                                   \
00229     const Type2& s2                                                           \
00230 );                                                                            \
00231                                                                               \
00232 TEMPLATE                                                                      \
00233 tmp<Field<ReturnType> > operator Op                                           \
00234 (                                                                             \
00235     const UList<Type1>& f1,                                                   \
00236     const Type2& s2                                                           \
00237 );                                                                            \
00238                                                                               \
00239 TEMPLATE                                                                      \
00240 tmp<Field<ReturnType> > operator Op                                           \
00241 (                                                                             \
00242     const tmp<Field<Type1> >& tf1,                                            \
00243     const Type2& s2                                                           \
00244 );
00245 
00246 
00247 #define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc)            \
00248     BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc)             \
00249     BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)
00250 
00251 
00252 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd