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 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,
665 <<
"empty field, returning zero." <<
endl;
672 #undef TMP_UNARY_FUNCTION 707 const UList<Type>& f1,
711 if (result.cdata() == f1.cdata())
721 f1.cbegin(result.size()),
766 #define PRODUCT_OPERATOR(product, Op, OpFunc) \ 768 template<class Type1, class Type2> \ 771 Field<typename product<Type1, Type2>::type>& result, \ 772 const UList<Type1>& f1, \ 773 const UList<Type2>& f2 \ 776 typedef typename product<Type1, Type2>::type resultType; \ 777 TFOR_ALL_F_OP_F_OP_F(resultType, result, =, Type1, f1, Op, Type2, f2) \ 780 template<class Type1, class Type2> \ 781 tmp<Field<typename product<Type1, Type2>::type>> \ 782 operator Op(const UList<Type1>& f1, const UList<Type2>& f2) \ 784 typedef typename product<Type1, Type2>::type resultType; \ 785 auto tres = tmp<Field<resultType>>::New(f1.size()); \ 786 OpFunc(tres.ref(), f1, f2); \ 790 template<class Type1, class Type2> \ 791 tmp<Field<typename product<Type1, Type2>::type>> \ 792 operator Op(const UList<Type1>& f1, const tmp<Field<Type2>>& tf2) \ 794 typedef typename product<Type1, Type2>::type resultType; \ 795 auto tres = reuseTmp<resultType, Type2>::New(tf2); \ 796 OpFunc(tres.ref(), f1, tf2()); \ 801 template<class Type1, class Type2> \ 802 tmp<Field<typename product<Type1, Type2>::type>> \ 803 operator Op(const tmp<Field<Type1>>& tf1, const UList<Type2>& f2) \ 805 typedef typename product<Type1, Type2>::type resultType; \ 806 auto tres = reuseTmp<resultType, Type1>::New(tf1); \ 807 OpFunc(tres.ref(), tf1(), f2); \ 812 template<class Type1, class Type2> \ 813 tmp<Field<typename product<Type1, Type2>::type>> \ 814 operator Op(const tmp<Field<Type1>>& tf1, const tmp<Field<Type2>>& tf2) \ 816 typedef typename product<Type1, Type2>::type resultType; \ 817 auto tres = reuseTmpTmp<resultType, Type1, Type1, Type2>::New(tf1, tf2); \ 818 OpFunc(tres.ref(), tf1(), tf2()); \ 824 template<class Type, class Form, class Cmpt, direction nCmpt> \ 827 Field<typename product<Type, Form>::type>& result, \ 828 const UList<Type>& f1, \ 829 const VectorSpace<Form,Cmpt,nCmpt>& vs \ 832 typedef typename product<Type, Form>::type resultType; \ 833 TFOR_ALL_F_OP_F_OP_S \ 834 (resultType, result, =,Type, f1, Op, Form, static_cast<const Form&>(vs))\ 837 template<class Type, class Form, class Cmpt, direction nCmpt> \ 838 tmp<Field<typename product<Type, Form>::type>> \ 839 operator Op(const UList<Type>& f1, const VectorSpace<Form,Cmpt,nCmpt>& vs) \ 841 typedef typename product<Type, Form>::type resultType; \ 842 auto tres = tmp<Field<resultType>>::New(f1.size()); \ 843 OpFunc(tres.ref(), f1, static_cast<const Form&>(vs)); \ 847 template<class Type, class Form, class Cmpt, direction nCmpt> \ 848 tmp<Field<typename product<Type, Form>::type>> \ 851 const tmp<Field<Type>>& tf1, \ 852 const VectorSpace<Form,Cmpt,nCmpt>& vs \ 855 typedef typename product<Type, Form>::type resultType; \ 856 auto tres = reuseTmp<resultType, Type>::New(tf1); \ 857 OpFunc(tres.ref(), tf1(), static_cast<const Form&>(vs)); \ 862 template<class Form, class Cmpt, direction nCmpt, class Type> \ 865 Field<typename product<Form, Type>::type>& result, \ 866 const VectorSpace<Form,Cmpt,nCmpt>& vs, \ 867 const UList<Type>& f1 \ 870 typedef typename product<Form, Type>::type resultType; \ 871 TFOR_ALL_F_OP_S_OP_F \ 872 (resultType, result, =,Form,static_cast<const Form&>(vs), Op, Type, f1)\ 875 template<class Form, class Cmpt, direction nCmpt, class Type> \ 876 tmp<Field<typename product<Form, Type>::type>> \ 877 operator Op(const VectorSpace<Form,Cmpt,nCmpt>& vs, const UList<Type>& f1) \ 879 typedef typename product<Form, Type>::type resultType; \ 880 auto tres = tmp<Field<resultType>>::New(f1.size()); \ 881 OpFunc(tres.ref(), static_cast<const Form&>(vs), f1); \ 885 template<class Form, class Cmpt, direction nCmpt, class Type> \ 886 tmp<Field<typename product<Form, Type>::type>> \ 889 const VectorSpace<Form,Cmpt,nCmpt>& vs, const tmp<Field<Type>>& tf1 \ 892 typedef typename product<Form, Type>::type resultType; \ 893 auto tres = reuseTmp<resultType, Type>::New(tf1); \ 894 OpFunc(tres.ref(), static_cast<const Form&>(vs), tf1()); \ 907 #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.
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...
void sumReduce(T &value, label &count, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) the sum of both value and count (for averaging) ...
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.
void clip(Field< Type > &result, const UList< Type > &f1, const MinMax< Type > &s2)
#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)
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.
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)
#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)
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)
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)
Represents 0/1 range or concept. Used for tagged dispatch or clamping.
symmTypeOfRank< typename pTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank) >::type type
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensioned< scalarMinMax > minMaxMag(const DimensionedField< Type, GeoMesh > &f1)
#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)
#define BINARY_FUNCTION_INTERFACE_FS(ReturnType, Type1, Type2, Func)
BINARY_TYPE_FUNCTION_FS(Type, Type, MinMax< Type >, clip)
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)
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))
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
#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)
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
#define TFOR_ALL_F_OP_FUNC_F_S(typeF1, f1, OP, FUNC, typeF2, f2, typeS, s)
static constexpr const zero Zero
Global zero (0)