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

scalarFieldField.C

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     Specialisation of FieldField<T> for scalar.
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include <OpenFOAM/scalarFieldField.H>
00030 
00031 #define TEMPLATE template<template<class> class Field>
00032 #include <OpenFOAM/FieldFieldFunctionsM.C>
00033 
00034 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038 
00039 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00040 
00041 template<template<class> class Field>
00042 void stabilise
00043 (
00044     FieldField<Field, scalar>& f,
00045     const FieldField<Field, scalar>& f1,
00046     const scalar s
00047 )
00048 {
00049     forAll(f, i)
00050     {
00051         stabilise(f[i], f1[i], s);
00052     }
00053 }
00054 
00055 template<template<class> class Field>
00056 tmp<FieldField<Field, scalar> > stabilise
00057 (
00058     const FieldField<Field, scalar>& f1,
00059     const scalar s
00060 )
00061 {
00062     tmp<FieldField<Field, scalar> > tf
00063     (
00064         FieldField<Field, scalar>::NewCalculatedType(f1)
00065     );
00066     stabilise(tf(), f1, s);
00067     return tf;
00068 }
00069 
00070 template<template<class> class Field>
00071 tmp<FieldField<Field, scalar> > stabilise
00072 (
00073     const tmp<FieldField<Field, scalar> >& tf1,
00074     const scalar s
00075 )
00076 {
00077     tmp<FieldField<Field, scalar> > tf(tf1.ptr());
00078     stabilise(tf(), tf(), s);
00079     return tf;
00080 }
00081 
00082 
00083 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00084 
00085 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, add)
00086 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, subtract)
00087 
00088 BINARY_OPERATOR(scalar, scalar, scalar, *, multiply)
00089 BINARY_OPERATOR(scalar, scalar, scalar, /, divide)
00090 
00091 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, divide)
00092 
00093 BINARY_FUNCTION(scalar, scalar, scalar, pow)
00094 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, pow)
00095 
00096 BINARY_FUNCTION(scalar, scalar, scalar, atan2)
00097 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, atan2)
00098 
00099 
00100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00101 
00102 UNARY_FUNCTION(scalar, scalar, pow3)
00103 UNARY_FUNCTION(scalar, scalar, pow4)
00104 UNARY_FUNCTION(scalar, scalar, pow5)
00105 UNARY_FUNCTION(scalar, scalar, pow6)
00106 UNARY_FUNCTION(scalar, scalar, sqrt)
00107 UNARY_FUNCTION(scalar, scalar, sign)
00108 UNARY_FUNCTION(scalar, scalar, pos)
00109 UNARY_FUNCTION(scalar, scalar, neg)
00110 UNARY_FUNCTION(scalar, scalar, exp)
00111 UNARY_FUNCTION(scalar, scalar, log)
00112 UNARY_FUNCTION(scalar, scalar, log10)
00113 UNARY_FUNCTION(scalar, scalar, sin)
00114 UNARY_FUNCTION(scalar, scalar, cos)
00115 UNARY_FUNCTION(scalar, scalar, tan)
00116 UNARY_FUNCTION(scalar, scalar, asin)
00117 UNARY_FUNCTION(scalar, scalar, acos)
00118 UNARY_FUNCTION(scalar, scalar, atan)
00119 UNARY_FUNCTION(scalar, scalar, sinh)
00120 UNARY_FUNCTION(scalar, scalar, cosh)
00121 UNARY_FUNCTION(scalar, scalar, tanh)
00122 UNARY_FUNCTION(scalar, scalar, asinh)
00123 UNARY_FUNCTION(scalar, scalar, acosh)
00124 UNARY_FUNCTION(scalar, scalar, atanh)
00125 UNARY_FUNCTION(scalar, scalar, erf)
00126 UNARY_FUNCTION(scalar, scalar, erfc)
00127 UNARY_FUNCTION(scalar, scalar, lgamma)
00128 UNARY_FUNCTION(scalar, scalar, j0)
00129 UNARY_FUNCTION(scalar, scalar, j1)
00130 UNARY_FUNCTION(scalar, scalar, y0)
00131 UNARY_FUNCTION(scalar, scalar, y1)
00132 
00133 
00134 #define BesselFunc(func)                                                      \
00135                                                                               \
00136 template<template<class> class Field>                                         \
00137 void func                                                                     \
00138 (                                                                             \
00139     FieldField<Field, scalar>& res,                                           \
00140     const int n,                                                              \
00141     const FieldField<Field, scalar>& sf                                       \
00142 )                                                                             \
00143 {                                                                             \
00144     forAll(res, i)                                                            \
00145     {                                                                         \
00146         func(res[i], n, sf[i]);                                               \
00147     }                                                                         \
00148 }                                                                             \
00149                                                                               \
00150 template<template<class> class Field>                                         \
00151 tmp<FieldField<Field, scalar> > func                                          \
00152 (                                                                             \
00153     const int n,                                                              \
00154     const FieldField<Field, scalar>& sf                                       \
00155 )                                                                             \
00156 {                                                                             \
00157     tmp<FieldField<Field, scalar> > tRes                                      \
00158     (                                                                         \
00159         FieldField<Field, scalar>::NewCalculatedType(sf)                      \
00160     );                                                                        \
00161     func(tRes(), n, sf);                                                      \
00162     return tRes;                                                              \
00163 }                                                                             \
00164                                                                               \
00165 template<template<class> class Field>                                         \
00166 tmp<FieldField<Field, scalar> > func                                          \
00167 (                                                                             \
00168     const int n,                                                              \
00169     const tmp<FieldField<Field, scalar> >& tsf                                \
00170 )                                                                             \
00171 {                                                                             \
00172     tmp<FieldField<Field, scalar> > tRes                                      \
00173     (                                                                         \
00174         reuseTmpFieldField<Field, scalar, scalar>::New(tsf)                   \
00175     );                                                                        \
00176     func(tRes(), n, tsf());                                                   \
00177     reuseTmpFieldField<Field, scalar, scalar>::clear(tsf);                    \
00178     return tRes;                                                              \
00179 }
00180 
00181 BesselFunc(jn)
00182 BesselFunc(yn)
00183 
00184 #undef BesselFunc
00185 
00186 
00187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00188 
00189 } // End namespace Foam
00190 
00191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00192 
00193 #include <OpenFOAM/undefFieldFunctionsM.H>
00194 
00195 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines