FreeFOAM The Cross-Platform CFD Toolkit
scalarFieldField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Description
25  Specialisation of FieldField<T> for scalar.
26 
27 \*---------------------------------------------------------------------------*/
28 
30 
31 #define TEMPLATE template<template<class> class Field>
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 template<template<class> class Field>
42 void stabilise
43 (
45  const FieldField<Field, scalar>& f1,
46  const scalar s
47 )
48 {
49  forAll(f, i)
50  {
51  stabilise(f[i], f1[i], s);
52  }
53 }
54 
55 template<template<class> class Field>
56 tmp<FieldField<Field, scalar> > stabilise
57 (
58  const FieldField<Field, scalar>& f1,
59  const scalar s
60 )
61 {
63  (
65  );
66  stabilise(tf(), f1, s);
67  return tf;
68 }
69 
70 template<template<class> class Field>
71 tmp<FieldField<Field, scalar> > stabilise
72 (
73  const tmp<FieldField<Field, scalar> >& tf1,
74  const scalar s
75 )
76 {
77  tmp<FieldField<Field, scalar> > tf(tf1.ptr());
78  stabilise(tf(), tf(), s);
79  return tf;
80 }
81 
82 
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
84 
85 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, add)
86 BINARY_TYPE_OPERATOR(scalar, scalar, scalar, -, subtract)
87 
88 BINARY_OPERATOR(scalar, scalar, scalar, *, multiply)
89 BINARY_OPERATOR(scalar, scalar, scalar, /, divide)
90 
91 BINARY_TYPE_OPERATOR_SF(scalar, scalar, scalar, /, divide)
92 
93 BINARY_FUNCTION(scalar, scalar, scalar, pow)
94 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, pow)
95 
96 BINARY_FUNCTION(scalar, scalar, scalar, atan2)
97 BINARY_TYPE_FUNCTION(scalar, scalar, scalar, atan2)
98 
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
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, sqrt)
107 UNARY_FUNCTION(scalar, scalar, sign)
108 UNARY_FUNCTION(scalar, scalar, pos)
109 UNARY_FUNCTION(scalar, scalar, neg)
110 UNARY_FUNCTION(scalar, scalar, exp)
111 UNARY_FUNCTION(scalar, scalar, log)
112 UNARY_FUNCTION(scalar, scalar, log10)
113 UNARY_FUNCTION(scalar, scalar, sin)
114 UNARY_FUNCTION(scalar, scalar, cos)
115 UNARY_FUNCTION(scalar, scalar, tan)
116 UNARY_FUNCTION(scalar, scalar, asin)
117 UNARY_FUNCTION(scalar, scalar, acos)
118 UNARY_FUNCTION(scalar, scalar, atan)
119 UNARY_FUNCTION(scalar, scalar, sinh)
120 UNARY_FUNCTION(scalar, scalar, cosh)
121 UNARY_FUNCTION(scalar, scalar, tanh)
122 UNARY_FUNCTION(scalar, scalar, asinh)
123 UNARY_FUNCTION(scalar, scalar, acosh)
124 UNARY_FUNCTION(scalar, scalar, atanh)
125 UNARY_FUNCTION(scalar, scalar, erf)
126 UNARY_FUNCTION(scalar, scalar, erfc)
127 UNARY_FUNCTION(scalar, scalar, lgamma)
128 UNARY_FUNCTION(scalar, scalar, j0)
129 UNARY_FUNCTION(scalar, scalar, j1)
130 UNARY_FUNCTION(scalar, scalar, y0)
131 UNARY_FUNCTION(scalar, scalar, y1)
132 
133 
134 #define BesselFunc(func) \
135  \
136 template<template<class> class Field> \
137 void func \
138 ( \
139  FieldField<Field, scalar>& res, \
140  const int n, \
141  const FieldField<Field, scalar>& sf \
142 ) \
143 { \
144  forAll(res, i) \
145  { \
146  func(res[i], n, sf[i]); \
147  } \
148 } \
149  \
150 template<template<class> class Field> \
151 tmp<FieldField<Field, scalar> > func \
152 ( \
153  const int n, \
154  const FieldField<Field, scalar>& sf \
155 ) \
156 { \
157  tmp<FieldField<Field, scalar> > tRes \
158  ( \
159  FieldField<Field, scalar>::NewCalculatedType(sf) \
160  ); \
161  func(tRes(), n, sf); \
162  return tRes; \
163 } \
164  \
165 template<template<class> class Field> \
166 tmp<FieldField<Field, scalar> > func \
167 ( \
168  const int n, \
169  const tmp<FieldField<Field, scalar> >& tsf \
170 ) \
171 { \
172  tmp<FieldField<Field, scalar> > tRes \
173  ( \
174  reuseTmpFieldField<Field, scalar, scalar>::New(tsf) \
175  ); \
176  func(tRes(), n, tsf()); \
177  reuseTmpFieldField<Field, scalar, scalar>::clear(tsf); \
178  return tRes; \
179 }
180 
183 
184 #undef BesselFunc
185 
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 } // End namespace Foam
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
194 
195 // ************************ vim: set sw=4 sts=4 et: ************************ //