ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / OpenFOAM / fields / Fields / Field / FieldFunctions.H
blobe3fd66afaf4baf65733ac23a07a80d9a93d1b625
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 \*---------------------------------------------------------------------------*/
26 #include "scalarField.H"
28 #define TEMPLATE template<class Type>
29 #include "FieldFunctionsM.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
38 template<class Type>
39 void component
41     Field<typename Field<Type>::cmptType>& res,
42     const UList<Type>& f,
43     const direction d
47 template<class Type>
48 void T(Field<Type>& res, const UList<Type>& f);
51 template<class Type, int r>
52 void pow
54     Field<typename powProduct<Type, r>::type>& res,
55     const UList<Type>& vf
59 template<class Type, int r>
60 tmp<Field<typename powProduct<Type, r>::type> >
61 pow
63     const UList<Type>& f,
64     typename powProduct<Type, r>::type
65       = pTraits<typename powProduct<Type, r>::type>::zero
68 template<class Type, int r>
69 tmp<Field<typename powProduct<Type, r>::type> >
70 pow
72     const tmp<Field<Type> >& tf,
73     typename powProduct<Type, r>::type
74       = pTraits<typename powProduct<Type, r>::type>::zero
78 template<class Type>
79 void sqr
81     Field<typename outerProduct<Type, Type>::type>& res,
82     const UList<Type>& vf
85 template<class Type>
86 tmp<Field<typename outerProduct<Type, Type>::type> >
87 sqr(const UList<Type>& f);
89 template<class Type>
90 tmp<Field<typename outerProduct<Type, Type>::type> >
91 sqr(const tmp<Field<Type> >& tf);
94 template<class Type>
95 void magSqr(Field<scalar>& res, const UList<Type>& f);
97 template<class Type>
98 tmp<Field<scalar> > magSqr(const UList<Type>& f);
100 template<class Type>
101 tmp<Field<scalar> > magSqr(const tmp<Field<Type> >& tf);
104 template<class Type>
105 void mag(Field<scalar>& res, const UList<Type>& f);
107 template<class Type>
108 tmp<Field<scalar> > mag(const UList<Type>& f);
110 template<class Type>
111 tmp<Field<scalar> > mag(const tmp<Field<Type> >& tf);
114 template<class Type>
115 void cmptMax(Field<typename Field<Type>::cmptType>& res, const UList<Type>& f);
117 template<class Type>
118 tmp<Field<typename Field<Type>::cmptType> > cmptMax(const UList<Type>& f);
120 template<class Type>
121 tmp<Field<typename Field<Type>::cmptType> >
122 cmptMax(const tmp<Field<Type> >& tf);
125 template<class Type>
126 void cmptMin(Field<typename Field<Type>::cmptType>& res, const UList<Type>& f);
128 template<class Type>
129 tmp<Field<typename Field<Type>::cmptType> > cmptMin(const UList<Type>& f);
131 template<class Type>
132 tmp<Field<typename Field<Type>::cmptType> >
133 cmptMin(const tmp<Field<Type> >& tf);
136 template<class Type>
137 void cmptAv(Field<typename Field<Type>::cmptType>& res, const UList<Type>& f);
139 template<class Type>
140 tmp<Field<typename Field<Type>::cmptType> > cmptAv(const UList<Type>& f);
142 template<class Type>
143 tmp<Field<typename Field<Type>::cmptType> > cmptAv(const tmp<Field<Type> >& tf);
146 template<class Type>
147 void cmptMag(Field<Type>& res, const UList<Type>& f);
149 template<class Type>
150 tmp<Field<Type> > cmptMag(const UList<Type>& f);
152 template<class Type>
153 tmp<Field<Type> > cmptMag(const tmp<Field<Type> >& tf);
155 #define TMP_UNARY_FUNCTION(ReturnType, Func)                                  \
156                                                                               \
157 template<class Type>                                                          \
158 ReturnType Func(const tmp<Field<Type> >& tf1);
160 template<class Type>
161 Type max(const UList<Type>& f);
163 TMP_UNARY_FUNCTION(Type, max)
165 template<class Type>
166 Type min(const UList<Type>& f);
168 TMP_UNARY_FUNCTION(Type, min)
170 template<class Type>
171 Type sum(const UList<Type>& f);
173 TMP_UNARY_FUNCTION(Type, sum)
176 template<class Type>
177 scalar sumProd(const UList<Type>& f1, const UList<Type>& f2);
179 template<class Type>
180 Type sumCmptProd(const UList<Type>& f1, const UList<Type>& f2);
182 template<class Type>
183 scalar sumSqr(const UList<Type>& f);
185 TMP_UNARY_FUNCTION(scalar, sumSqr)
187 template<class Type>
188 scalar sumMag(const UList<Type>& f);
190 TMP_UNARY_FUNCTION(scalar, sumMag)
192 template<class Type>
193 Type sumCmptMag(const UList<Type>& f);
195 TMP_UNARY_FUNCTION(Type, sumCmptMag)
197 template<class Type>
198 Type average(const UList<Type>& f);
200 TMP_UNARY_FUNCTION(Type, average)
203 #define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc)                      \
204                                                                               \
205 template<class Type>                                                          \
206 ReturnType gFunc(const UList<Type>& f);                                       \
207 TMP_UNARY_FUNCTION(ReturnType, gFunc)
209 G_UNARY_FUNCTION(Type, gMax, max, max)
210 G_UNARY_FUNCTION(Type, gMin, min, min)
211 G_UNARY_FUNCTION(Type, gSum, sum, sum)
212 G_UNARY_FUNCTION(scalar, gSumSqr, sumSqr, sum)
213 G_UNARY_FUNCTION(scalar, gSumMag, sumMag, sum)
214 G_UNARY_FUNCTION(Type, gSumCmptMag, sumCmptMag, sum)
216 #undef G_UNARY_FUNCTION
218 template<class Type>
219 scalar gSumProd(const UList<Type>& f1, const UList<Type>& f2);
221 template<class Type>
222 Type gSumCmptProd(const UList<Type>& f1, const UList<Type>& f2);
224 template<class Type>
225 Type gAverage(const UList<Type>& f);
227 TMP_UNARY_FUNCTION(Type, gAverage)
229 #undef TMP_UNARY_FUNCTION
232 BINARY_FUNCTION(Type, Type, Type, max)
233 BINARY_FUNCTION(Type, Type, Type, min)
234 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
235 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
237 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
238 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
239 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
240 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
243 // * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * //
245 UNARY_OPERATOR(Type, Type, -, negate)
247 BINARY_OPERATOR(Type, Type, scalar, *, multiply)
248 BINARY_OPERATOR(Type, scalar, Type, *, multiply)
249 BINARY_OPERATOR(Type, Type, scalar, /, divide)
251 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, multiply)
252 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, multiply)
254 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide)
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 #define PRODUCT_OPERATOR(product, Op, OpFunc)                                 \
260                                                                               \
261 template<class Type1, class Type2>                                            \
262 void OpFunc                                                                   \
263 (                                                                             \
264     Field<typename product<Type1, Type2>::type>& res,                         \
265     const UList<Type1>& f1,                                                   \
266     const UList<Type2>& f2                                                    \
267 );                                                                            \
268                                                                               \
269 template<class Type1, class Type2>                                            \
270 tmp<Field<typename product<Type1, Type2>::type> >                             \
271 operator Op(const UList<Type1>& f1, const UList<Type2>& f2);                  \
272                                                                               \
273 template<class Type1, class Type2>                                            \
274 tmp<Field<typename product<Type1, Type2>::type> >                             \
275 operator Op(const UList<Type1>& f1, const tmp<Field<Type2> >& tf2);           \
276                                                                               \
277 template<class Type1, class Type2>                                            \
278 tmp<Field<typename product<Type1, Type2>::type> >                             \
279 operator Op(const tmp<Field<Type1> >& tf1, const UList<Type2>& f2);           \
280                                                                               \
281 template<class Type1, class Type2>                                            \
282 tmp<Field<typename product<Type1, Type2>::type> >                             \
283 operator Op(const tmp<Field<Type1> >& tf1, const tmp<Field<Type2> >& tf2);    \
284                                                                               \
285 template<class Type, class Form, class Cmpt, int nCmpt>                       \
286 void OpFunc                                                                   \
287 (                                                                             \
288     Field<typename product<Type, Form>::type>& res,                           \
289     const UList<Type>& f1,                                                    \
290     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
291 );                                                                            \
292                                                                               \
293 template<class Type, class Form, class Cmpt, int nCmpt>                       \
294 tmp<Field<typename product<Type, Form>::type> >                               \
295 operator Op(const UList<Type>& f1, const VectorSpace<Form,Cmpt,nCmpt>& vs);   \
296                                                                               \
297 template<class Type, class Form, class Cmpt, int nCmpt>                       \
298 tmp<Field<typename product<Type, Form>::type> >                               \
299 operator Op(const tmp<Field<Type> >&tf1,const VectorSpace<Form,Cmpt,nCmpt>&vs);\
300                                                                               \
301 template<class Form, class Cmpt, int nCmpt, class Type>                       \
302 void OpFunc                                                                   \
303 (                                                                             \
304     Field<typename product<Form, Type>::type>& res,                           \
305     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
306     const UList<Type>& f1                                                     \
307 );                                                                            \
308                                                                               \
309 template<class Form, class Cmpt, int nCmpt, class Type>                       \
310 tmp<Field<typename product<Form, Type>::type> >                               \
311 operator Op(const VectorSpace<Form,Cmpt,nCmpt>& vs, const UList<Type>& f1);   \
312                                                                               \
313 template<class Form, class Cmpt, int nCmpt, class Type>                       \
314 tmp<Field<typename product<Form, Type>::type> >                               \
315 operator Op(const VectorSpace<Form,Cmpt,nCmpt>&vs,const tmp<Field<Type> >&tf1);
317 PRODUCT_OPERATOR(typeOfSum, +, add)
318 PRODUCT_OPERATOR(typeOfSum, -, subtract)
320 PRODUCT_OPERATOR(outerProduct, *, outer)
321 PRODUCT_OPERATOR(crossProduct, ^, cross)
322 PRODUCT_OPERATOR(innerProduct, &, dot)
323 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
325 #undef PRODUCT_OPERATOR
328 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 } // End namespace Foam
332 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334 #include "undefFieldFunctionsM.H"
336 // ************************************************************************* //