initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / FieldFields / scalarFieldField / scalarFieldField.C
blobfe9067a8f57dab085599253b534afb4cf6a7d68d
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 FieldField\<T\> for scalar.
28 \*---------------------------------------------------------------------------*/
30 #include "scalarFieldField.H"
32 #define TEMPLATE template<template<class> class Field>
33 #include "FieldFieldFunctionsM.C"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace Foam
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 template<template<class> class Field>
43 void stabilise
45     FieldField<Field, scalar>& f,
46     const FieldField<Field, scalar>& f1,
47     const scalar s
50     forAll(f, i)
51     {
52         stabilise(f[i], f1[i], s);
53     }
56 template<template<class> class Field>
57 tmp<FieldField<Field, scalar> > stabilise
59     const FieldField<Field, scalar>& f1,
60     const scalar s
63     tmp<FieldField<Field, scalar> > tf
64     (
65         FieldField<Field, scalar>::NewCalculatedType(f1)
66     );
67     stabilise(tf(), f1, s);
68     return tf;
71 template<template<class> class Field>
72 tmp<FieldField<Field, scalar> > stabilise
74     const tmp<FieldField<Field, scalar> >& tf1,
75     const scalar s
78     tmp<FieldField<Field, scalar> > tf(tf1.ptr());
79     stabilise(tf(), tf(), s);
80     return tf;
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, add)
87 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, subtract)
89 BINARY_OPERATOR(scalar, scalar, scalar, *, multiply)
90 BINARY_OPERATOR(scalar, scalar, scalar, /, divide)
92 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, divide)
94 BINARY_FUNCTION(scalar, scalar, scalar, pow)
95 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, pow)
97 BINARY_FUNCTION(scalar, scalar, scalar, atan2)
98 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, atan2)
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 UNARY_FUNCTION(scalar, scalar, pow3)
104 UNARY_FUNCTION(scalar, scalar, pow4)
105 UNARY_FUNCTION(scalar, scalar, pow5)
106 UNARY_FUNCTION(scalar, scalar, pow6)
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 // ************************************************************************* //