FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Description
00025     High performance macro functions for Field<Type> algebra.  These expand
00026     using either array element access (for vector machines) or pointer
00027     dereferencing for scalar machines as appropriate.
00028 
00029 \*---------------------------------------------------------------------------*/
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 #define UNARY_FUNCTION(ReturnType, Type1, Func)                               \
00034                                                                               \
00035 TEMPLATE                                                                      \
00036 void Func(Field<ReturnType>& res, const UList<Type1>& f);                     \
00037 TEMPLATE                                                                      \
00038 tmp<Field<ReturnType> > Func(const UList<Type1>& f);                          \
00039 TEMPLATE                                                                      \
00040 tmp<Field<ReturnType> > Func(const tmp<Field<Type1> >& tf);
00041 
00042 
00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00044 
00045 #define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc)                         \
00046                                                                               \
00047 TEMPLATE                                                                      \
00048 void OpFunc(Field<ReturnType>& res, const UList<Type1>& f);                   \
00049 TEMPLATE                                                                      \
00050 tmp<Field<ReturnType> > operator Op(const UList<Type1>& f);                   \
00051 TEMPLATE                                                                      \
00052 tmp<Field<ReturnType> > operator Op(const tmp<Field<Type1> >& tf);
00053 
00054 
00055 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00056 
00057 #define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)                       \
00058                                                                               \
00059 TEMPLATE                                                                      \
00060 void Func                                                                     \
00061 (                                                                             \
00062     Field<ReturnType>& f,                                                     \
00063     const UList<Type1>& f1,                                                   \
00064     const UList<Type2>& f2                                                    \
00065 );                                                                            \
00066                                                                               \
00067 TEMPLATE                                                                      \
00068 tmp<Field<ReturnType> > Func                                                  \
00069 (                                                                             \
00070     const UList<Type1>& f1,                                                   \
00071     const UList<Type2>& f2                                                    \
00072 );                                                                            \
00073                                                                               \
00074 TEMPLATE                                                                      \
00075 tmp<Field<ReturnType> > Func                                                  \
00076 (                                                                             \
00077     const UList<Type1>& f1,                                                   \
00078     const tmp<Field<Type2> >& tf2                                             \
00079 );                                                                            \
00080                                                                               \
00081 TEMPLATE                                                                      \
00082 tmp<Field<ReturnType> > Func                                                  \
00083 (                                                                             \
00084     const tmp<Field<Type1> >& tf1,                                            \
00085     const UList<Type2>& f2                                                    \
00086 );                                                                            \
00087                                                                               \
00088 TEMPLATE                                                                      \
00089 tmp<Field<ReturnType> > Func                                                  \
00090 (                                                                             \
00091     const tmp<Field<Type1> >& tf1,                                            \
00092     const tmp<Field<Type2> >& tf2                                             \
00093 );
00094 
00095 
00096 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00097 
00098 #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)               \
00099                                                                               \
00100 TEMPLATE                                                                      \
00101 void Func                                                                     \
00102 (                                                                             \
00103     Field<ReturnType>& f,                                                     \
00104     const Type1& s1,                                                          \
00105     const UList<Type2>& f2                                                    \
00106 );                                                                            \
00107                                                                               \
00108 TEMPLATE                                                                      \
00109 tmp<Field<ReturnType> > Func                                                  \
00110 (                                                                             \
00111     const Type1& s1,                                                          \
00112     const UList<Type2>& f2                                                    \
00113 );                                                                            \
00114                                                                               \
00115 TEMPLATE                                                                      \
00116 tmp<Field<ReturnType> > Func                                                  \
00117 (                                                                             \
00118     const Type1& s1,                                                          \
00119     const tmp<Field<Type2> >& tf2                                             \
00120 );
00121 
00122 
00123 #define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)               \
00124                                                                               \
00125 TEMPLATE                                                                      \
00126 void Func                                                                     \
00127 (                                                                             \
00128     Field<ReturnType>& f,                                                     \
00129     const UList<Type1>& f1,                                                   \
00130     const Type2& s2                                                           \
00131 );                                                                            \
00132                                                                               \
00133 TEMPLATE                                                                      \
00134 tmp<Field<ReturnType> > Func                                                  \
00135 (                                                                             \
00136     const UList<Type1>& f1,                                                   \
00137     const Type2& s2                                                           \
00138 );                                                                            \
00139                                                                               \
00140 TEMPLATE                                                                      \
00141 tmp<Field<ReturnType> > Func                                                  \
00142 (                                                                             \
00143     const tmp<Field<Type1> >& tf1,                                            \
00144     const Type2& s2                                                           \
00145 );
00146 
00147 
00148 #define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)                  \
00149     BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func)                   \
00150     BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
00151 
00152 
00153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00154 
00155 #define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc)                 \
00156                                                                               \
00157 TEMPLATE                                                                      \
00158 void OpFunc                                                                   \
00159 (                                                                             \
00160     Field<ReturnType>& f,                                                     \
00161     const UList<Type1>& f1,                                                   \
00162     const UList<Type2>& f2                                                    \
00163 );                                                                            \
00164                                                                               \
00165 TEMPLATE                                                                      \
00166 tmp<Field<ReturnType> > operator Op                                           \
00167 (                                                                             \
00168     const UList<Type1>& f1,                                                   \
00169     const UList<Type2>& f2                                                    \
00170 );                                                                            \
00171                                                                               \
00172 TEMPLATE                                                                      \
00173 tmp<Field<ReturnType> > operator Op                                           \
00174 (                                                                             \
00175     const UList<Type1>& f1,                                                   \
00176     const tmp<Field<Type2> >& tf2                                             \
00177 );                                                                            \
00178                                                                               \
00179 TEMPLATE                                                                      \
00180 tmp<Field<ReturnType> > operator Op                                           \
00181 (                                                                             \
00182     const tmp<Field<Type1> >& tf1,                                            \
00183     const UList<Type2>& f2                                                    \
00184 );                                                                            \
00185                                                                               \
00186 TEMPLATE                                                                      \
00187 tmp<Field<ReturnType> > operator Op                                           \
00188 (                                                                             \
00189     const tmp<Field<Type1> >& tf1,                                            \
00190     const tmp<Field<Type2> >& tf2                                             \
00191 );
00192 
00193 
00194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00195 
00196 #define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc)         \
00197                                                                               \
00198 TEMPLATE                                                                      \
00199 void OpFunc                                                                   \
00200 (                                                                             \
00201     Field<ReturnType>& f,                                                     \
00202     const Type1& s1,                                                          \
00203     const UList<Type2>& f2                                                    \
00204 );                                                                            \
00205                                                                               \
00206 TEMPLATE                                                                      \
00207 tmp<Field<ReturnType> > operator Op                                           \
00208 (                                                                             \
00209     const Type1& s1,                                                          \
00210     const UList<Type2>& f2                                                    \
00211 );                                                                            \
00212                                                                               \
00213 TEMPLATE                                                                      \
00214 tmp<Field<ReturnType> > operator Op                                           \
00215 (                                                                             \
00216     const Type1& s1,                                                          \
00217     const tmp<Field<Type2> >& tf2                                             \
00218 );
00219 
00220 
00221 #define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)         \
00222                                                                               \
00223 TEMPLATE                                                                      \
00224 void OpFunc                                                                   \
00225 (                                                                             \
00226     Field<ReturnType>& f,                                                     \
00227     const UList<Type1>& f1,                                                   \
00228     const Type2& s2                                                           \
00229 );                                                                            \
00230                                                                               \
00231 TEMPLATE                                                                      \
00232 tmp<Field<ReturnType> > operator Op                                           \
00233 (                                                                             \
00234     const UList<Type1>& f1,                                                   \
00235     const Type2& s2                                                           \
00236 );                                                                            \
00237                                                                               \
00238 TEMPLATE                                                                      \
00239 tmp<Field<ReturnType> > operator Op                                           \
00240 (                                                                             \
00241     const tmp<Field<Type1> >& tf1,                                            \
00242     const Type2& s2                                                           \
00243 );
00244 
00245 
00246 #define BINARY_TYPE_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc)            \
00247     BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpFunc)             \
00248     BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpFunc)
00249 
00250 
00251 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines