FieldFunctions.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
25 
26 #include "PstreamReduceOps.H"
27 #include "FieldReuseFunctions.H"
28 
29 #define TEMPLATE template<class Type>
30 #include "FieldFunctionsM.C"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 /* * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * */
38 
39 template<class Type>
40 void component
41 (
42  Field<typename Field<Type>::cmptType>& res,
43  const UList<Type>& f,
44  const direction d
45 )
46 {
47  typedef typename Field<Type>::cmptType cmptType;
49  (
50  cmptType, res, =, Type, f, .component, const direction, d
51  )
52 }
53 
54 
55 template<class Type>
56 void T(Field<Type>& res, const UList<Type>& f)
57 {
58  TFOR_ALL_F_OP_F_FUNC(Type, res, =, Type, f, T)
59 }
60 
61 
62 template<class Type, direction r>
63 void pow
64 (
65  Field<typename powProduct<Type, r>::type>& res,
66  const UList<Type>& vf
67 )
68 {
69  typedef typename powProduct<Type, r>::type powProductType;
71  (
72  powProductType, res, =, pow, Type, vf, powProductType,
74  )
75 }
76 
77 template<class Type, direction r>
79 pow
80 (
81  const UList<Type>& f,
83 )
84 {
85  typedef typename powProduct<Type, r>::type powProductType;
87  (
89  );
90  pow<Type, r>(tRes.ref(), f);
91  return tRes;
92 }
93 
94 template<class Type, direction r>
96 pow
97 (
98  const tmp<Field<Type>>& tf,
100 )
101 {
102  typedef typename powProduct<Type, r>::type powProductType;
104  pow<Type, r>(tRes.ref(), tf());
105  tf.clear();
106  return tRes;
107 }
108 
109 
110 template<class Type>
111 void sqr
112 (
113  Field<typename outerProduct<Type, Type>::type>& res,
114  const UList<Type>& vf
115 )
116 {
117  typedef typename outerProduct<Type, Type>::type outerProductType;
118  TFOR_ALL_F_OP_FUNC_F(outerProductType, res, =, sqr, Type, vf)
119 }
120 
121 template<class Type>
123 sqr(const UList<Type>& f)
124 {
125  typedef typename outerProduct<Type, Type>::type outerProductType;
127  (
129  );
130  sqr(tRes.ref(), f);
131  return tRes;
132 }
133 
134 template<class Type>
137 {
138  typedef typename outerProduct<Type, Type>::type outerProductType;
141  sqr(tRes.ref(), tf());
142  tf.clear();
143  return tRes;
144 }
145 
146 
147 template<class Type>
148 void magSqr(Field<scalar>& res, const UList<Type>& f)
149 {
150  TFOR_ALL_F_OP_FUNC_F(scalar, res, =, magSqr, Type, f)
151 }
152 
153 template<class Type>
155 {
156  tmp<Field<scalar>> tRes(new Field<scalar>(f.size()));
157  magSqr(tRes.ref(), f);
158  return tRes;
159 }
160 
161 template<class Type>
163 {
165  magSqr(tRes.ref(), tf());
166  tf.clear();
167  return tRes;
168 }
169 
170 
171 template<class Type>
172 void mag(Field<scalar>& res, const UList<Type>& f)
173 {
174  TFOR_ALL_F_OP_FUNC_F(scalar, res, =, mag, Type, f)
175 }
176 
177 template<class Type>
179 {
180  tmp<Field<scalar>> tRes(new Field<scalar>(f.size()));
181  mag(tRes.ref(), f);
182  return tRes;
183 }
184 
185 template<class Type>
187 {
189  mag(tRes.ref(), tf());
190  tf.clear();
191  return tRes;
192 }
193 
194 
195 template<class Type>
196 void cmptMax(Field<typename Field<Type>::cmptType>& res, const UList<Type>& f)
197 {
198  typedef typename Field<Type>::cmptType cmptType;
199  TFOR_ALL_F_OP_FUNC_F(cmptType, res, =, cmptMax, Type, f)
200 }
201 
202 template<class Type>
204 {
205  typedef typename Field<Type>::cmptType cmptType;
206  tmp<Field<cmptType>> tRes(new Field<cmptType>(f.size()));
207  cmptMax(tRes.ref(), f);
208  return tRes;
209 }
210 
211 template<class Type>
213 {
214  typedef typename Field<Type>::cmptType cmptType;
216  cmptMax(tRes.ref(), tf());
217  tf.clear();
218  return tRes;
219 }
220 
221 
222 template<class Type>
223 void cmptMin(Field<typename Field<Type>::cmptType>& res, const UList<Type>& f)
224 {
225  typedef typename Field<Type>::cmptType cmptType;
226  TFOR_ALL_F_OP_FUNC_F(cmptType, res, =, cmptMin, Type, f)
227 }
228 
229 template<class Type>
231 {
232  typedef typename Field<Type>::cmptType cmptType;
233  tmp<Field<cmptType>> tRes(new Field<cmptType>(f.size()));
234  cmptMin(tRes.ref(), f);
235  return tRes;
236 }
237 
238 template<class Type>
240 {
241  typedef typename Field<Type>::cmptType cmptType;
243  cmptMin(tRes.ref(), tf());
244  tf.clear();
245  return tRes;
246 }
247 
248 
249 template<class Type>
250 void cmptAv(Field<typename Field<Type>::cmptType>& res, const UList<Type>& f)
251 {
252  typedef typename Field<Type>::cmptType cmptType;
253  TFOR_ALL_F_OP_FUNC_F(cmptType, res, =, cmptAv, Type, f)
254 }
255 
256 template<class Type>
258 {
259  typedef typename Field<Type>::cmptType cmptType;
260  tmp<Field<cmptType>> tRes(new Field<cmptType>(f.size()));
261  cmptAv(tRes.ref(), f);
262  return tRes;
263 }
264 
265 template<class Type>
267 {
268  typedef typename Field<Type>::cmptType cmptType;
270  cmptAv(tRes.ref(), tf());
271  tf.clear();
272  return tRes;
273 }
274 
275 
276 template<class Type>
277 void cmptMag(Field<Type>& res, const UList<Type>& f)
278 {
279  TFOR_ALL_F_OP_FUNC_F(Type, res, =, cmptMag, Type, f)
280 }
281 
282 template<class Type>
284 {
285  tmp<Field<Type>> tRes(new Field<Type>(f.size()));
286  cmptMag(tRes.ref(), f);
287  return tRes;
288 }
289 
290 template<class Type>
292 {
293  tmp<Field<Type>> tRes = New(tf);
294  cmptMag(tRes.ref(), tf());
295  tf.clear();
296  return tRes;
297 }
298 
299 
300 #define TMP_UNARY_FUNCTION(ReturnType, Func) \
301  \
302 template<class Type> \
303 ReturnType Func(const tmp<Field<Type>>& tf1) \
304 { \
305  ReturnType res = Func(tf1()); \
306  tf1.clear(); \
307  return res; \
308 }
309 
310 template<class Type>
311 Type max(const UList<Type>& f)
312 {
313  if (f.size())
314  {
315  Type Max(f[0]);
316  TFOR_ALL_S_OP_FUNC_F_S(Type, Max, =, max, Type, f, Type, Max)
317  return Max;
318  }
319  else
320  {
321  return pTraits<Type>::min;
322  }
323 }
324 
326 
327 template<class Type>
328 Type min(const UList<Type>& f)
329 {
330  if (f.size())
331  {
332  Type Min(f[0]);
333  TFOR_ALL_S_OP_FUNC_F_S(Type, Min, =, min, Type, f, Type, Min)
334  return Min;
335  }
336  else
337  {
338  return pTraits<Type>::max;
339  }
340 }
341 
343 
344 template<class Type>
345 Type sum(const UList<Type>& f)
346 {
347  if (f.size())
348  {
349  Type Sum = Zero;
350  TFOR_ALL_S_OP_F(Type, Sum, +=, Type, f)
351  return Sum;
352  }
353  else
354  {
355  return Zero;
356  }
357 }
358 
360 
361 template<class Type>
362 Type maxMagSqr(const UList<Type>& f)
363 {
364  if (f.size())
365  {
366  Type Max(f[0]);
368  (
369  Type,
370  Max,
371  =,
373  Type,
374  f,
375  Type,
376  Max
377  )
378  return Max;
379  }
380  else
381  {
382  return Zero;
383  }
384 }
385 
386 TMP_UNARY_FUNCTION(Type, maxMagSqr)
387 
388 template<class Type>
389 Type minMagSqr(const UList<Type>& f)
390 {
391  if (f.size())
392  {
393  Type Min(f[0]);
395  (
396  Type,
397  Min,
398  =,
400  Type,
401  f,
402  Type,
403  Min
404  )
405  return Min;
406  }
407  else
408  {
409  return pTraits<Type>::rootMax;
410  }
411 }
412 
413 TMP_UNARY_FUNCTION(Type, minMagSqr)
414 
415 template<class Type>
416 scalar sumProd(const UList<Type>& f1, const UList<Type>& f2)
417 {
418  if (f1.size() && (f1.size() == f2.size()))
419  {
420  scalar SumProd = 0;
421  TFOR_ALL_S_OP_F_OP_F(scalar, SumProd, +=, Type, f1, &&, Type, f2)
422  return SumProd;
423  }
424  else
425  {
426  return 0;
427  }
428 }
429 
430 
431 template<class Type>
432 Type sumCmptProd(const UList<Type>& f1, const UList<Type>& f2)
433 {
434  if (f1.size() && (f1.size() == f2.size()))
435  {
436  Type SumProd = Zero;
438  (
439  Type,
440  SumProd,
441  +=,
442  cmptMultiply,
443  Type,
444  f1,
445  Type,
446  f2
447  )
448  return SumProd;
449  }
450  else
451  {
452  return Zero;
453  }
454 }
455 
456 
457 template<class Type>
458 scalar sumSqr(const UList<Type>& f)
459 {
460  if (f.size())
461  {
462  scalar SumSqr = 0;
463  TFOR_ALL_S_OP_FUNC_F(scalar, SumSqr, +=, sqr, Type, f)
464  return SumSqr;
465  }
466  else
467  {
468  return 0;
469  }
470 }
471 
472 TMP_UNARY_FUNCTION(scalar, sumSqr)
473 
474 template<class Type>
475 scalar sumMag(const UList<Type>& f)
476 {
477  if (f.size())
478  {
479  scalar SumMag = 0;
480  TFOR_ALL_S_OP_FUNC_F(scalar, SumMag, +=, mag, Type, f)
481  return SumMag;
482  }
483  else
484  {
485  return 0;
486  }
487 }
488 
489 TMP_UNARY_FUNCTION(scalar, sumMag)
490 
491 
492 template<class Type>
493 Type sumCmptMag(const UList<Type>& f)
494 {
495  if (f.size())
496  {
497  Type SumMag = Zero;
498  TFOR_ALL_S_OP_FUNC_F(scalar, SumMag, +=, cmptMag, Type, f)
499  return SumMag;
500  }
501  else
502  {
503  return Zero;
504  }
505 }
506 
507 TMP_UNARY_FUNCTION(Type, sumCmptMag)
508 
509 template<class Type>
510 Type average(const UList<Type>& f)
511 {
512  if (f.size())
513  {
514  Type avrg = sum(f)/f.size();
515 
516  return avrg;
517  }
518  else
519  {
521  << "empty field, returning zero" << endl;
522 
523  return Zero;
524  }
525 }
526 
528 
529 
530 #define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc) \
531  \
532 template<class Type> \
533 ReturnType gFunc(const UList<Type>& f, const label comm) \
534 { \
535  ReturnType res = Func(f); \
536  reduce(res, rFunc##Op<Type>(), Pstream::msgType(), comm); \
537  return res; \
538 } \
539 TMP_UNARY_FUNCTION(ReturnType, gFunc)
540 
542 G_UNARY_FUNCTION(Type, gMin, min, min)
543 G_UNARY_FUNCTION(Type, gSum, sum, sum)
544 G_UNARY_FUNCTION(Type, gMaxMagSqr, maxMagSqr, maxMagSqr)
545 G_UNARY_FUNCTION(Type, gMinMagSqr, minMagSqr, minMagSqr)
546 G_UNARY_FUNCTION(scalar, gSumSqr, sumSqr, sum)
547 G_UNARY_FUNCTION(scalar, gSumMag, sumMag, sum)
548 G_UNARY_FUNCTION(Type, gSumCmptMag, sumCmptMag, sum)
549 
550 #undef G_UNARY_FUNCTION
551 
552 template<class Type>
553 scalar gSumProd
554 (
555  const UList<Type>& f1,
556  const UList<Type>& f2,
557  const label comm
558 )
559 {
560  scalar SumProd = sumProd(f1, f2);
561  reduce(SumProd, sumOp<scalar>(), Pstream::msgType(), comm);
562  return SumProd;
563 }
564 
565 template<class Type>
566 Type gSumCmptProd
567 (
568  const UList<Type>& f1,
569  const UList<Type>& f2,
570  const label comm
571 )
572 {
573  Type SumProd = sumCmptProd(f1, f2);
574  reduce(SumProd, sumOp<Type>(), Pstream::msgType(), comm);
575  return SumProd;
576 }
577 
578 template<class Type>
579 Type gAverage
580 (
581  const UList<Type>& f,
582  const label comm
583 )
584 {
585  label n = f.size();
586  Type s = sum(f);
587  sumReduce(s, n, Pstream::msgType(), comm);
588 
589  if (n > 0)
590  {
591  Type avrg = s/n;
592 
593  return avrg;
594  }
595  else
596  {
598  << "empty field, returning zero." << endl;
599 
600  return Zero;
601  }
602 }
603 
605 
606 #undef TMP_UNARY_FUNCTION
607 
608 
609 BINARY_FUNCTION(Type, Type, Type, max)
610 BINARY_FUNCTION(Type, Type, Type, min)
611 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
612 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
613 
614 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
615 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
618 
619 
620 /* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */
621 
622 UNARY_OPERATOR(Type, Type, -, negate)
623 
624 BINARY_OPERATOR(Type, Type, scalar, *, multiply)
625 BINARY_OPERATOR(Type, scalar, Type, *, multiply)
626 BINARY_OPERATOR(Type, Type, scalar, /, divide)
627 
628 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, multiply)
629 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, multiply)
630 
631 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide)
632 
633 
634 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
635 
636 #define PRODUCT_OPERATOR(product, Op, OpFunc) \
637  \
638 template<class Type1, class Type2> \
639 void OpFunc \
640 ( \
641  Field<typename product<Type1, Type2>::type>& res, \
642  const UList<Type1>& f1, \
643  const UList<Type2>& f2 \
644 ) \
645 { \
646  typedef typename product<Type1, Type2>::type productType; \
647  TFOR_ALL_F_OP_F_OP_F(productType, res, =, Type1, f1, Op, Type2, f2) \
648 } \
649  \
650 template<class Type1, class Type2> \
651 tmp<Field<typename product<Type1, Type2>::type>> \
652 operator Op(const UList<Type1>& f1, const UList<Type2>& f2) \
653 { \
654  typedef typename product<Type1, Type2>::type productType; \
655  tmp<Field<productType>> tRes(new Field<productType>(f1.size())); \
656  OpFunc(tRes.ref(), f1, f2); \
657  return tRes; \
658 } \
659  \
660 template<class Type1, class Type2> \
661 tmp<Field<typename product<Type1, Type2>::type>> \
662 operator Op(const UList<Type1>& f1, const tmp<Field<Type2>>& tf2) \
663 { \
664  typedef typename product<Type1, Type2>::type productType; \
665  tmp<Field<productType>> tRes = reuseTmp<productType, Type2>::New(tf2); \
666  OpFunc(tRes.ref(), f1, tf2()); \
667  tf2.clear(); \
668  return tRes; \
669 } \
670  \
671 template<class Type1, class Type2> \
672 tmp<Field<typename product<Type1, Type2>::type>> \
673 operator Op(const tmp<Field<Type1>>& tf1, const UList<Type2>& f2) \
674 { \
675  typedef typename product<Type1, Type2>::type productType; \
676  tmp<Field<productType>> tRes = reuseTmp<productType, Type1>::New(tf1); \
677  OpFunc(tRes.ref(), tf1(), f2); \
678  tf1.clear(); \
679  return tRes; \
680 } \
681  \
682 template<class Type1, class Type2> \
683 tmp<Field<typename product<Type1, Type2>::type>> \
684 operator Op(const tmp<Field<Type1>>& tf1, const tmp<Field<Type2>>& tf2) \
685 { \
686  typedef typename product<Type1, Type2>::type productType; \
687  tmp<Field<productType>> tRes = \
688  reuseTmpTmp<productType, Type1, Type1, Type2>::New(tf1, tf2); \
689  OpFunc(tRes.ref(), tf1(), tf2()); \
690  tf1.clear(); \
691  tf2.clear(); \
692  return tRes; \
693 } \
694  \
695 template<class Type, class Form, class Cmpt, direction nCmpt> \
696 void OpFunc \
697 ( \
698  Field<typename product<Type, Form>::type>& res, \
699  const UList<Type>& f1, \
700  const VectorSpace<Form,Cmpt,nCmpt>& vs \
701 ) \
702 { \
703  typedef typename product<Type, Form>::type productType; \
704  TFOR_ALL_F_OP_F_OP_S \
705  (productType, res, =,Type, f1, Op, Form, static_cast<const Form&>(vs)) \
706 } \
707  \
708 template<class Type, class Form, class Cmpt, direction nCmpt> \
709 tmp<Field<typename product<Type, Form>::type>> \
710 operator Op(const UList<Type>& f1, const VectorSpace<Form,Cmpt,nCmpt>& vs) \
711 { \
712  typedef typename product<Type, Form>::type productType; \
713  tmp<Field<productType>> tRes(new Field<productType>(f1.size())); \
714  OpFunc(tRes.ref(), f1, static_cast<const Form&>(vs)); \
715  return tRes; \
716 } \
717  \
718 template<class Type, class Form, class Cmpt, direction nCmpt> \
719 tmp<Field<typename product<Type, Form>::type>> \
720 operator Op \
721 ( \
722  const tmp<Field<Type>>& tf1, \
723  const VectorSpace<Form,Cmpt,nCmpt>& vs \
724 ) \
725 { \
726  typedef typename product<Type, Form>::type productType; \
727  tmp<Field<productType>> tRes = reuseTmp<productType, Type>::New(tf1); \
728  OpFunc(tRes.ref(), tf1(), static_cast<const Form&>(vs)); \
729  tf1.clear(); \
730  return tRes; \
731 } \
732  \
733 template<class Form, class Cmpt, direction nCmpt, class Type> \
734 void OpFunc \
735 ( \
736  Field<typename product<Form, Type>::type>& res, \
737  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
738  const UList<Type>& f1 \
739 ) \
740 { \
741  typedef typename product<Form, Type>::type productType; \
742  TFOR_ALL_F_OP_S_OP_F \
743  (productType, res, =,Form,static_cast<const Form&>(vs), Op, Type, f1) \
744 } \
745  \
746 template<class Form, class Cmpt, direction nCmpt, class Type> \
747 tmp<Field<typename product<Form, Type>::type>> \
748 operator Op(const VectorSpace<Form,Cmpt,nCmpt>& vs, const UList<Type>& f1) \
749 { \
750  typedef typename product<Form, Type>::type productType; \
751  tmp<Field<productType>> tRes(new Field<productType>(f1.size())); \
752  OpFunc(tRes.ref(), static_cast<const Form&>(vs), f1); \
753  return tRes; \
754 } \
755  \
756 template<class Form, class Cmpt, direction nCmpt, class Type> \
757 tmp<Field<typename product<Form, Type>::type>> \
758 operator Op \
759 ( \
760  const VectorSpace<Form,Cmpt,nCmpt>& vs, const tmp<Field<Type>>& tf1 \
761 ) \
762 { \
763  typedef typename product<Form, Type>::type productType; \
764  tmp<Field<productType>> tRes = reuseTmp<productType, Type>::New(tf1); \
765  OpFunc(tRes.ref(), static_cast<const Form&>(vs), tf1()); \
766  tf1.clear(); \
767  return tRes; \
768 }
769 
772 
777 
778 #undef PRODUCT_OPERATOR
779 
780 
781 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
782 
783 } // End namespace Foam
784 
785 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
786 
787 #include "undefFieldFunctionsM.H"
788 
789 // ************************************************************************* //
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
static tmp< Field< TypeR > > New(const tmp< Field< Type1 >> &tf1)
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Inter-processor communication reduction functions.
#define TMP_UNARY_FUNCTION(ReturnType, Func)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &df)
Type minMagSqr(const UList< Type > &f)
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
dimensionedSymmTensor sqr(const dimensionedVector &dv)
uint8_t direction
Definition: direction.H:45
pTraits< Type >::cmptType cmptType
Component type.
Definition: Field.H:97
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#define TFOR_ALL_F_OP_F_FUNC(typeF1, f1, OP, typeF2, f2, FUNC)
Definition: FieldM.H:127
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
Traits class for primitives.
Definition: pTraits.H:50
#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:90
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:476
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)
#define TFOR_ALL_F_OP_FUNC_F(typeF1, f1, OP, FUNC, typeF2, f2)
Definition: FieldM.H:112
void dotdot(FieldField< Field1, typename scalarProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void subtract(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Type sumCmptProd(const UList< Type > &f1, const UList< Type > &f2)
const tensorField & tf
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
scalar sumProd(const UList< Type > &f1, const UList< Type > &f2)
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
#define TFOR_ALL_S_OP_FUNC_F(typeS, s, OP, FUNC, typeF, f)
Definition: FieldM.H:390
Type gSumCmptProd(const UList< Type > &f1, const UList< Type > &f2, const label comm)
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Pre-declare SubField and related Field type.
Definition: Field.H:56
#define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc)
#define TFOR_ALL_S_OP_F(typeS, s, OP, typeF, f)
Definition: FieldM.H:363
Type sumCmptMag(const UList< Type > &f)
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.H:124
void sumReduce(T &Value, label &Count, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
#define TFOR_ALL_S_OP_FUNC_F_S(typeS1, s1, OP, FUNC, typeF, f, typeS2, s2)
Definition: FieldM.H:197
#define TFOR_ALL_S_OP_FUNC_F_F(typeS, s, OP, FUNC, typeF1, f1, typeF2, f2)
Definition: FieldM.H:163
static const zero Zero
Definition: zero.H:97
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
scalar gSumProd(const UList< Type > &f1, const UList< Type > &f2, const label comm)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Type gMax(const FieldField< Field, Type > &f)
#define TFOR_ALL_S_OP_F_OP_F(typeS, s, OP1, typeF1, f1, OP2, typeF2, f2)
Definition: FieldM.H:376
labelList f(nPoints)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
symmTypeOfRank< typename pTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank) >::type type
Definition: products.H:136
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
scalar sumSqr(const UList< Type > &f)
void negate(FieldField< Field, Type > &res, const FieldField< Field, Type > &f)
#define WarningInFunction
Report a warning using Foam::Warning.
Type gAverage(const FieldField< Field, Type > &f)
#define TFOR_ALL_F_OP_F_FUNC_S(typeF1, f1, OP, typeF2, f2, FUNC, typeS, s)
Definition: FieldM.H:240
Type maxMagSqr(const UList< Type > &f)
dimensioned< scalar > mag(const dimensioned< Type > &)
label n
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
A class for managing temporary objects.
Definition: PtrList.H:53
void cmptMin(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
label size() const
Return the number of elements in the UList.
Definition: UListI.H:299
#define PRODUCT_OPERATOR(product, Op, OpFunc)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
Namespace for OpenFOAM.
dimensioned< scalar > sumMag(const DimensionedField< Type, GeoMesh > &df)
#define TFOR_ALL_F_OP_FUNC_F_S(typeF1, f1, OP, FUNC, typeF2, f2, typeS, s)
Definition: FieldM.H:180