1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 Specialisation of Field\<T\> for scalar.
27 \*---------------------------------------------------------------------------*/
29 #include "scalarField.H"
32 #include "FieldFunctionsM.C"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 tmp<scalarField> scalarField::component(const direction) const
47 void component(scalarField& sf, const UList<scalar>& f, const direction)
53 void scalarField::replace(const direction, const UList<scalar>& sf)
59 void scalarField::replace(const direction, const scalar& s)
65 void stabilise(scalarField& res, const UList<scalar>& sf, const scalar s)
67 TFOR_ALL_F_OP_FUNC_S_F
69 scalar, res, =, ::Foam::stabilise, scalar, s, scalar, sf
73 tmp<scalarField> stabilise(const UList<scalar>& sf, const scalar s)
75 tmp<scalarField> tRes(new scalarField(sf.size()));
76 stabilise(tRes(), sf, s);
80 tmp<scalarField> stabilise(const tmp<scalarField>& tsf, const scalar s)
82 tmp<scalarField> tRes = reuseTmp<scalar, scalar>::New(tsf);
83 stabilise(tRes(), tsf(), s);
84 reuseTmp<scalar, scalar>::clear(tsf);
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, add)
92 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, subtract)
94 BINARY_OPERATOR(scalar, scalar, scalar, *, multiply)
95 BINARY_OPERATOR(scalar, scalar, scalar, /, divide)
97 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, divide)
99 BINARY_FUNCTION(scalar, scalar, scalar, pow)
100 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, pow)
102 BINARY_FUNCTION(scalar, scalar, scalar, atan2)
103 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, atan2)
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 UNARY_FUNCTION(scalar, scalar, pow3)
108 UNARY_FUNCTION(scalar, scalar, pow4)
109 UNARY_FUNCTION(scalar, scalar, pow5)
110 UNARY_FUNCTION(scalar, scalar, pow6)
111 UNARY_FUNCTION(scalar, scalar, pow025)
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 // ************************************************************************* //