BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / OpenFOAM / fields / Fields / scalarField / scalarField.C
blob9000bb533a5df8938c5389a29be0f6b9e2a339b2
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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
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
19     for more details.
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/>.
24 Description
25     Specialisation of Field\<T\> for scalar.
27 \*---------------------------------------------------------------------------*/
29 #include "scalarField.H"
31 #define TEMPLATE
32 #include "FieldFunctionsM.C"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace Foam
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 template<>
42 tmp<scalarField> scalarField::component(const direction) const
44     return *this;
47 void component(scalarField& sf, const UList<scalar>& f, const direction)
49     sf = f;
52 template<>
53 void scalarField::replace(const direction, const UList<scalar>& sf)
55     *this = sf;
58 template<>
59 void scalarField::replace(const direction, const scalar& s)
61     *this = s;
65 void stabilise(scalarField& res, const UList<scalar>& sf, const scalar s)
67     TFOR_ALL_F_OP_FUNC_S_F
68     (
69         scalar, res, =, ::Foam::stabilise, scalar, s, scalar, sf
70     )
73 tmp<scalarField> stabilise(const UList<scalar>& sf, const scalar s)
75     tmp<scalarField> tRes(new scalarField(sf.size()));
76     stabilise(tRes(), sf, s);
77     return tRes;
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);
85     return tRes;
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)             \
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 // ************************************************************************* //