32 #define TEMPLATE template<class Type> 60 void T(Field<Type>& result,
const UList<Type>& f1)
66 template<
class Type, direction r>
77 resultType, result, =,
pow, Type, f1, resultType,
82 template<
class Type, direction r>
86 const UList<Type>& f1,
91 auto tres = tmp<Field<resultType>>
::New(f1.size());
92 pow<Type, r>(tres.ref(), f1);
96 template<
class Type, direction r>
100 const tmp<Field<Type>>& tf1,
106 pow<Type, r>(tres.ref(), tf1());
116 const UList<Type>& f1
126 sqr(
const UList<Type>& f1)
136 sqr(
const tmp<Field<Type>>& tf1)
140 sqr(tres.ref(), tf1());
150 const UList<Type>& f1
160 magSqr(
const UList<Type>& f1)
171 magSqr(
const tmp<Field<Type>>& tf1)
176 magSqr(tres.ref(), tf1());
186 const UList<Type>& f1
196 mag(
const UList<Type>& f1)
207 mag(
const tmp<Field<Type>>& tf1)
212 mag(tres.ref(), tf1());
222 const UList<Type>& f1
231 tmp<Field<typename Field<Type>::cmptType>>
cmptMax(
const UList<Type>& f1)
240 tmp<Field<typename Field<Type>::cmptType>>
cmptMax(
const tmp<Field<Type>>& tf1)
254 const UList<Type>& f1
263 tmp<Field<typename Field<Type>::cmptType>>
cmptMin(
const UList<Type>& f1)
272 tmp<Field<typename Field<Type>::cmptType>>
cmptMin(
const tmp<Field<Type>>& tf1)
286 const UList<Type>& f1
295 tmp<Field<typename Field<Type>::cmptType>>
cmptAv(
const UList<Type>& f1)
304 tmp<Field<typename Field<Type>::cmptType>>
cmptAv(
const tmp<Field<Type>>& tf1)
321 tmp<Field<Type>>
cmptMag(
const UList<Type>& f1)
329 tmp<Field<Type>>
cmptMag(
const tmp<Field<Type>>& tf1)
331 auto tres =
New(tf1);
345 tmp<Field<Type>>
cmptMagSqr(
const UList<Type>& f1)
353 tmp<Field<Type>>
cmptMagSqr(
const tmp<Field<Type>>& tf1)
362 #define TMP_UNARY_FUNCTION(ReturnType, Func) \ 364 template<class Type> \ 365 ReturnType Func(const tmp<Field<Type>>& tf1) \ 367 ReturnType res = Func(tf1()); \ 388 Type
min(
const UList<Type>& f1)
403 Type
sum(
const UList<Type>& f1)
407 resultType result =
Zero;
485 resultType result =
Zero;
486 if (f1.size() && (f1.size() == f2.size()))
495 Type
sumCmptProd(
const UList<Type>& f1,
const UList<Type>& f2)
498 if (f1.size() && (f1.size() == f2.size()))
518 sumSqr(
const UList<Type>& f1)
522 resultType result =
Zero;
532 sumSqr(
const tmp<Field<Type>>& tf1)
535 resultType result =
sumSqr(tf1());
543 sumMag(
const UList<Type>& f1)
547 resultType result =
Zero;
572 Type
average(
const UList<Type>& f1)
576 Type result =
sum(f1)/f1.size();
582 <<
"empty field, returning zero" <<
endl;
591 #define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc) \ 593 template<class Type> \ 594 ReturnType gFunc(const UList<Type>& f, const label comm) \ 596 ReturnType res = Func(f); \ 597 Foam::reduce(res, rFunc##Op<ReturnType>(), UPstream::msgType(), comm); \ 600 TMP_UNARY_FUNCTION(ReturnType, gFunc) 615 #undef G_UNARY_FUNCTION 636 const UList<Type>& f1,
637 const UList<Type>& f2,
649 const UList<Type>& f1,
653 label
count = f1.size();
654 Type result =
sum(f1);
668 <<
"empty field, returning zero." <<
endl;
679 const UList<scalar>& weights,
680 const UList<Type>&
fld,
687 const label loopLen =
fld.size();
690 for (label i = 0; i < loopLen; ++i)
703 if (weight > ROOTVSMALL)
706 return result/(weight + ROOTVSMALL);
718 const UList<scalar>& weights,
719 const UList<Type>&
fld,
725 const label loopLen =
fld.size();
728 for (label i = 0; i < loopLen; ++i)
743 #undef TMP_UNARY_FUNCTION 778 const UList<Type>& f1,
782 if (result.cdata() == f1.cdata())
792 f1.cbegin(result.size()),
835 #define PRODUCT_OPERATOR(product, Op, OpFunc) \ 837 template<class Type1, class Type2> \ 840 Field<typename product<Type1, Type2>::type>& result, \ 841 const UList<Type1>& f1, \ 842 const UList<Type2>& f2 \ 845 typedef typename product<Type1, Type2>::type resultType; \ 846 TFOR_ALL_F_OP_F_OP_F(resultType, result, =, Type1, f1, Op, Type2, f2) \ 849 template<class Type1, class Type2> \ 850 tmp<Field<typename product<Type1, Type2>::type>> \ 851 operator Op(const UList<Type1>& f1, const UList<Type2>& f2) \ 853 typedef typename product<Type1, Type2>::type resultType; \ 854 auto tres = tmp<Field<resultType>>::New(f1.size()); \ 855 OpFunc(tres.ref(), f1, f2); \ 859 template<class Type1, class Type2> \ 860 tmp<Field<typename product<Type1, Type2>::type>> \ 861 operator Op(const UList<Type1>& f1, const tmp<Field<Type2>>& tf2) \ 863 typedef typename product<Type1, Type2>::type resultType; \ 864 auto tres = reuseTmp<resultType, Type2>::New(tf2); \ 865 OpFunc(tres.ref(), f1, tf2()); \ 870 template<class Type1, class Type2> \ 871 tmp<Field<typename product<Type1, Type2>::type>> \ 872 operator Op(const tmp<Field<Type1>>& tf1, const UList<Type2>& f2) \ 874 typedef typename product<Type1, Type2>::type resultType; \ 875 auto tres = reuseTmp<resultType, Type1>::New(tf1); \ 876 OpFunc(tres.ref(), tf1(), f2); \ 881 template<class Type1, class Type2> \ 882 tmp<Field<typename product<Type1, Type2>::type>> \ 883 operator Op(const tmp<Field<Type1>>& tf1, const tmp<Field<Type2>>& tf2) \ 885 typedef typename product<Type1, Type2>::type resultType; \ 886 auto tres = reuseTmpTmp<resultType, Type1, Type1, Type2>::New(tf1, tf2); \ 887 OpFunc(tres.ref(), tf1(), tf2()); \ 893 template<class Type, class Form, class Cmpt, direction nCmpt> \ 896 Field<typename product<Type, Form>::type>& result, \ 897 const UList<Type>& f1, \ 898 const VectorSpace<Form,Cmpt,nCmpt>& vs \ 901 typedef typename product<Type, Form>::type resultType; \ 902 TFOR_ALL_F_OP_F_OP_S \ 903 (resultType, result, =,Type, f1, Op, Form, static_cast<const Form&>(vs))\ 906 template<class Type, class Form, class Cmpt, direction nCmpt> \ 907 tmp<Field<typename product<Type, Form>::type>> \ 908 operator Op(const UList<Type>& f1, const VectorSpace<Form,Cmpt,nCmpt>& vs) \ 910 typedef typename product<Type, Form>::type resultType; \ 911 auto tres = tmp<Field<resultType>>::New(f1.size()); \ 912 OpFunc(tres.ref(), f1, static_cast<const Form&>(vs)); \ 916 template<class Type, class Form, class Cmpt, direction nCmpt> \ 917 tmp<Field<typename product<Type, Form>::type>> \ 920 const tmp<Field<Type>>& tf1, \ 921 const VectorSpace<Form,Cmpt,nCmpt>& vs \ 924 typedef typename product<Type, Form>::type resultType; \ 925 auto tres = reuseTmp<resultType, Type>::New(tf1); \ 926 OpFunc(tres.ref(), tf1(), static_cast<const Form&>(vs)); \ 931 template<class Form, class Cmpt, direction nCmpt, class Type> \ 934 Field<typename product<Form, Type>::type>& result, \ 935 const VectorSpace<Form,Cmpt,nCmpt>& vs, \ 936 const UList<Type>& f1 \ 939 typedef typename product<Form, Type>::type resultType; \ 940 TFOR_ALL_F_OP_S_OP_F \ 941 (resultType, result, =,Form,static_cast<const Form&>(vs), Op, Type, f1)\ 944 template<class Form, class Cmpt, direction nCmpt, class Type> \ 945 tmp<Field<typename product<Form, Type>::type>> \ 946 operator Op(const VectorSpace<Form,Cmpt,nCmpt>& vs, const UList<Type>& f1) \ 948 typedef typename product<Form, Type>::type resultType; \ 949 auto tres = tmp<Field<resultType>>::New(f1.size()); \ 950 OpFunc(tres.ref(), static_cast<const Form&>(vs), f1); \ 954 template<class Form, class Cmpt, direction nCmpt, class Type> \ 955 tmp<Field<typename product<Form, Type>::type>> \ 958 const VectorSpace<Form,Cmpt,nCmpt>& vs, const tmp<Field<Type>>& tf1 \ 961 typedef typename product<Form, Type>::type resultType; \ 962 auto tres = reuseTmp<resultType, Type>::New(tf1); \ 963 OpFunc(tres.ref(), static_cast<const Form&>(vs), tf1()); \ 976 #undef PRODUCT_OPERATOR void size(const label n)
Older name for setAddressableSize.
Type gWeightedAverage(const UList< scalar > &weights, const UList< Type > &fld, const label comm)
The global weighted average of a field, using the mag() of the weights.
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 divide(DimensionedField< Type, GeoMesh > &result, const DimensionedField< Type, GeoMesh > &f1, const DimensionedField< scalar, GeoMesh > &f2)
Inter-processor communication reduction functions.
Type gWeightedSum(const UList< scalar > &weights, const UList< Type > &fld, const label comm)
The global weighted sum (integral) of a field, using the mag() of the weights.
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &f1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
#define TMP_UNARY_FUNCTION(ReturnType, Func)
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)
pTraits< Type >::cmptType cmptType
Component type.
A min/max value pair with additional methods. In addition to conveniently storing values...
Type minMagSqr(const UList< Type > &f1)
Outer-product of identical types.
scalarProduct< Type, Type >::type gSumProd(const UList< Type > &f1, const UList< Type > &f2, const label comm)
#define BINARY_TYPE_OPERATOR_SF(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#define TFOR_ALL_F_OP_F_FUNC(typeF1, f1, OP, typeF2, f2, FUNC)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static tmp< Field< TypeR > > New(const Field< Type1 > &f1)
Pass-through to tmp New.
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.
Type gSumCmptMag(const UList< Type > &f, const label comm)
void clamp_range(const Type &lower, const Type &upper)
Clamp field values (in-place) to the specified range.
#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)
static int & msgType() noexcept
Message tag of standard messages.
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
#define BINARY_TYPE_FUNCTION(ReturnType, Type1, Type2, Func)
#define TFOR_ALL_F_OP_FUNC_F(typeF1, f1, OP, FUNC, typeF2, f2)
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)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
Type maxMagSqr(const UList< Type > &f1)
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 > &)
complex sumProd(const UList< complex > &f1, const UList< complex > &f2)
Sum product.
void reduce(T &value, [[maybe_unused]] BinaryOp bop, [[maybe_unused]] const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce)
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
Type gMaxMagSqr(const UList< Type > &f, const label comm)
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1, const label comm)
dimensioned< scalarMinMax > minMaxMag(const DimensionedField< Type, GeoMesh > &f1, const label comm)
#define TFOR_ALL_S_OP_FUNC_F(typeS, s, OP, FUNC, typeF, f)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Type gMinMagSqr(const UList< Type > &f, const label comm)
outerProduct1< Type >::type sumSqr(const UList< Type > &f1)
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Type gSumCmptProd(const UList< Type > &f1, const UList< Type > &f2, const label comm)
Unary function for applying component-wise clamping.
Type gSum(const FieldField< Field, Type > &f)
void cmptMagSqr(Field< Type > &result, const UList< Type > &f1)
Generic templated field type.
#define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc)
#define TFOR_ALL_S_OP_FUNC_F_S(typeS1, s1, OP, FUNC, typeF, f, typeS2, s2)
#define TFOR_ALL_S_OP_FUNC_F_F(typeS, s, OP, FUNC, typeF1, f1, typeF2, f2)
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
pTraits< arg1 >::cmptType type
Type sumCmptMag(const UList< Type > &f1)
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.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
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)
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
Type gMax(const FieldField< Field, Type > &f)
#define TFOR_ALL_S_OP_F_OP_F(typeS, s, OP1, typeF1, f1, OP2, typeF2, f2)
outerProduct1< Type >::type gSumSqr(const UList< Type > &f, const label comm)
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)
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;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Represents 0/1 range or concept. Used for tagged dispatch or clamping.
symmTypeOfRank< typename pTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank) >::type type
dimensioned< typename typeOfMag< Type >::type > sumMag(const DimensionedField< Type, GeoMesh > &f1, const label comm)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
#define WarningInFunction
Report a warning using Foam::Warning.
#define TFOR_ALL_F_OP_F_FUNC_S(typeF1, f1, OP, typeF2, f2, FUNC, typeS, s)
#define BINARY_FUNCTION_INTERFACE_FS(ReturnType, Type1, Type2, Func)
void sumReduce(T &value, CountType &count, [[maybe_unused]] const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) the sum of value and counter (eg, for averaging) ...
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing the constant UList.
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
const Type * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
#define TERNARY_TYPE_FUNCTION_FFS(ReturnType, Type1, Type2, Type3, Func)
A class for managing temporary objects.
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)
#define PRODUCT_OPERATOR(product, Op, OpFunc)
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
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
#define TFOR_ALL_F_OP_FUNC_F_S(typeF1, f1, OP, FUNC, typeF2, f2, typeS, s)
static constexpr const zero Zero
Global zero (0)