FieldFunctions.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "PstreamReduceOps.H"
30 #include "FieldReuseFunctions.H"
31 
32 #define TEMPLATE template<class Type>
33 #include "FieldFunctionsM.C"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 /* * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * */
41 
42 template<class Type>
43 void component
44 (
45  Field<typename Field<Type>::cmptType>& res,
46  const UList<Type>& f,
47  const direction d
48 )
49 {
50  typedef typename Field<Type>::cmptType cmptType;
52  (
53  cmptType, res, =, Type, f, .component, const direction, d
54  )
55 }
56 
57 
58 template<class Type>
59 void T(Field<Type>& res, const UList<Type>& f)
60 {
61  TFOR_ALL_F_OP_F_FUNC(Type, res, =, Type, f, T)
62 }
63 
64 
65 template<class Type, direction r>
66 void pow
67 (
68  Field<typename powProduct<Type, r>::type>& res,
69  const UList<Type>& vf
70 )
71 {
72  typedef typename powProduct<Type, r>::type powProductType;
74  (
75  powProductType, res, =, pow, Type, vf, powProductType,
77  )
78 }
79 
80 template<class Type, direction r>
82 pow
83 (
84  const UList<Type>& f,
86 )
87 {
88  typedef typename powProduct<Type, r>::type powProductType;
89  auto tres
90  (
91  tmp<Field<powProductType>>::New(f.size())
92  );
93  pow<Type, r>(tres.ref(), f);
94  return tres;
95 }
96 
97 template<class Type, direction r>
99 pow
100 (
101  const tmp<Field<Type>>& tf,
103 )
104 {
105  typedef typename powProduct<Type, r>::type powProductType;
106  auto tres = reuseTmp<powProductType, Type>::New(tf);
107  pow<Type, r>(tres.ref(), tf());
108  tf.clear();
109  return tres;
110 }
111 
112 
113 template<class Type>
114 void sqr
115 (
116  Field<typename outerProduct<Type, Type>::type>& res,
117  const UList<Type>& vf
118 )
119 {
120  typedef typename outerProduct<Type, Type>::type outerProductType;
121  TFOR_ALL_F_OP_FUNC_F(outerProductType, res, =, sqr, Type, vf)
122 }
123 
124 template<class Type>
127 {
128  typedef typename outerProduct<Type, Type>::type outerProductType;
129  auto tres
130  (
131  tmp<Field<outerProductType>>::New(f.size())
132  );
133  sqr(tres.ref(), f);
134  return tres;
135 }
136 
137 template<class Type>
139 sqr(const tmp<Field<Type>>& tf)
140 {
141  typedef typename outerProduct<Type, Type>::type outerProductType;
143  sqr(tres.ref(), tf());
144  tf.clear();
145  return tres;
146 }
147 
148 
149 template<class Type>
150 void magSqr
151 (
152  Field<typename typeOfMag<Type>::type>& res,
153  const UList<Type>& f
154 )
155 {
156  typedef typename typeOfMag<Type>::type magType;
157 
158  TFOR_ALL_F_OP_FUNC_F(magType, res, =, magSqr, Type, f)
159 }
160 
161 template<class Type>
164 {
165  typedef typename typeOfMag<Type>::type magType;
166 
167  auto tres = tmp<Field<magType>>::New(f.size());
168  magSqr(tres.ref(), f);
169  return tres;
170 }
171 
172 template<class Type>
174 magSqr(const tmp<Field<Type>>& tf)
175 {
176  typedef typename typeOfMag<Type>::type magType;
177 
178  auto tres = reuseTmp<magType, Type>::New(tf);
179  magSqr(tres.ref(), tf());
180  tf.clear();
181  return tres;
182 }
183 
184 
185 template<class Type>
186 void mag
187 (
188  Field<typename typeOfMag<Type>::type>& res,
189  const UList<Type>& f
190 )
191 {
192  typedef typename typeOfMag<Type>::type magType;
193 
194  TFOR_ALL_F_OP_FUNC_F(magType, res, =, mag, Type, f)
195 }
196 
197 template<class Type>
200 {
201  typedef typename typeOfMag<Type>::type magType;
202 
203  auto tres = tmp<Field<magType>>::New(f.size());
204  mag(tres.ref(), f);
205  return tres;
206 }
207 
208 template<class Type>
210 mag(const tmp<Field<Type>>& tf)
211 {
212  typedef typename typeOfMag<Type>::type magType;
213 
214  auto tres = reuseTmp<magType, Type>::New(tf);
215  mag(tres.ref(), tf());
216  tf.clear();
217  return tres;
218 }
219 
220 
221 template<class Type>
222 void cmptMax(Field<typename Field<Type>::cmptType>& res, const UList<Type>& f)
223 {
224  typedef typename Field<Type>::cmptType cmptType;
225  TFOR_ALL_F_OP_FUNC_F(cmptType, res, =, cmptMax, Type, f)
226 }
227 
228 template<class Type>
230 {
231  typedef typename Field<Type>::cmptType cmptType;
232  auto tres = tmp<Field<cmptType>>::New(f.size());
233  cmptMax(tres.ref(), f);
234  return tres;
235 }
236 
237 template<class Type>
239 {
240  typedef typename Field<Type>::cmptType cmptType;
241  auto tres = reuseTmp<cmptType, Type>::New(tf);
242  cmptMax(tres.ref(), tf());
243  tf.clear();
244  return tres;
245 }
246 
247 
248 template<class Type>
249 void cmptMin(Field<typename Field<Type>::cmptType>& res, const UList<Type>& f)
250 {
251  typedef typename Field<Type>::cmptType cmptType;
252  TFOR_ALL_F_OP_FUNC_F(cmptType, res, =, cmptMin, Type, f)
253 }
254 
255 template<class Type>
257 {
258  typedef typename Field<Type>::cmptType cmptType;
259  auto tres = tmp<Field<cmptType>>::New(f.size());
260  cmptMin(tres.ref(), f);
261  return tres;
262 }
263 
264 template<class Type>
266 {
267  typedef typename Field<Type>::cmptType cmptType;
268  auto tres = reuseTmp<cmptType, Type>::New(tf);
269  cmptMin(tres.ref(), tf());
270  tf.clear();
271  return tres;
272 }
273 
274 
275 template<class Type>
276 void cmptAv(Field<typename Field<Type>::cmptType>& res, const UList<Type>& f)
277 {
278  typedef typename Field<Type>::cmptType cmptType;
279  TFOR_ALL_F_OP_FUNC_F(cmptType, res, =, cmptAv, Type, f)
280 }
281 
282 template<class Type>
284 {
285  typedef typename Field<Type>::cmptType cmptType;
286  auto tres = tmp<Field<cmptType>>::New(f.size());
287  cmptAv(tres.ref(), f);
288  return tres;
289 }
290 
291 template<class Type>
293 {
294  typedef typename Field<Type>::cmptType cmptType;
295  auto tres = reuseTmp<cmptType, Type>::New(tf);
296  cmptAv(tres.ref(), tf());
297  tf.clear();
298  return tres;
299 }
300 
301 
302 template<class Type>
303 void cmptMag(Field<Type>& res, const UList<Type>& f)
304 {
305  TFOR_ALL_F_OP_FUNC_F(Type, res, =, cmptMag, Type, f)
306 }
307 
308 template<class Type>
310 {
311  auto tres = tmp<Field<Type>>::New(f.size());
312  cmptMag(tres.ref(), f);
313  return tres;
314 }
315 
316 template<class Type>
318 {
319  auto tres = New(tf);
320  cmptMag(tres.ref(), tf());
321  tf.clear();
322  return tres;
323 }
324 
325 
326 template<class Type>
328 {
329  TFOR_ALL_F_OP_FUNC_F(Type, res, =, cmptMagSqr, Type, f)
330 }
331 
332 template<class Type>
334 {
335  auto tres = tmp<Field<Type>>::New(f.size());
336  cmptMagSqr(tres.ref(), f);
337  return tres;
338 }
339 
340 template<class Type>
342 {
343  auto tres = New(tf);
344  cmptMagSqr(tres.ref(), tf());
345  tf.clear();
346  return tres;
347 }
348 
349 
350 #define TMP_UNARY_FUNCTION(ReturnType, Func) \
351  \
352 template<class Type> \
353 ReturnType Func(const tmp<Field<Type>>& tf1) \
354 { \
355  ReturnType res = Func(tf1()); \
356  tf1.clear(); \
357  return res; \
358 }
359 
360 template<class Type>
361 Type max(const UList<Type>& f)
362 {
363  if (f.size())
364  {
365  Type Max(f[0]);
366  TFOR_ALL_S_OP_FUNC_F_S(Type, Max, =, max, Type, f, Type, Max)
367  return Max;
368  }
369 
370  return pTraits<Type>::min;
371 }
372 
374 
375 template<class Type>
376 Type min(const UList<Type>& f)
377 {
378  if (f.size())
379  {
380  Type Min(f[0]);
381  TFOR_ALL_S_OP_FUNC_F_S(Type, Min, =, min, Type, f, Type, Min)
382  return Min;
383  }
384 
385  return pTraits<Type>::max;
386 }
387 
389 
390 template<class Type>
391 Type sum(const UList<Type>& f)
392 {
393  typedef typename Foam::typeOfSolve<Type>::type solveType;
394 
395  solveType Sum = Zero;
396 
397  if (f.size())
398  {
399  TFOR_ALL_S_OP_FUNC_F(solveType, Sum, +=, solveType, Type, f)
400  }
401 
402  return Type(Sum);
403 }
404 
406 
407 
408 // From MinMaxOps.H:
409 // - Foam::minMax(const UList<Type>&)
410 // - Foam::minMaxMag(const UList<Type>&)
411 
414 
415 
416 template<class Type>
417 Type maxMagSqr(const UList<Type>& f)
418 {
419  if (f.size())
420  {
421  Type Max(f[0]);
423  (
424  Type,
425  Max,
426  =,
428  Type,
429  f,
430  Type,
431  Max
432  )
433  return Max;
434  }
435 
436  return Zero;
437 }
438 
440 
441 template<class Type>
442 Type minMagSqr(const UList<Type>& f)
443 {
444  if (f.size())
445  {
446  Type Min(f[0]);
448  (
449  Type,
450  Min,
451  =,
453  Type,
454  f,
455  Type,
456  Min
457  )
458  return Min;
459  }
460 
461  return pTraits<Type>::rootMax;
462 }
463 
465 
466 template<class Type>
468 sumProd(const UList<Type>& f1, const UList<Type>& f2)
469 {
470  typedef typename scalarProduct<Type, Type>::type prodType;
471 
472  prodType result = Zero;
473  if (f1.size() && (f1.size() == f2.size()))
474  {
475  TFOR_ALL_S_OP_F_OP_F(prodType, result, +=, Type, f1, &&, Type, f2)
476  }
477  return result;
478 }
479 
480 
481 template<class Type>
482 Type sumCmptProd(const UList<Type>& f1, const UList<Type>& f2)
483 {
484  Type SumProd = Zero;
485  if (f1.size() && (f1.size() == f2.size()))
486  {
488  (
489  Type,
490  SumProd,
491  +=,
492  cmptMultiply,
493  Type,
494  f1,
495  Type,
496  f2
497  )
498  }
499  return SumProd;
500 }
501 
502 
503 template<class Type>
506 {
507  typedef typename outerProduct1<Type>::type prodType;
508  prodType result = Zero;
509  if (f.size())
510  {
511  TFOR_ALL_S_OP_FUNC_F(prodType, result, +=, sqr, Type, f)
512  }
513  return result;
514 }
515 
516 template<class Type>
518 sumSqr(const tmp<Field<Type>>& tf)
519 {
520  typedef typename outerProduct1<Type>::type prodType;
521  prodType result = sumSqr(tf());
522  tf.clear();
523  return result;
524 }
525 
526 
527 template<class Type>
528 typename typeOfMag<Type>::type
530 {
531  typedef typename typeOfMag<Type>::type magType;
532  magType result = Zero;
533  if (f.size())
534  {
535  TFOR_ALL_S_OP_FUNC_F(magType, result, +=, mag, Type, f)
536  }
537  return result;
538 }
539 
541 
542 
543 template<class Type>
545 {
546  Type result = Zero;
547  if (f.size())
548  {
549  TFOR_ALL_S_OP_FUNC_F(Type, result, +=, cmptMag, Type, f)
550  }
551  return result;
552 }
553 
555 
556 template<class Type>
557 Type average(const UList<Type>& f)
558 {
559  if (f.size())
560  {
561  Type avrg = sum(f)/f.size();
562 
563  return avrg;
564  }
565 
567  << "empty field, returning zero" << endl;
568 
569  return Zero;
570 }
571 
573 
574 
575 // With reduction on ReturnType
576 #define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc) \
577  \
578 template<class Type> \
579 ReturnType gFunc(const UList<Type>& f, const label comm) \
580 { \
581  ReturnType res = Func(f); \
582  reduce(res, rFunc##Op<ReturnType>(), Pstream::msgType(), comm); \
583  return res; \
584 } \
585 TMP_UNARY_FUNCTION(ReturnType, gFunc)
586 
593 
596 
599 
600 #undef G_UNARY_FUNCTION
601 
602 
603 template<class Type>
605 (
606  const UList<Type>& f1,
607  const UList<Type>& f2,
608  const label comm
609 )
610 {
611  typedef typename scalarProduct<Type, Type>::type prodType;
612 
613  prodType result = sumProd(f1, f2);
614  reduce(result, sumOp<prodType>(), Pstream::msgType(), comm);
615  return result;
616 }
617 
618 template<class Type>
619 Type gSumCmptProd
620 (
621  const UList<Type>& f1,
622  const UList<Type>& f2,
623  const label comm
624 )
625 {
626  Type SumProd = sumCmptProd(f1, f2);
627  reduce(SumProd, sumOp<Type>(), Pstream::msgType(), comm);
628  return SumProd;
629 }
630 
631 template<class Type>
632 Type gAverage
633 (
634  const UList<Type>& f,
635  const label comm
636 )
637 {
638  label n = f.size();
639  Type s = sum(f);
640  sumReduce(s, n, Pstream::msgType(), comm);
641 
642  if (n > 0)
643  {
644  Type avrg = s/n;
645 
646  return avrg;
647  }
648 
650  << "empty field, returning zero." << endl;
651 
652  return Zero;
653 }
654 
656 
657 #undef TMP_UNARY_FUNCTION
658 
659 
660 BINARY_FUNCTION(Type, Type, Type, max)
661 BINARY_FUNCTION(Type, Type, Type, min)
662 BINARY_FUNCTION(Type, Type, Type, cmptMultiply)
663 BINARY_FUNCTION(Type, Type, Type, cmptDivide)
664 
665 BINARY_TYPE_FUNCTION(Type, Type, Type, max)
666 BINARY_TYPE_FUNCTION(Type, Type, Type, min)
667 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptMultiply)
668 BINARY_TYPE_FUNCTION(Type, Type, Type, cmptDivide)
669 
671 
672 
673 /* * * * * * * * * * * * * * * * Global operators * * * * * * * * * * * * * */
674 
675 UNARY_OPERATOR(Type, Type, -, negate)
676 
677 BINARY_OPERATOR(Type, Type, scalar, *, multiply)
678 BINARY_OPERATOR(Type, scalar, Type, *, multiply)
679 BINARY_OPERATOR(Type, Type, scalar, /, divide)
680 
681 BINARY_TYPE_OPERATOR_SF(Type, scalar, Type, *, multiply)
682 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, *, multiply)
683 
684 BINARY_TYPE_OPERATOR_FS(Type, Type, scalar, /, divide)
685 
686 
687 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
688 
689 #define PRODUCT_OPERATOR(product, Op, OpFunc) \
690  \
691 template<class Type1, class Type2> \
692 void OpFunc \
693 ( \
694  Field<typename product<Type1, Type2>::type>& res, \
695  const UList<Type1>& f1, \
696  const UList<Type2>& f2 \
697 ) \
698 { \
699  typedef typename product<Type1, Type2>::type productType; \
700  TFOR_ALL_F_OP_F_OP_F(productType, res, =, Type1, f1, Op, Type2, f2) \
701 } \
702  \
703 template<class Type1, class Type2> \
704 tmp<Field<typename product<Type1, Type2>::type>> \
705 operator Op(const UList<Type1>& f1, const UList<Type2>& f2) \
706 { \
707  typedef typename product<Type1, Type2>::type productType; \
708  auto tres = tmp<Field<productType>>::New(f1.size()); \
709  OpFunc(tres.ref(), f1, f2); \
710  return tres; \
711 } \
712  \
713 template<class Type1, class Type2> \
714 tmp<Field<typename product<Type1, Type2>::type>> \
715 operator Op(const UList<Type1>& f1, const tmp<Field<Type2>>& tf2) \
716 { \
717  typedef typename product<Type1, Type2>::type productType; \
718  auto tres = reuseTmp<productType, Type2>::New(tf2); \
719  OpFunc(tres.ref(), f1, tf2()); \
720  tf2.clear(); \
721  return tres; \
722 } \
723  \
724 template<class Type1, class Type2> \
725 tmp<Field<typename product<Type1, Type2>::type>> \
726 operator Op(const tmp<Field<Type1>>& tf1, const UList<Type2>& f2) \
727 { \
728  typedef typename product<Type1, Type2>::type productType; \
729  auto tres = reuseTmp<productType, Type1>::New(tf1); \
730  OpFunc(tres.ref(), tf1(), f2); \
731  tf1.clear(); \
732  return tres; \
733 } \
734  \
735 template<class Type1, class Type2> \
736 tmp<Field<typename product<Type1, Type2>::type>> \
737 operator Op(const tmp<Field<Type1>>& tf1, const tmp<Field<Type2>>& tf2) \
738 { \
739  typedef typename product<Type1, Type2>::type productType; \
740  auto tres = reuseTmpTmp<productType, Type1, Type1, Type2>::New(tf1, tf2); \
741  OpFunc(tres.ref(), tf1(), tf2()); \
742  tf1.clear(); \
743  tf2.clear(); \
744  return tres; \
745 } \
746  \
747 template<class Type, class Form, class Cmpt, direction nCmpt> \
748 void OpFunc \
749 ( \
750  Field<typename product<Type, Form>::type>& res, \
751  const UList<Type>& f1, \
752  const VectorSpace<Form,Cmpt,nCmpt>& vs \
753 ) \
754 { \
755  typedef typename product<Type, Form>::type productType; \
756  TFOR_ALL_F_OP_F_OP_S \
757  (productType, res, =,Type, f1, Op, Form, static_cast<const Form&>(vs)) \
758 } \
759  \
760 template<class Type, class Form, class Cmpt, direction nCmpt> \
761 tmp<Field<typename product<Type, Form>::type>> \
762 operator Op(const UList<Type>& f1, const VectorSpace<Form,Cmpt,nCmpt>& vs) \
763 { \
764  typedef typename product<Type, Form>::type productType; \
765  auto tres = tmp<Field<productType>>::New(f1.size()); \
766  OpFunc(tres.ref(), f1, static_cast<const Form&>(vs)); \
767  return tres; \
768 } \
769  \
770 template<class Type, class Form, class Cmpt, direction nCmpt> \
771 tmp<Field<typename product<Type, Form>::type>> \
772 operator Op \
773 ( \
774  const tmp<Field<Type>>& tf1, \
775  const VectorSpace<Form,Cmpt,nCmpt>& vs \
776 ) \
777 { \
778  typedef typename product<Type, Form>::type productType; \
779  auto tres = reuseTmp<productType, Type>::New(tf1); \
780  OpFunc(tres.ref(), tf1(), static_cast<const Form&>(vs)); \
781  tf1.clear(); \
782  return tres; \
783 } \
784  \
785 template<class Form, class Cmpt, direction nCmpt, class Type> \
786 void OpFunc \
787 ( \
788  Field<typename product<Form, Type>::type>& res, \
789  const VectorSpace<Form,Cmpt,nCmpt>& vs, \
790  const UList<Type>& f1 \
791 ) \
792 { \
793  typedef typename product<Form, Type>::type productType; \
794  TFOR_ALL_F_OP_S_OP_F \
795  (productType, res, =,Form,static_cast<const Form&>(vs), Op, Type, f1) \
796 } \
797  \
798 template<class Form, class Cmpt, direction nCmpt, class Type> \
799 tmp<Field<typename product<Form, Type>::type>> \
800 operator Op(const VectorSpace<Form,Cmpt,nCmpt>& vs, const UList<Type>& f1) \
801 { \
802  typedef typename product<Form, Type>::type productType; \
803  auto tres = tmp<Field<productType>>::New(f1.size()); \
804  OpFunc(tres.ref(), static_cast<const Form&>(vs), f1); \
805  return tres; \
806 } \
807  \
808 template<class Form, class Cmpt, direction nCmpt, class Type> \
809 tmp<Field<typename product<Form, Type>::type>> \
810 operator Op \
811 ( \
812  const VectorSpace<Form,Cmpt,nCmpt>& vs, const tmp<Field<Type>>& tf1 \
813 ) \
814 { \
815  typedef typename product<Form, Type>::type productType; \
816  auto tres = reuseTmp<productType, Type>::New(tf1); \
817  OpFunc(tres.ref(), static_cast<const Form&>(vs), tf1()); \
818  tf1.clear(); \
819  return tres; \
820 }
821 
824 
829 
830 #undef PRODUCT_OPERATOR
831 
832 
833 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
834 
835 } // End namespace Foam
836 
837 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
838 
839 #include "undefFieldFunctionsM.H"
840 
841 // ************************************************************************* //
BINARY_TYPE_OPERATOR_SF
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:522
BINARY_OPERATOR
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:412
TFOR_ALL_F_OP_FUNC_F_S
#define TFOR_ALL_F_OP_FUNC_F_S(typeF1, f1, OP, FUNC, typeF2, f2, typeS, s)
Definition: FieldM.H:187
Foam::cmptMagSqr
void cmptMagSqr(Field< Type > &res, const UList< Type > &f)
Definition: FieldFunctions.C:327
G_UNARY_FUNCTION
#define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc)
Definition: FieldFunctions.C:576
Foam::subtract
void subtract(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:940
Foam::gMinMagSqr
Type gMinMagSqr(const UList< Type > &f, const label comm)
Definition: FieldFunctions.C:591
Foam::gSumMag
typeOfMag< Type >::type gSumMag(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:598
Foam::component
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
Definition: FieldFieldFunctions.C:44
s
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
Definition: gmvOutputSpray.H:25
Foam::cmptMultiply
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
TFOR_ALL_S_OP_FUNC_F_F
#define TFOR_ALL_S_OP_FUNC_F_F(typeS, s, OP, FUNC, typeF1, f1, typeF2, f2)
Definition: FieldM.H:169
Foam::gAverage
Type gAverage(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:604
Foam::innerProduct
Definition: products.H:141
Foam::outerProduct::type
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:114
TMP_UNARY_FUNCTION
#define TMP_UNARY_FUNCTION(ReturnType, Func)
Definition: FieldFunctions.C:350
Foam::dot
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:944
Foam::crossProduct
Definition: products.H:129
undefFieldFunctionsM.H
TFOR_ALL_S_OP_FUNC_F_S
#define TFOR_ALL_S_OP_FUNC_F_S(typeS1, s1, OP, FUNC, typeF, f, typeS2, s2)
Definition: FieldM.H:205
Foam::sumMag
dimensioned< typename typeOfMag< Type >::type > sumMag(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:332
Foam::powProduct::type
symmTypeOfRank< typename pTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank) >::type type
Definition: products.H:170
Foam::gMinMaxMag
scalarMinMax gMinMaxMag(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:596
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::gSum
Type gSum(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:594
BINARY_FUNCTION
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
Definition: DimensionedFieldFunctionsM.C:141
Foam::sumSqr
outerProduct1< Type >::type sumSqr(const UList< Type > &f)
Definition: FieldFunctions.C:505
Foam::sumProd
complex sumProd(const UList< complex > &f1, const UList< complex > &f2)
Sum product.
Definition: complexField.C:191
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::gSumSqr
outerProduct1< Type >::type gSumSqr(const UList< Type > &f, const label comm)
Definition: FieldFunctions.C:597
TFOR_ALL_F_OP_FUNC_F
#define TFOR_ALL_F_OP_FUNC_F(typeF1, f1, OP, FUNC, typeF2, f2)
Definition: FieldM.H:116
Foam::sumCmptMag
Type sumCmptMag(const UList< Type > &f)
Definition: FieldFunctions.C:544
Foam::sumOp
Definition: ops.H:213
Foam::gMaxMagSqr
Type gMaxMagSqr(const UList< Type > &f, const label comm)
Definition: FieldFunctions.C:590
TFOR_ALL_F_OP_F_FUNC
#define TFOR_ALL_F_OP_F_FUNC(typeF1, f1, OP, typeF2, f2, FUNC)
Definition: FieldM.H:132
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Foam::divide
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
Foam::cmptMin
void cmptMin(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:302
Foam::maxMagSqr
Type maxMagSqr(const UList< Type > &f)
Definition: FieldFunctions.C:417
Foam::gSumCmptMag
Type gSumCmptMag(const UList< Type > &f, const label comm)
Definition: FieldFunctions.C:592
Foam::cmptMag
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:400
FieldReuseFunctions.H
Foam::cmptMax
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:253
n
label n
Definition: TABSMDCalcMethod2.H:31
BINARY_TYPE_FUNCTION_FS
#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
Definition: DimensionedFieldFunctionsM.C:329
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:51
Foam::Field::cmptType
pTraits< Type >::cmptType cmptType
Component type.
Definition: Field.H:86
Foam::scalarProduct
Definition: products.H:153
Foam::typeOfSum
Definition: products.H:97
Foam::Field
Generic templated field type.
Definition: Field.H:63
TFOR_ALL_S_OP_FUNC_F
#define TFOR_ALL_S_OP_FUNC_F(typeS, s, OP, FUNC, typeF, f)
Definition: FieldM.H:404
PRODUCT_OPERATOR
#define PRODUCT_OPERATOR(product, Op, OpFunc)
Definition: FieldFunctions.C:689
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::cmptAv
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:246
Foam::scalarProduct::type
pTraits< arg1 >::cmptType type
Definition: products.H:157
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::typeOfMag
The magnitude type for given argument.
Definition: products.H:88
Foam::negate
void negate(FieldField< Field, Type > &res, const FieldField< Field, Type > &f)
Foam::gSumProd
scalarProduct< Type, Type >::type gSumProd(const UList< Type > &f1, const UList< Type > &f2, const label comm)
Definition: FieldFunctions.C:605
Foam::minMaxMag
dimensioned< scalarMinMax > minMaxMag(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:330
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:939
Foam::reuseTmp::New
static tmp< Field< TypeR > > New(const tmp< Field< Type1 >> &tf1)
Definition: FieldReuseFunctions.H:42
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
TFOR_ALL_S_OP_F_OP_F
#define TFOR_ALL_S_OP_F_OP_F(typeS, s, OP1, typeF1, f1, OP2, typeF2, f2)
Definition: FieldM.H:389
BINARY_TYPE_FUNCTION
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)
Definition: DimensionedFieldFunctionsM.C:405
Foam::minMagSqr
Type minMagSqr(const UList< Type > &f)
Definition: FieldFunctions.C:442
PstreamReduceOps.H
Inter-processor communication reduction functions.
TFOR_ALL_F_OP_F_FUNC_S
#define TFOR_ALL_F_OP_F_FUNC_S(typeF1, f1, OP, typeF2, f2, FUNC, typeS, s)
Definition: FieldM.H:251
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::cmptDivide
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::UPstream::msgType
static int & msgType() noexcept
Message tag of standard messages.
Definition: UPstream.H:540
Foam::clip
dimensionSet clip(const dimensionSet &ds1, const dimensionSet &ds2)
Definition: dimensionSet.C:278
Foam::maxMagSqrOp
Definition: ops.H:226
UNARY_OPERATOR
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
Definition: DimensionedFieldFunctionsM.C:87
f
labelList f(nPoints)
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::sumCmptProd
Type sumCmptProd(const UList< Type > &f1, const UList< Type > &f2)
Definition: FieldFunctions.C:482
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::UList< Type >
FieldFunctionsM.C
Foam::outer
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:942
Foam::sum
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:327
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::roots::type
type
Types of root.
Definition: Roots.H:54
Foam::typeOfSolve::type
Type type
Definition: products.H:82
Foam::minMagSqrOp
Definition: ops.H:225
Foam::UList::size
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Foam::minMax
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
Definition: hashSets.C:61
Foam::sumReduce
void sumReduce(T &Value, label &Count, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:133
Foam::gMin
Type gMin(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:593
BINARY_TYPE_OPERATOR_FS
#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Definition: DimensionedFieldFunctionsM.C:599
Foam::multiply
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
Foam::cross
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:943
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328
Foam::outerProduct1
Outer-product of identical types.
Definition: products.H:120
Foam::typeOfMag::type
pTraits< typename pTraits< arg1 >::cmptType >::magType type
Definition: products.H:92
Foam::MinMax
A min/max value pair with additional methods. In addition to conveniently storing values,...
Definition: HashSet.H:76
Foam::outerProduct
Definition: products.H:106
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:592
Foam::gSumCmptProd
Type gSumCmptProd(const UList< Type > &f1, const UList< Type > &f2, const label comm)
Definition: FieldFunctions.C:620
Foam::average
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:328
Foam::gMinMax
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:595
Foam::dotdot
void dotdot(FieldField< Field1, typename scalarProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:945