1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Specialisation of Field\<T\> for scalar.
28 \*---------------------------------------------------------------------------*/
30 #include "scalarField.H"
33 #include "FieldFunctionsM.C"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 tmp<scalarField> scalarField::component(const direction) const
48 void component(scalarField& sf, const UList<scalar>& f, const direction)
54 void scalarField::replace(const direction, const UList<scalar>& sf)
60 void scalarField::replace(const direction, const scalar& s)
66 void stabilise(scalarField& res, const UList<scalar>& sf, const scalar s)
68 TFOR_ALL_F_OP_FUNC_S_F
70 scalar, res, =, ::Foam::stabilise, scalar, s, scalar, sf
74 tmp<scalarField> stabilise(const UList<scalar>& sf, const scalar s)
76 tmp<scalarField> tRes(new scalarField(sf.size()));
77 stabilise(tRes(), sf, s);
81 tmp<scalarField> stabilise(const tmp<scalarField>& tsf, const scalar s)
83 tmp<scalarField> tRes = reuseTmp<scalar, scalar>::New(tsf);
84 stabilise(tRes(), tsf(), s);
85 reuseTmp<scalar, scalar>::clear(tsf);
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
92 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, add)
93 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, subtract)
95 BINARY_OPERATOR(scalar, scalar, scalar, *, multiply)
96 BINARY_OPERATOR(scalar, scalar, scalar, /, divide)
98 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, divide)
100 BINARY_FUNCTION(scalar, scalar, scalar, pow)
101 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, pow)
103 BINARY_FUNCTION(scalar, scalar, scalar, atan2)
104 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, atan2)
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 UNARY_FUNCTION(scalar, scalar, pow3)
109 UNARY_FUNCTION(scalar, scalar, pow4)
110 UNARY_FUNCTION(scalar, scalar, pow5)
111 UNARY_FUNCTION(scalar, scalar, pow6)
112 UNARY_FUNCTION(scalar, scalar, sqrt)
113 UNARY_FUNCTION(scalar, scalar, sign)
114 UNARY_FUNCTION(scalar, scalar, pos)
115 UNARY_FUNCTION(scalar, scalar, neg)
116 UNARY_FUNCTION(scalar, scalar, exp)
117 UNARY_FUNCTION(scalar, scalar, log)
118 UNARY_FUNCTION(scalar, scalar, log10)
119 UNARY_FUNCTION(scalar, scalar, sin)
120 UNARY_FUNCTION(scalar, scalar, cos)
121 UNARY_FUNCTION(scalar, scalar, tan)
122 UNARY_FUNCTION(scalar, scalar, asin)
123 UNARY_FUNCTION(scalar, scalar, acos)
124 UNARY_FUNCTION(scalar, scalar, atan)
125 UNARY_FUNCTION(scalar, scalar, sinh)
126 UNARY_FUNCTION(scalar, scalar, cosh)
127 UNARY_FUNCTION(scalar, scalar, tanh)
128 UNARY_FUNCTION(scalar, scalar, asinh)
129 UNARY_FUNCTION(scalar, scalar, acosh)
130 UNARY_FUNCTION(scalar, scalar, atanh)
131 UNARY_FUNCTION(scalar, scalar, erf)
132 UNARY_FUNCTION(scalar, scalar, erfc)
133 UNARY_FUNCTION(scalar, scalar, lgamma)
134 UNARY_FUNCTION(scalar, scalar, j0)
135 UNARY_FUNCTION(scalar, scalar, j1)
136 UNARY_FUNCTION(scalar, scalar, y0)
137 UNARY_FUNCTION(scalar, scalar, y1)
140 #define BesselFunc(func) \
141 void func(scalarField& res, const int n, const UList<scalar>& sf) \
143 TFOR_ALL_F_OP_FUNC_S_F(scalar, res, =, ::Foam::func, int, n, scalar, sf) \
146 tmp<scalarField> func(const int n, const UList<scalar>& sf) \
148 tmp<scalarField> tRes(new scalarField(sf.size())); \
149 func(tRes(), n, sf); \
153 tmp<scalarField> func(const int n, const tmp<scalarField>& tsf) \
155 tmp<scalarField> tRes = reuseTmp<scalar, scalar>::New(tsf); \
156 func(tRes(), n, tsf()); \
157 reuseTmp<scalar, scalar>::clear(tsf); \
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 } // End namespace Foam
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 #include "undefFieldFunctionsM.H"
175 // ************************************************************************* //