32 #define TEMPLATE template<template<class> class Field, class Type> 42 template<
template<
class>
class Field,
class Type>
50 const label loopLen = (sf).size();
52 for (label i = 0; i < loopLen; ++i)
59 template<
template<
class>
class Field,
class Type>
60 void T(FieldField<Field, Type>& f1,
const FieldField<Field, Type>& f2)
62 const label loopLen = (f1).size();
64 for (label i = 0; i < loopLen; ++i)
71 template<
template<
class>
class Field,
class Type,
direction r>
75 const FieldField<Field, Type>& vf
78 const label loopLen = (
f).size();
80 for (label i = 0; i < loopLen; ++i)
86 template<
template<
class>
class Field,
class Type,
direction r>
97 pow<Type, r>(tres.ref(),
f);
101 template<
template<
class>
class Field,
class Type,
direction r>
112 pow<Type, r>(tres.ref(), tf());
118 template<
template<
class>
class Field,
class Type>
122 const FieldField<Field, Type>& vf
125 const label loopLen = (
f).size();
127 for (label i = 0; i < loopLen; ++i)
133 template<
template<
class>
class Field,
class Type>
135 sqr(
const FieldField<Field, Type>&
f)
145 template<
template<
class>
class Field,
class Type>
147 sqr(
const tmp<FieldField<Field, Type>>& tf)
153 sqr(tres.ref(), tf());
159 template<
template<
class>
class Field,
class Type>
163 const FieldField<Field, Type>&
f 166 const label loopLen = (sf).size();
168 for (label i = 0; i < loopLen; ++i)
174 template<
template<
class>
class Field,
class Type>
176 magSqr(
const FieldField<Field, Type>&
f)
186 template<
template<
class>
class Field,
class Type>
188 magSqr(
const tmp<FieldField<Field, Type>>& tf)
200 template<
template<
class>
class Field,
class Type>
204 const FieldField<Field, Type>&
f 207 const label loopLen = (sf).size();
209 for (label i = 0; i < loopLen; ++i)
215 template<
template<
class>
class Field,
class Type>
217 mag(
const FieldField<Field, Type>&
f)
227 template<
template<
class>
class Field,
class Type>
229 mag(
const tmp<FieldField<Field, Type>>& tf)
235 mag(tres.ref(), tf());
241 template<
template<
class>
class Field,
class Type>
245 const FieldField<Field, Type>&
f 248 const label loopLen = (cf).size();
250 for (label i = 0; i < loopLen; ++i)
256 template<
template<
class>
class Field,
class Type>
257 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>>
cmptMax 259 const FieldField<Field, Type>&
f 270 template<
template<
class>
class Field,
class Type>
271 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>>
cmptMax 273 const tmp<FieldField<Field, Type>>& tf
286 template<
template<
class>
class Field,
class Type>
290 const FieldField<Field, Type>&
f 293 const label loopLen = (cf).size();
295 for (label i = 0; i < loopLen; ++i)
301 template<
template<
class>
class Field,
class Type>
302 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>>
cmptMin 304 const FieldField<Field, Type>&
f 315 template<
template<
class>
class Field,
class Type>
316 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>>
cmptMin 318 const tmp<FieldField<Field, Type>>& tf
331 template<
template<
class>
class Field,
class Type>
335 const FieldField<Field, Type>&
f 338 const label loopLen = (cf).size();
340 for (label i = 0; i < loopLen; ++i)
346 template<
template<
class>
class Field,
class Type>
347 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>>
cmptAv 349 const FieldField<Field, Type>&
f 360 template<
template<
class>
class Field,
class Type>
361 tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>>
cmptAv 363 const tmp<FieldField<Field, Type>>& tf
376 template<
template<
class>
class Field,
class Type>
379 FieldField<Field, Type>& cf,
380 const FieldField<Field, Type>&
f 383 const label loopLen = (cf).size();
385 for (label i = 0; i < loopLen; ++i)
391 template<
template<
class>
class Field,
class Type>
392 tmp<FieldField<Field, Type>>
cmptMag 394 const FieldField<Field, Type>&
f 403 template<
template<
class>
class Field,
class Type>
404 tmp<FieldField<Field, Type>>
cmptMag 406 const tmp<FieldField<Field, Type>>& tf
409 tmp<FieldField<Field, Type>> tres(
New(tf));
416 #define TMP_UNARY_FUNCTION(ReturnType, Func) \ 418 template<template<class> class Field, class Type> \ 419 ReturnType Func(const tmp<FieldField<Field, Type>>& tf1) \ 421 ReturnType res = Func(tf1()); \ 426 template<
template<
class>
class Field,
class Type>
431 const label loopLen = (
f).size();
433 for (label i = 0; i < loopLen; ++i)
437 result =
max(
max(
f[i]), result);
448 template<
template<
class>
class Field,
class Type>
449 Type
min(
const FieldField<Field, Type>&
f)
453 const label loopLen = (
f).size();
455 for (label i = 0; i < loopLen; ++i)
469 template<
template<
class>
class Field,
class Type>
470 Type
sum(
const FieldField<Field, Type>&
f)
474 const label loopLen = (
f).size();
476 for (label i = 0; i < loopLen; ++i)
486 template<
template<
class>
class Field,
class Type>
491 resultType result =
Zero;
493 const label loopLen = (
f).size();
495 for (label i = 0; i < loopLen; ++i)
505 template<
template<
class>
class Field,
class Type>
506 Type
average(
const FieldField<Field, Type>&
f)
510 const label loopLen = (
f).size();
512 for (label i = 0; i < loopLen; ++i)
519 Type avrg =
sum(
f)/
n;
525 <<
"empty fieldField, returning zero" <<
endl;
533 template<
template<
class>
class Field,
class Type>
534 MinMax<Type>
minMax(
const FieldField<Field, Type>&
f)
538 const label loopLen = (
f).size();
540 for (label i = 0; i < loopLen; ++i)
550 template<
template<
class>
class Field,
class Type>
555 const label loopLen = (
f).size();
557 for (label i = 0; i < loopLen; ++i)
569 #define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc) \ 571 template<template<class> class Field, class Type> \ 572 ReturnType gFunc(const FieldField<Field, Type>& f) \ 574 ReturnType res = Func(f); \ 575 reduce(res, rFunc##Op<ReturnType>()); \ 578 TMP_UNARY_FUNCTION(ReturnType, gFunc) 588 #undef G_UNARY_FUNCTION 591 template<
template<
class>
class Field,
class Type>
596 const label loopLen = (
f).size();
598 for (label i = 0; i < loopLen; ++i)
613 <<
"Empty FieldField, returning zero" <<
endl;
620 #undef TMP_UNARY_FUNCTION 659 #define PRODUCT_OPERATOR(product, Op, OpFunc) \ 663 template<class> class Field1, \ 664 template<class> class Field2, \ 670 FieldField<Field1, typename product<Type1, Type2>::type>& f, \ 671 const FieldField<Field1, Type1>& f1, \ 672 const FieldField<Field2, Type2>& f2 \ 675 const label loopLen = (f).size(); \ 677 for (label i = 0; i < loopLen; ++i) \ 679 OpFunc(f[i], f1[i], f2[i]); \ 685 template<class> class Field1, \ 686 template<class> class Field2, \ 690 tmp<FieldField<Field1, typename product<Type1, Type2>::type>> \ 693 const FieldField<Field1, Type1>& f1, \ 694 const FieldField<Field2, Type2>& f2 \ 697 typedef typename product<Type1, Type2>::type resultType; \ 698 auto tres = FieldField<Field1, resultType>::NewCalculatedType(f1); \ 699 OpFunc(tres.ref(), f1, f2); \ 703 template<template<class> class Field, class Type1, class Type2> \ 704 tmp<FieldField<Field, typename product<Type1, Type2>::type>> \ 707 const FieldField<Field, Type1>& f1, \ 708 const tmp<FieldField<Field, Type2>>& tf2 \ 711 typedef typename product<Type1, Type2>::type resultType; \ 712 auto tres = reuseTmpFieldField<Field, resultType, Type2>::New(tf2); \ 713 OpFunc(tres.ref(), f1, tf2()); \ 720 template<class> class Field1, \ 721 template<class> class Field2, \ 725 tmp<FieldField<Field, typename product<Type1, Type2>::type>> \ 728 const FieldField<Field1, Type1>& f1, \ 729 const tmp<FieldField<Field2, Type2>>& tf2 \ 732 typedef typename product<Type1, Type2>::type resultType; \ 733 auto tres = FieldField<Field1, resultType>::NewCalculatedType(f1); \ 734 OpFunc(tres.ref(), f1, tf2()); \ 741 template<class> class Field1, \ 742 template<class> class Field2, \ 746 tmp<FieldField<Field1, typename product<Type1, Type2>::type>> \ 749 const tmp<FieldField<Field1, Type1>>& tf1, \ 750 const FieldField<Field2, Type2>& f2 \ 753 typedef typename product<Type1, Type2>::type resultType; \ 754 auto tres = reuseTmpFieldField<Field1, resultType, Type1>::New(tf1); \ 755 OpFunc(tres.ref(), tf1(), f2); \ 762 template<class> class Field1, \ 763 template<class> class Field2, \ 767 tmp<FieldField<Field1, typename product<Type1, Type2>::type>> \ 770 const tmp<FieldField<Field1, Type1>>& tf1, \ 771 const tmp<FieldField<Field2, Type2>>& tf2 \ 774 typedef typename product<Type1, Type2>::type resultType; \ 777 reuseTmpTmpFieldField<Field1, resultType, Type1, Type1, Type2>::New \ 780 OpFunc(tres.ref(), tf1(), tf2()); \ 788 template<class> class Field, \ 796 FieldField<Field, typename product<Type, Form>::type>& result, \ 797 const FieldField<Field, Type>& f1, \ 798 const VectorSpace<Form,Cmpt,nCmpt>& vs \ 801 const label loopLen = (result).size(); \ 803 for (label i = 0; i < loopLen; ++i) \ 805 OpFunc(result[i], f1[i], vs); \ 811 template<class> class Field, \ 817 tmp<FieldField<Field, typename product<Type, Form>::type>> \ 820 const FieldField<Field, Type>& f1, \ 821 const VectorSpace<Form,Cmpt,nCmpt>& vs \ 824 typedef typename product<Type, Form>::type resultType; \ 825 auto tres = FieldField<Field, resultType>::NewCalculatedType(f1); \ 826 OpFunc(tres.ref(), f1, static_cast<const Form&>(vs)); \ 832 template<class> class Field, \ 838 tmp<FieldField<Field, typename product<Type, Form>::type>> \ 841 const tmp<FieldField<Field, Type>>& tf1, \ 842 const VectorSpace<Form,Cmpt,nCmpt>& vs \ 845 typedef typename product<Type, Form>::type resultType; \ 846 auto tres = reuseTmpFieldField<Field, resultType, Type>::New(tf1); \ 847 OpFunc(tres.ref(), tf1(), static_cast<const Form&>(vs)); \ 854 template<class> class Field, \ 862 FieldField<Field, typename product<Form, Type>::type>& result, \ 863 const VectorSpace<Form,Cmpt,nCmpt>& vs, \ 864 const FieldField<Field, Type>& f1 \ 867 const label loopLen = (result).size(); \ 869 for (label i = 0; i < loopLen; ++i) \ 871 OpFunc(result[i], vs, f1[i]); \ 877 template<class> class Field, \ 883 tmp<FieldField<Field, typename product<Form, Type>::type>> \ 886 const VectorSpace<Form,Cmpt,nCmpt>& vs, \ 887 const FieldField<Field, Type>& f1 \ 890 typedef typename product<Form, Type>::type resultType; \ 891 auto tres = FieldField<Field, resultType>::NewCalculatedType(f1); \ 892 OpFunc(tres.ref(), static_cast<const Form&>(vs), f1); \ 898 template<class> class Field, \ 904 tmp<FieldField<Field, typename product<Form, Type>::type>> \ 907 const VectorSpace<Form,Cmpt,nCmpt>& vs, \ 908 const tmp<FieldField<Field, Type>>& tf1 \ 911 typedef typename product<Form, Type>::type resultType; \ 912 auto tres = reuseTmpFieldField<Field, resultType, Type>::New(tf1); \ 913 OpFunc(tres.ref(), static_cast<const Form&>(vs), tf1()); \ 926 #undef PRODUCT_OPERATOR dimensioned< typename typeOfMag< Type >::type > sumMag(const DimensionedField< Type, GeoMesh > &f1)
void size(const label n)
Older name for setAddressableSize.
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
void divide(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
Inter-processor communication reduction functions.
MinMax< scalar > scalarMinMax
A scalar min/max range.
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &f1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Type gMin(const FieldField< Field, Type > &f)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
A min/max value pair with additional methods. In addition to conveniently storing values...
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A traits class, which is primarily used for primitives and vector-space.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
The magnitude type for given argument.
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
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)
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)
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)
A field of fields is a PtrList of fields with reference counting.
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Type gSum(const FieldField< Field, Type > &f)
Generic templated field type.
Type max(const tmp< FieldField< Field, Type >> &tf1)
#define TMP_UNARY_FUNCTION(ReturnType, Func)
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
void negate(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
static tmp< FieldField< Field, Type > > NewCalculatedType(const FieldField< Field, Type2 > &ff)
Return a pointer to a new calculatedFvPatchFieldField created on.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
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 G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc)
scalarMinMax gMinMaxMag(const FieldField< Field, Type > &f)
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
typeOfMag< Type >::type gSumMag(const FieldField< Field, Type > &f)
symmTypeOfRank< typename pTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank) >::type type
#define PRODUCT_OPERATOR(product, Op, OpFunc)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
pTraits< Type >::cmptType cmptType
Component type.
dimensioned< scalarMinMax > minMaxMag(const DimensionedField< Type, GeoMesh > &f1)
#define WarningInFunction
Report a warning using Foam::Warning.
Type gAverage(const FieldField< Field, Type > &f)
BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax< Type >, clip)
static tmp< FieldField< Field, TypeR > > New(const FieldField< Field, Type1 > &f1)
Pass-through to NewCalculatedType.
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
#define TERNARY_TYPE_FUNCTION_FFS(ReturnType, Type1, Type2, Type3, Func)
void cmptMin(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
void multiply(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
#define TERNARY_FUNCTION(ReturnType, Type1, Type2, Type3, Func)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
pTraits< typename pTraits< arg1 >::cmptType >::magType type
static constexpr const zero Zero
Global zero (0)