initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / Fields / scalarField / scalarField.C
blob4f2eccfa9ceea08bab64a6720d31c2161cf1dd6d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Description
26     Specialisation of Field\<T\> for scalar.
28 \*---------------------------------------------------------------------------*/
30 #include "scalarField.H"
32 #define TEMPLATE
33 #include "FieldFunctionsM.C"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace Foam
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 template<>
43 tmp<scalarField> scalarField::component(const direction) const
45     return *this;
48 void component(scalarField& sf, const UList<scalar>& f, const direction)
50     sf = f;
53 template<>
54 void scalarField::replace(const direction, const UList<scalar>& sf)
56     *this = sf;
59 template<>
60 void scalarField::replace(const direction, const scalar& s)
62     *this = s;
66 void stabilise(scalarField& res, const UList<scalar>& sf, const scalar s)
68     TFOR_ALL_F_OP_FUNC_S_F
69     (
70         scalar, res, =, ::Foam::stabilise, scalar, s, scalar, sf
71     )
74 tmp<scalarField> stabilise(const UList<scalar>& sf, const scalar s)
76     tmp<scalarField> tRes(new scalarField(sf.size()));
77     stabilise(tRes(), sf, s);
78     return tRes;
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);
86     return tRes;
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)             \
142 {                                                                             \
143     TFOR_ALL_F_OP_FUNC_S_F(scalar, res, =, ::Foam::func, int, n, scalar, sf)  \
144 }                                                                             \
145                                                                               \
146 tmp<scalarField> func(const int n, const UList<scalar>& sf)                   \
147 {                                                                             \
148     tmp<scalarField> tRes(new scalarField(sf.size()));                        \
149     func(tRes(), n, sf);                                                      \
150     return tRes;                                                              \
151 }                                                                             \
152                                                                               \
153 tmp<scalarField> func(const int n, const tmp<scalarField>& tsf)               \
154 {                                                                             \
155     tmp<scalarField> tRes = reuseTmp<scalar, scalar>::New(tsf);               \
156     func(tRes(), n, tsf());                                                   \
157     reuseTmp<scalar, scalar>::clear(tsf);                                     \
158     return tRes;                                                              \
161 BesselFunc(jn)
162 BesselFunc(yn)
164 #undef BesselFunc
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 } // End namespace Foam
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 #include "undefFieldFunctionsM.H"
175 // ************************************************************************* //