BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / OpenFOAM / fields / GeometricFields / GeometricField / GeometricFieldFunctions.H
blobc8e0a8e48e9aef24cebb762f009feb27040426d0
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 "GeometricScalarField.H"
28 #define TEMPLATE \
29     template<class Type, template<class> class PatchField, class GeoMesh>
30 #include "GeometricFieldFunctionsM.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 namespace Foam
37 // * * * * * * * * * * * * * * * Global functions  * * * * * * * * * * * * * //
39 template<class Type, template<class> class PatchField, class GeoMesh>
40 void component
42     GeometricField
43     <
44         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
45         PatchField,
46         GeoMesh
47     >& gcf,
48     const GeometricField<Type, PatchField, GeoMesh>& gf,
49     const direction d
52 template<class Type, template<class> class PatchField, class GeoMesh>
53 void T
55      GeometricField<Type, PatchField, GeoMesh>& gf,
56      const GeometricField<Type, PatchField, GeoMesh>& gf1
59 template<class Type, template<class> class PatchField, class GeoMesh, int r>
60 void pow
62     GeometricField<typename powProduct<Type, r>::type, PatchField, GeoMesh>& gf,
63     const GeometricField<Type, PatchField, GeoMesh>& gf1
66 template<class Type, template<class> class PatchField, class GeoMesh, int r>
67 tmp
69     GeometricField
70     <typename powProduct<Type, r>::type, PatchField, GeoMesh>
72 pow
74     const GeometricField<Type, PatchField, GeoMesh>& gf,
75     typename powProduct<Type, r>::type
78 template<class Type, template<class> class PatchField, class GeoMesh, int r>
79 tmp
81     GeometricField
82     <typename powProduct<Type, r>::type, PatchField, GeoMesh>
84 pow
86     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf,
87     typename powProduct<Type, r>::type
90 template<class Type, template<class> class PatchField, class GeoMesh>
91 void sqr
93     GeometricField
94     <typename outerProduct<Type, Type>::type, PatchField, GeoMesh>& gf,
95     const GeometricField<Type, PatchField, GeoMesh>& gf1
98 template<class Type, template<class> class PatchField, class GeoMesh>
99 tmp
101     GeometricField
102     <
103         typename outerProduct<Type, Type>::type,
104         PatchField,
105         GeoMesh
106     >
108 sqr(const GeometricField<Type, PatchField, GeoMesh>& gf);
110 template<class Type, template<class> class PatchField, class GeoMesh>
113     GeometricField
114     <
115         typename outerProduct<Type, Type>::type,
116         PatchField,
117         GeoMesh
118     >
120 sqr(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf);
122 template<class Type, template<class> class PatchField, class GeoMesh>
123 void magSqr
125     GeometricField<scalar, PatchField, GeoMesh>& gsf,
126     const GeometricField<Type, PatchField, GeoMesh>& gf
129 template<class Type, template<class> class PatchField, class GeoMesh>
130 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
132     const GeometricField<Type, PatchField, GeoMesh>& gf
135 template<class Type, template<class> class PatchField, class GeoMesh>
136 tmp<GeometricField<scalar, PatchField, GeoMesh> > magSqr
138     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
141 template<class Type, template<class> class PatchField, class GeoMesh>
142 void mag
144     GeometricField<scalar, PatchField, GeoMesh>& gsf,
145     const GeometricField<Type, PatchField, GeoMesh>& gf
148 template<class Type, template<class> class PatchField, class GeoMesh>
149 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
151     const GeometricField<Type, PatchField, GeoMesh>& gf
154 template<class Type, template<class> class PatchField, class GeoMesh>
155 tmp<GeometricField<scalar, PatchField, GeoMesh> > mag
157     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf
160 template<class Type, template<class> class PatchField, class GeoMesh>
161 void cmptAv
163     GeometricField
164     <
165         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
166         PatchField,
167         GeoMesh
168     >& gcf,
169     const GeometricField<Type, PatchField, GeoMesh>& gf
172 template<class Type, template<class> class PatchField, class GeoMesh>
175     GeometricField
176     <
177         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
178         PatchField,
179         GeoMesh
180     >
182 cmptAv(const GeometricField<Type, PatchField, GeoMesh>& gf);
184 template<class Type, template<class> class PatchField, class GeoMesh>
187     GeometricField
188     <
189         typename GeometricField<Type, PatchField, GeoMesh>::cmptType,
190         PatchField,
191         GeoMesh
192     >
194 cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf);
197 #define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc)       \
198                                                                               \
199 template<class Type, template<class> class PatchField, class GeoMesh>         \
200 dimensioned<returnType> func                                                  \
201 (                                                                             \
202     const GeometricField<Type, PatchField, GeoMesh>& gf                       \
203 );                                                                            \
204                                                                               \
205 template<class Type, template<class> class PatchField, class GeoMesh>         \
206 dimensioned<returnType> func                                                  \
207 (                                                                             \
208     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
211 UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, max, gMax)
212 UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, min, gMin)
214 #undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
217 #define UNARY_REDUCTION_FUNCTION(returnType, func, gFunc)                     \
218                                                                               \
219 template<class Type, template<class> class PatchField, class GeoMesh>         \
220 dimensioned<returnType> func                                                  \
221 (                                                                             \
222     const GeometricField<Type, PatchField, GeoMesh>& gf                       \
223 );                                                                            \
224                                                                               \
225 template<class Type, template<class> class PatchField, class GeoMesh>         \
226 dimensioned<returnType> func                                                  \
227 (                                                                             \
228     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
231 UNARY_REDUCTION_FUNCTION(Type, sum, gSum)
232 UNARY_REDUCTION_FUNCTION(scalar, sumMag, gSumMag)
233 UNARY_REDUCTION_FUNCTION(Type, average, gAverage)
235 #undef UNARY_REDUCTION_FUNCTION
238 BINARY_FUNCTION(Type, Type, Type, max)
239 BINARY_FUNCTION(Type, Type, Type, min)
240 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
241 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
243 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
244 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
245 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
246 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
249 // * * * * * * * * * * * * * * * Global operators  * * * * * * * * * * * * * //
251 UNARY_OPERATOR(Type, Type, -, negate, transform)
253 #ifndef __INTEL_COMPILER
254 BINARY_OPERATOR(Type, Type, scalar, *, '*', multiply)
255 BINARY_OPERATOR(Type, scalar, Type, *, '*', multiply)
256 #endif
257 BINARY_OPERATOR(Type, Type, scalar, /, '|', divide)
259 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, '*', multiply)
260 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, '*', multiply)
262 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, '|', divide)
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 #define PRODUCT_OPERATOR(product, op, opFunc)                                 \
268                                                                               \
269 template                                                                      \
270 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
271 void opFunc                                                                   \
272 (                                                                             \
273     GeometricField                                                            \
274     <typename product<Type1, Type2>::type, PatchField, GeoMesh>& gf,          \
275     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
276     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
277 );                                                                            \
278                                                                               \
279 template                                                                      \
280 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
281 tmp                                                                           \
282 <                                                                             \
283     GeometricField                                                            \
284         <typename product<Type1, Type2>::type, PatchField, GeoMesh>           \
285 >                                                                             \
286 operator op                                                                   \
287 (                                                                             \
288     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
289     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
290 );                                                                            \
291                                                                               \
292 template                                                                      \
293 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
294 tmp                                                                           \
295 <                                                                             \
296     GeometricField                                                            \
297     <typename product<Type1, Type2>::type, PatchField, GeoMesh>               \
298 >                                                                             \
299 operator op                                                                   \
300 (                                                                             \
301     const GeometricField<Type1, PatchField, GeoMesh>& gf1,                    \
302     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
303 );                                                                            \
304                                                                               \
305 template                                                                      \
306 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
307 tmp                                                                           \
308 <                                                                             \
309     GeometricField                                                            \
310     <typename product<Type1, Type2>::type, PatchField, GeoMesh>               \
311 >                                                                             \
312 operator op                                                                   \
313 (                                                                             \
314     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
315     const GeometricField<Type2, PatchField, GeoMesh>& gf2                     \
316 );                                                                            \
317                                                                               \
318 template                                                                      \
319 <class Type1, class Type2, template<class> class PatchField, class GeoMesh>   \
320 tmp                                                                           \
321 <                                                                             \
322     GeometricField                                                            \
323     <typename product<Type1, Type2>::type, PatchField, GeoMesh>               \
324 >                                                                             \
325 operator op                                                                   \
326 (                                                                             \
327     const tmp<GeometricField<Type1, PatchField, GeoMesh> >& tgf1,             \
328     const tmp<GeometricField<Type2, PatchField, GeoMesh> >& tgf2              \
329 );                                                                            \
330                                                                               \
331 template                                                                      \
332 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
333 void opFunc                                                                   \
334 (                                                                             \
335     GeometricField                                                            \
336     <typename product<Type, Form>::type, PatchField, GeoMesh>& gf,            \
337     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
338     const dimensioned<Form>& dvs                                              \
339 );                                                                            \
340                                                                               \
341 template                                                                      \
342 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
343 tmp                                                                           \
344 <                                                                             \
345     GeometricField                                                            \
346     <typename product<Type, Form>::type, PatchField, GeoMesh>                 \
347 >                                                                             \
348 operator op                                                                   \
349 (                                                                             \
350     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
351     const dimensioned<Form>& dvs                                              \
352 );                                                                            \
353                                                                               \
354 template                                                                      \
355 <                                                                             \
356     class Form,                                                               \
357     class Cmpt,                                                               \
358     int nCmpt,                                                                \
359     class Type, template<class> class PatchField,                             \
360     class GeoMesh                                                             \
361 >                                                                             \
362 tmp                                                                           \
363 <                                                                             \
364     GeometricField                                                            \
365     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
366 >                                                                             \
367 operator op                                                                   \
368 (                                                                             \
369     const GeometricField<Type, PatchField, GeoMesh>& gf1,                     \
370     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
371 );                                                                            \
372                                                                               \
373 template                                                                      \
374 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
375 tmp                                                                           \
376 <                                                                             \
377     GeometricField                                                            \
378     <typename product<Type, Form>::type, PatchField, GeoMesh>                 \
379 >                                                                             \
380 operator op                                                                   \
381 (                                                                             \
382     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1,              \
383     const dimensioned<Form>& dvs                                              \
384 );                                                                            \
385                                                                               \
386 template                                                                      \
387 <                                                                             \
388     class Form,                                                               \
389     class Cmpt,                                                               \
390     int nCmpt,                                                                \
391     class Type, template<class> class PatchField,                             \
392     class GeoMesh                                                             \
393 >                                                                             \
394 tmp                                                                           \
395 <                                                                             \
396     GeometricField                                                            \
397     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
398 >                                                                             \
399 operator op                                                                   \
400 (                                                                             \
401     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1,              \
402     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
403 );                                                                            \
404                                                                               \
405 template                                                                      \
406 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
407 void opFunc                                                                   \
408 (                                                                             \
409     GeometricField                                                            \
410     <typename product<Form, Type>::type, PatchField, GeoMesh>& gf,            \
411     const dimensioned<Form>& dvs,                                             \
412     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
413 );                                                                            \
414                                                                               \
415 template                                                                      \
416 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
417 tmp                                                                           \
418 <                                                                             \
419     GeometricField                                                            \
420     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
421 >                                                                             \
422 operator op                                                                   \
423 (                                                                             \
424     const dimensioned<Form>& dvs,                                             \
425     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
426 );                                                                            \
427                                                                               \
428 template                                                                      \
429 <                                                                             \
430     class Form,                                                               \
431     class Cmpt,                                                               \
432     int nCmpt,                                                                \
433     class Type, template<class> class PatchField,                             \
434     class GeoMesh                                                             \
435 >                                                                             \
436 tmp                                                                           \
437 <                                                                             \
438     GeometricField                                                            \
439     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
440 >                                                                             \
441 operator op                                                                   \
442 (                                                                             \
443     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
444     const GeometricField<Type, PatchField, GeoMesh>& gf1                      \
445 );                                                                            \
446                                                                               \
447 template                                                                      \
448 <class Form, class Type, template<class> class PatchField, class GeoMesh>     \
449 tmp                                                                           \
450 <                                                                             \
451     GeometricField                                                            \
452     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
453 >                                                                             \
454 operator op                                                                   \
455 (                                                                             \
456     const dimensioned<Form>& dvs,                                             \
457     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
458 );                                                                            \
459                                                                               \
460 template                                                                      \
461 <                                                                             \
462     class Form,                                                               \
463     class Cmpt,                                                               \
464     int nCmpt,                                                                \
465     class Type, template<class> class PatchField,                             \
466     class GeoMesh                                                             \
467 >                                                                             \
468 tmp                                                                           \
469 <                                                                             \
470     GeometricField                                                            \
471     <typename product<Form, Type>::type, PatchField, GeoMesh>                 \
472 >                                                                             \
473 operator op                                                                   \
474 (                                                                             \
475     const VectorSpace<Form,Cmpt,nCmpt>& vs,                                   \
476     const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf1               \
479 PRODUCT_OPERATOR(typeOfSum, +, add)
480 PRODUCT_OPERATOR(typeOfSum, -, subtract)
482 PRODUCT_OPERATOR(outerProduct, *, outer)
483 PRODUCT_OPERATOR(crossProduct, ^, cross)
484 PRODUCT_OPERATOR(innerProduct, &, dot)
485 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
487 #undef PRODUCT_OPERATOR
490 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
492 } // End namespace Foam
494 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
496 #include "undefFieldFunctionsM.H"
498 // ************************************************************************* //