32#define TEMPLATE template<template<class> class Field, class Type>
42template<
template<
class>
class Field,
class Type>
50 const label loopLen = (sf).size();
52 for (label i = 0; i < loopLen; ++i)
59template<
template<
class>
class Field,
class Type>
62 const label loopLen = (f1).size();
64 for (label i = 0; i < loopLen; ++i)
78 const label loopLen = (
f).size();
80 for (label i = 0; i < loopLen; ++i)
101template<
template<
class>
class Field,
class Type,
direction r>
102tmp<FieldField<Field, typename powProduct<Type, r>::type>>
118template<
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)
133template<
template<
class>
class Field,
class Type>
145template<
template<
class>
class Field,
class Type>
146tmp<FieldField<Field, typename outerProduct<Type, Type>::type>>
147sqr(
const tmp<FieldField<Field, Type>>& tf)
159template<
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)
174template<
template<
class>
class Field,
class Type>
186template<
template<
class>
class Field,
class Type>
187tmp<FieldField<Field, typename typeOfMag<Type>::type>>
188magSqr(
const tmp<FieldField<Field, Type>>& tf)
200template<
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)
215template<
template<
class>
class Field,
class Type>
227template<
template<
class>
class Field,
class Type>
228tmp<FieldField<Field, typename typeOfMag<Type>::type>>
229mag(
const tmp<FieldField<Field, Type>>& tf)
241template<
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)
256template<
template<
class>
class Field,
class Type>
270template<
template<
class>
class Field,
class Type>
271tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>>
cmptMax
273 const tmp<FieldField<Field, Type>>& tf
286template<
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)
301template<
template<
class>
class Field,
class Type>
315template<
template<
class>
class Field,
class Type>
316tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>>
cmptMin
318 const tmp<FieldField<Field, Type>>& tf
331template<
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)
346template<
template<
class>
class Field,
class Type>
360template<
template<
class>
class Field,
class Type>
361tmp<FieldField<Field, typename FieldField<Field, Type>::cmptType>>
cmptAv
363 const tmp<FieldField<Field, Type>>& tf
376template<
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)
391template<
template<
class>
class Field,
class Type>
403template<
template<
class>
class Field,
class Type>
404tmp<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) \
418template<template<class> class Field, class Type> \
419ReturnType Func(const tmp<FieldField<Field, Type>>& tf1) \
421 ReturnType res = Func(tf1()); \
426template<
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);
448template<
template<
class>
class Field,
class Type>
449Type
min(
const FieldField<Field, Type>&
f)
451 Type result = pTraits<Type>::max;
453 const label loopLen = (
f).size();
455 for (label i = 0; i < loopLen; ++i)
469template<
template<
class>
class Field,
class Type>
470Type
sum(
const FieldField<Field, Type>&
f)
474 const label loopLen = (
f).size();
476 for (label i = 0; i < loopLen; ++i)
486template<
template<
class>
class Field,
class Type>
491 resultType result =
Zero;
493 const label loopLen = (
f).size();
495 for (label i = 0; i < loopLen; ++i)
505template<
template<
class>
class Field,
class Type>
506Type
average(
const FieldField<Field, Type>&
f)
511 const label loopLen = (
f).size();
513 for (label i = 0; i < loopLen; ++i)
515 const label
n =
f[i].size();
529 <<
"empty fieldField, returning zero" <<
endl;
537template<
template<
class>
class Field,
class Type>
538MinMax<Type>
minMax(
const FieldField<Field, Type>&
f)
542 const label loopLen = (
f).size();
544 for (label i = 0; i < loopLen; ++i)
554template<
template<
class>
class Field,
class Type>
559 const label loopLen = (
f).size();
561 for (label i = 0; i < loopLen; ++i)
573#define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc) \
575template<template<class> class Field, class Type> \
576ReturnType gFunc(const FieldField<Field, Type>& f) \
578 ReturnType res = Func(f); \
579 reduce(res, rFunc##Op<ReturnType>()); \
582TMP_UNARY_FUNCTION(ReturnType, gFunc)
592#undef G_UNARY_FUNCTION
595template<
template<
class>
class Field,
class Type>
605 const label loopLen = (
f).size();
607 for (label i = 0; i < loopLen; ++i)
609 const label
n =
f[i].size();
629 <<
"Empty FieldField, returning zero" <<
endl;
636#undef TMP_UNARY_FUNCTION
675#define PRODUCT_OPERATOR(product, Op, OpFunc) \
679 template<class> class Field1, \
680 template<class> class Field2, \
686 FieldField<Field1, typename product<Type1, Type2>::type>& f, \
687 const FieldField<Field1, Type1>& f1, \
688 const FieldField<Field2, Type2>& f2 \
691 const label loopLen = (f).size(); \
693 for (label i = 0; i < loopLen; ++i) \
695 OpFunc(f[i], f1[i], f2[i]); \
701 template<class> class Field1, \
702 template<class> class Field2, \
706tmp<FieldField<Field1, typename product<Type1, Type2>::type>> \
709 const FieldField<Field1, Type1>& f1, \
710 const FieldField<Field2, Type2>& f2 \
713 typedef typename product<Type1, Type2>::type resultType; \
714 auto tres = FieldField<Field1, resultType>::NewCalculatedType(f1); \
715 OpFunc(tres.ref(), f1, f2); \
719template<template<class> class Field, class Type1, class Type2> \
720tmp<FieldField<Field, typename product<Type1, Type2>::type>> \
723 const FieldField<Field, Type1>& f1, \
724 const tmp<FieldField<Field, Type2>>& tf2 \
727 typedef typename product<Type1, Type2>::type resultType; \
728 auto tres = reuseTmpFieldField<Field, resultType, Type2>::New(tf2); \
729 OpFunc(tres.ref(), f1, tf2()); \
736 template<class> class Field1, \
737 template<class> class Field2, \
741tmp<FieldField<Field, typename product<Type1, Type2>::type>> \
744 const FieldField<Field1, Type1>& f1, \
745 const tmp<FieldField<Field2, Type2>>& tf2 \
748 typedef typename product<Type1, Type2>::type resultType; \
749 auto tres = FieldField<Field1, resultType>::NewCalculatedType(f1); \
750 OpFunc(tres.ref(), f1, tf2()); \
757 template<class> class Field1, \
758 template<class> class Field2, \
762tmp<FieldField<Field1, typename product<Type1, Type2>::type>> \
765 const tmp<FieldField<Field1, Type1>>& tf1, \
766 const FieldField<Field2, Type2>& f2 \
769 typedef typename product<Type1, Type2>::type resultType; \
770 auto tres = reuseTmpFieldField<Field1, resultType, Type1>::New(tf1); \
771 OpFunc(tres.ref(), tf1(), f2); \
778 template<class> class Field1, \
779 template<class> class Field2, \
783tmp<FieldField<Field1, typename product<Type1, Type2>::type>> \
786 const tmp<FieldField<Field1, Type1>>& tf1, \
787 const tmp<FieldField<Field2, Type2>>& tf2 \
790 typedef typename product<Type1, Type2>::type resultType; \
793 reuseTmpTmpFieldField<Field1, resultType, Type1, Type1, Type2>::New \
796 OpFunc(tres.ref(), tf1(), tf2()); \
804 template<class> class Field, \
812 FieldField<Field, typename product<Type, Form>::type>& result, \
813 const FieldField<Field, Type>& f1, \
814 const VectorSpace<Form,Cmpt,nCmpt>& vs \
817 const label loopLen = (result).size(); \
819 for (label i = 0; i < loopLen; ++i) \
821 OpFunc(result[i], f1[i], vs); \
827 template<class> class Field, \
833tmp<FieldField<Field, typename product<Type, Form>::type>> \
836 const FieldField<Field, Type>& f1, \
837 const VectorSpace<Form,Cmpt,nCmpt>& vs \
840 typedef typename product<Type, Form>::type resultType; \
841 auto tres = FieldField<Field, resultType>::NewCalculatedType(f1); \
842 OpFunc(tres.ref(), f1, static_cast<const Form&>(vs)); \
848 template<class> class Field, \
854tmp<FieldField<Field, typename product<Type, Form>::type>> \
857 const tmp<FieldField<Field, Type>>& tf1, \
858 const VectorSpace<Form,Cmpt,nCmpt>& vs \
861 typedef typename product<Type, Form>::type resultType; \
862 auto tres = reuseTmpFieldField<Field, resultType, Type>::New(tf1); \
863 OpFunc(tres.ref(), tf1(), static_cast<const Form&>(vs)); \
870 template<class> class Field, \
878 FieldField<Field, typename product<Form, Type>::type>& result, \
879 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
880 const FieldField<Field, Type>& f1 \
883 const label loopLen = (result).size(); \
885 for (label i = 0; i < loopLen; ++i) \
887 OpFunc(result[i], vs, f1[i]); \
893 template<class> class Field, \
899tmp<FieldField<Field, typename product<Form, Type>::type>> \
902 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
903 const FieldField<Field, Type>& f1 \
906 typedef typename product<Form, Type>::type resultType; \
907 auto tres = FieldField<Field, resultType>::NewCalculatedType(f1); \
908 OpFunc(tres.ref(), static_cast<const Form&>(vs), f1); \
914 template<class> class Field, \
920tmp<FieldField<Field, typename product<Form, Type>::type>> \
923 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
924 const tmp<FieldField<Field, Type>>& tf1 \
927 typedef typename product<Form, Type>::type resultType; \
928 auto tres = reuseTmpFieldField<Field, resultType, Type>::New(tf1); \
929 OpFunc(tres.ref(), static_cast<const Form&>(vs), tf1()); \
942#undef PRODUCT_OPERATOR
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
#define BINARY_TYPE_FUNCTION_FS(ReturnType, Type1, Type2, Func)
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#define TERNARY_FUNCTION(ReturnType, Type1, Type2, Type3, Func)
#define TERNARY_TYPE_FUNCTION_FFS(ReturnType, Type1, Type2, Type3, Func)
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#define BINARY_TYPE_OPERATOR_FS(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)
#define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc)
#define TMP_UNARY_FUNCTION(ReturnType, Func)
Inter-processor communication reduction functions.
A field of fields is a PtrList of fields with reference counting.
static tmp< FieldField< Field, Type > > NewCalculatedType(const FieldField< Field, Type2 > &ff)
Return a pointer to a new calculatedFvPatchFieldField created on.
pTraits< Type >::cmptType cmptType
Component type.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
A min/max value pair with additional methods. In addition to conveniently storing values,...
static int & msgType() noexcept
Message tag of standard messages.
typeOfRank< typenamepTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank)>::type type
A traits class, which is primarily used for primitives and vector-space.
symmTypeOfRank< typenamepTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank)>::type type
A class for managing temporary objects.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
The magnitude type for given argument.
pTraits< typenamepTraits< arg1 >::cmptType >::magType type
#define PRODUCT_OPERATOR(product, op, opFunc)
#define WarningInFunction
Report a warning using Foam::Warning.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
dimensioned< scalarMinMax > minMaxMag(const DimensionedField< Type, GeoMesh > &f1, const label comm)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
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.
Type gSum(const FieldField< Field, Type > &f)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void subtract(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
void cmptMin(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
void divide(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
MinMax< scalar > scalarMinMax
A scalar min/max range.
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
scalarMinMax gMinMaxMag(const FieldField< Field, Type > &f)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void add(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh > > cmptAv(const DimensionedField< Type, GeoMesh > &f1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
static constexpr const zero Zero
Global zero (0).
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
typeOfMag< Type >::type gSumMag(const FieldField< Field, Type > &f)
void dotdot(FieldField< Field1, typename scalarProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void sumReduce(T &value, CountType &count, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) the sum of value and counter (eg, for averaging).
Type gMin(const FieldField< Field, Type > &f)
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
void cross(FieldField< Field1, typename crossProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void negate(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1)
void multiply(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1, const label comm)
Type gMax(const FieldField< Field, Type > &f)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< Type > lerp(const dimensioned< Type > &a, const dimensioned< Type > &b, const scalar t)
dimensioned< typename typeOfMag< Type >::type > sumMag(const DimensionedField< Type, GeoMesh > &f1, const label comm)
static tmp< FieldField< Field, TypeR > > New(const FieldField< Field, Type1 > &f1)
Pass-through to NewCalculatedType.