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

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