Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / OpenFOAM / fields / FieldFields / scalarFieldField / scalarFieldField.C
blob478c768176090f63200adc774f9ad770f2b1a991
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
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 FieldField\<T\> for scalar.
27 \*---------------------------------------------------------------------------*/
29 #include "scalarFieldField.H"
31 #define TEMPLATE template<template<class> class Field>
32 #include "FieldFieldFunctionsM.C"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace Foam
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 template<template<class> class Field>
42 void stabilise
44     FieldField<Field, scalar>& f,
45     const FieldField<Field, scalar>& f1,
46     const scalar s
49     forAll(f, i)
50     {
51         stabilise(f[i], f1[i], s);
52     }
55 template<template<class> class Field>
56 tmp<FieldField<Field, scalar> > stabilise
58     const FieldField<Field, scalar>& f1,
59     const scalar s
62     tmp<FieldField<Field, scalar> > tf
63     (
64         FieldField<Field, scalar>::NewCalculatedType(f1)
65     );
66     stabilise(tf(), f1, s);
67     return tf;
70 template<template<class> class Field>
71 tmp<FieldField<Field, scalar> > stabilise
73     const tmp<FieldField<Field, scalar> >& tf1,
74     const scalar s
77     tmp<FieldField<Field, scalar> > tf(tf1.ptr());
78     stabilise(tf(), tf(), s);
79     return tf;
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, add)
86 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, subtract)
88 BINARY_OPERATOR(scalar, scalar, scalar, *, multiply)
89 BINARY_OPERATOR(scalar, scalar, scalar, /, divide)
91 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, divide)
93 BINARY_FUNCTION(scalar, scalar, scalar, pow)
94 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, pow)
96 BINARY_FUNCTION(scalar, scalar, scalar, atan2)
97 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, atan2)
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 UNARY_FUNCTION(scalar, scalar, pow3)
103 UNARY_FUNCTION(scalar, scalar, pow4)
104 UNARY_FUNCTION(scalar, scalar, pow5)
105 UNARY_FUNCTION(scalar, scalar, pow6)
106 UNARY_FUNCTION(scalar, scalar, pow025)
107 UNARY_FUNCTION(scalar, scalar, sqrt)
108 UNARY_FUNCTION(scalar, scalar, sign)
109 UNARY_FUNCTION(scalar, scalar, pos)
110 UNARY_FUNCTION(scalar, scalar, neg)
111 UNARY_FUNCTION(scalar, scalar, exp)
112 UNARY_FUNCTION(scalar, scalar, log)
113 UNARY_FUNCTION(scalar, scalar, log10)
114 UNARY_FUNCTION(scalar, scalar, sin)
115 UNARY_FUNCTION(scalar, scalar, cos)
116 UNARY_FUNCTION(scalar, scalar, tan)
117 UNARY_FUNCTION(scalar, scalar, asin)
118 UNARY_FUNCTION(scalar, scalar, acos)
119 UNARY_FUNCTION(scalar, scalar, atan)
120 UNARY_FUNCTION(scalar, scalar, sinh)
121 UNARY_FUNCTION(scalar, scalar, cosh)
122 UNARY_FUNCTION(scalar, scalar, tanh)
123 UNARY_FUNCTION(scalar, scalar, asinh)
124 UNARY_FUNCTION(scalar, scalar, acosh)
125 UNARY_FUNCTION(scalar, scalar, atanh)
126 UNARY_FUNCTION(scalar, scalar, erf)
127 UNARY_FUNCTION(scalar, scalar, erfc)
128 UNARY_FUNCTION(scalar, scalar, lgamma)
129 UNARY_FUNCTION(scalar, scalar, j0)
130 UNARY_FUNCTION(scalar, scalar, j1)
131 UNARY_FUNCTION(scalar, scalar, y0)
132 UNARY_FUNCTION(scalar, scalar, y1)
135 #define BesselFunc(func)                                                      \
136                                                                               \
137 template<template<class> class Field>                                         \
138 void func                                                                     \
139 (                                                                             \
140     FieldField<Field, scalar>& res,                                           \
141     const int n,                                                              \
142     const FieldField<Field, scalar>& sf                                       \
143 )                                                                             \
144 {                                                                             \
145     forAll(res, i)                                                            \
146     {                                                                         \
147         func(res[i], n, sf[i]);                                               \
148     }                                                                         \
149 }                                                                             \
150                                                                               \
151 template<template<class> class Field>                                         \
152 tmp<FieldField<Field, scalar> > func                                          \
153 (                                                                             \
154     const int n,                                                              \
155     const FieldField<Field, scalar>& sf                                       \
156 )                                                                             \
157 {                                                                             \
158     tmp<FieldField<Field, scalar> > tRes                                      \
159     (                                                                         \
160         FieldField<Field, scalar>::NewCalculatedType(sf)                      \
161     );                                                                        \
162     func(tRes(), n, sf);                                                      \
163     return tRes;                                                              \
164 }                                                                             \
165                                                                               \
166 template<template<class> class Field>                                         \
167 tmp<FieldField<Field, scalar> > func                                          \
168 (                                                                             \
169     const int n,                                                              \
170     const tmp<FieldField<Field, scalar> >& tsf                                \
171 )                                                                             \
172 {                                                                             \
173     tmp<FieldField<Field, scalar> > tRes                                      \
174     (                                                                         \
175         reuseTmpFieldField<Field, scalar, scalar>::New(tsf)                   \
176     );                                                                        \
177     func(tRes(), n, tsf());                                                   \
178     reuseTmpFieldField<Field, scalar, scalar>::clear(tsf);                    \
179     return tRes;                                                              \
182 BesselFunc(jn)
183 BesselFunc(yn)
185 #undef BesselFunc
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 } // End namespace Foam
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 #include "undefFieldFunctionsM.H"
196 // ************************************************************************* //