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

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