initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / fields / pointPatchFields / pointPatchField / pointPatchFieldFunctions.H
blob4d6cdaf1c2c02452cfe4fcbbd3a932a211a15f54
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 \*---------------------------------------------------------------------------*/
27 namespace Foam
30 /* * * * * * * * * * * * * * * * Global functions  * * * * * * * * * * * * * */
32 template<class Type>
33 inline void component
35     pointPatchField<typename Field<Type>::cmptType>& sf,
36     const pointPatchField<Type>& f,
37     const direction d
42 template<class Type>
43 inline void T
45     pointPatchField<Type>& f1,
46     const pointPatchField<Type>& f2
51 template<class Type, int r>
52 inline void pow
54     Field<typename powProduct<Type, r>::type>& f,
55     const pointPatchField<Type>& vf
60 template<class Type>
61 inline void sqr
63     Field<typename outerProduct<Type, Type>::type>& f,
64     const pointPatchField<Type>& vf
69 template<class Type>
70 inline void magSqr
72     pointPatchField<scalar>& sf,
73     const pointPatchField<Type>& f
78 template<class Type>
79 inline void mag
81     pointPatchField<scalar>& sf,
82     const pointPatchField<Type>& f
87 template<class Type>
88 inline void cmptAv
90     pointPatchField<typename Field<Type>::cmptType>& cf,
91     const pointPatchField<Type>& f
96 template<class Type>
97 inline void cmptMag
99     pointPatchField<Type>& cf,
100     const pointPatchField<Type>& f
105 #define BINARY_FUNCTION(func)                                                 \
106                                                                               \
107 template<class Type>                                                          \
108 inline void func                                                              \
109 (                                                                             \
110     pointPatchField<Type>& f,                                                 \
111     const pointPatchField<Type>& f1,                                          \
112     const pointPatchField<Type>& f2                                           \
113 )                                                                             \
114 {}                                                                            \
115                                                                               \
116 template<class Type>                                                          \
117 inline void func                                                              \
118 (                                                                             \
119     pointPatchField<Type>& f,                                                 \
120     const pointPatchField<Type>& f1,                                          \
121     const Type& s                                                             \
122 )                                                                             \
125 BINARY_FUNCTION(max)
126 BINARY_FUNCTION(min)
127 BINARY_FUNCTION(cmptMultiply)
128 BINARY_FUNCTION(cmptDivide)
130 #undef BINARY_FUNCTION
133 /* * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * */
135 #define UNARY_OPERATOR(op, opFunc)                                            \
136                                                                               \
137 template<class Type>                                                          \
138 inline void opFunc                                                            \
139 (                                                                             \
140     pointPatchField<Type>& f,                                                 \
141     const pointPatchField<Type>& f1                                           \
142 )                                                                             \
145 UNARY_OPERATOR(-, negate)
147 #undef UNARY_OPERATOR
150 #define BINARY_OPERATOR_FF(Type1, Type2, op, opFunc)                          \
151                                                                               \
152 template<class Type>                                                          \
153 inline void opFunc                                                            \
154 (                                                                             \
155     pointPatchField<Type>& f,                                                 \
156     const pointPatchField<Type1>& f1,                                         \
157     const pointPatchField<Type2>& f2                                          \
158 )                                                                             \
161 #define BINARY_OPERATOR_R(Type1, Type2, op, opFunc)                           \
162     BINARY_OPERATOR_FF(Type1, Type2, op, opFunc)
164 BINARY_OPERATOR_R(Type, Type, +, add)
165 BINARY_OPERATOR_R(Type, Type, -, subtract)
166 BINARY_OPERATOR_FF(scalar, Type, *, multiply)
167 BINARY_OPERATOR_FF(Type, scalar, /, divide)
169 #undef BINARY_OPERATOR_R
170 #undef BINARY_OPERATOR_FF
171 #undef BINARY_OPERATOR_FTR
172 #undef BINARY_OPERATOR_TF
173 #undef BINARY_OPERATOR_TTR
174 #undef BINARY_OPERATOR_FT
175 #undef BINARY_OPERATOR_TRF
176 #undef BINARY_OPERATOR_TRT
179 #define BINARY_TYPE_OPERATOR_TF(TYPE, op, opFunc)                             \
180                                                                               \
181 template<class Type>                                                          \
182 inline void opFunc                                                            \
183 (                                                                             \
184     pointPatchField<Type>& f,                                                 \
185     const TYPE& s,                                                            \
186     const pointPatchField<Type>& f1                                           \
187 )                                                                             \
191 #define BINARY_TYPE_OPERATOR_FT(TYPE, op, opFunc)                             \
192                                                                               \
193 template<class Type>                                                          \
194 inline void opFunc                                                            \
195 (                                                                             \
196     pointPatchField<Type>& f,                                                 \
197     const pointPatchField<Type>& f1,                                          \
198     const TYPE& s                                                             \
199 )                                                                             \
203 #define BINARY_TYPE_OPERATOR(TYPE, op, opFunc)                                \
204     BINARY_TYPE_OPERATOR_TF(TYPE, op, opFunc)                                 \
205     BINARY_TYPE_OPERATOR_FT(TYPE, op, opFunc)
207 BINARY_TYPE_OPERATOR(Type, +, add)
208 BINARY_TYPE_OPERATOR(Type, -, subtract)
210 BINARY_TYPE_OPERATOR(scalar, *, multiply)
211 BINARY_TYPE_OPERATOR_FT(scalar, /, divide)
213 #undef BINARY_TYPE_OPERATOR
214 #undef BINARY_TYPE_OPERATOR_TF
215 #undef BINARY_TYPE_OPERATOR_FT
218 #define PRODUCT_OPERATOR(product, op, opFunc)                                 \
219                                                                               \
220 template                                                                      \
221 <                                                                             \
222     class Type1,                                                              \
223     class Type2                                                               \
224 >                                                                             \
225 inline void opFunc                                                            \
226 (                                                                             \
227     pointPatchField                                                           \
228     <typename product<Type1, Type2>::type>& f,                                \
229     const pointPatchField<Type1>& f1,                                         \
230     const pointPatchField<Type2>& f2                                          \
231 )                                                                             \
232 {}                                                                            \
233                                                                               \
234 template                                                                      \
235 <                                                                             \
236     class Type,                                                               \
237     class Form,                                                               \
238     class Cmpt,                                                               \
239     int nCmpt                                                                 \
240 >                                                                             \
241 inline void opFunc                                                            \
242 (                                                                             \
243     pointPatchField                                                           \
244     <typename product<Type, Form>::type>& f,                                  \
245     const pointPatchField<Type>& f1,                                          \
246     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
247 )                                                                             \
248 {}                                                                            \
249                                                                               \
250 template                                                                      \
251 <                                                                             \
252     class Form,                                                               \
253     class Cmpt,                                                               \
254     int nCmpt,                                                                \
255     class Type                                                                \
256 >                                                                             \
257 inline void opFunc                                                            \
258 (                                                                             \
259     pointPatchField                                                           \
260     <typename product<Form, Type>::type>& f,                                  \
261     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
262     const pointPatchField<Type>& f1                                           \
263 )                                                                             \
266 PRODUCT_OPERATOR(outerProduct, *, outer)
267 PRODUCT_OPERATOR(crossProduct, ^, cross)
268 PRODUCT_OPERATOR(innerProduct, &, dot)
269 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
271 #undef PRODUCT_OPERATOR
274 inline void hdual
276     pointPatchField<vector>&,
277     const pointPatchField<tensor>&
281 inline void hdual
283     pointPatchField<tensor>&,
284     const pointPatchField<vector>&
288 inline void diag
290     pointPatchField<vector>&,
291     const pointPatchField<tensor>&
295 inline void tr
297     pointPatchField<scalar>&,
298     const pointPatchField<tensor>&
302 inline void dev
304     pointPatchField<tensor>&,
305     const pointPatchField<tensor>&
309 inline void dev2
311     pointPatchField<tensor>&,
312     const pointPatchField<tensor>&
316 inline void det
318     pointPatchField<scalar>&,
319     const pointPatchField<tensor>&
323 inline void inv
325     pointPatchField<tensor>&,
326     const pointPatchField<tensor>&
330 inline void symm
332     pointPatchField<tensor>&,
333     const pointPatchField<tensor>&
337 inline void twoSymm
339     pointPatchField<tensor>&,
340     const pointPatchField<tensor>&
344 inline void skew
346     pointPatchField<tensor>&,
347     const pointPatchField<tensor>&
351 inline void eigenValues
353     pointPatchField<vector>&,
354     const pointPatchField<tensor>&
358 inline void eigenVectors
360     pointPatchField<tensor>&,
361     const pointPatchField<tensor>&
366 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
368 } // End namespace Foam
370 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //