29 #define TEMPLATE template<class Type>
62 template<
class Type, direction r>
72 powProductType, res, =,
pow, Type, vf, powProductType,
77 template<
class Type, direction r>
78 tmp<Field<typename powProduct<Type, r>::type>>
90 pow<Type, r>(tRes.
ref(),
f);
94 template<
class Type, direction r>
95 tmp<Field<typename powProduct<Type, r>::type>>
104 pow<Type, r>(tRes.
ref(),
tf());
122 tmp<Field<typename outerProduct<Type, Type>::type>>
135 tmp<Field<typename outerProduct<Type, Type>::type>>
300 #define TMP_UNARY_FUNCTION(ReturnType, Func) \
302 template<class Type> \
303 ReturnType Func(const tmp<Field<Type>>& tf1) \
305 ReturnType res = Func(tf1()); \
521 <<
"empty field, returning zero" <<
endl;
530 #define G_UNARY_FUNCTION(ReturnType, gFunc, Func, rFunc) \
532 template<class Type> \
533 ReturnType gFunc(const UList<Type>& f, const label comm) \
535 ReturnType res = Func(f); \
536 reduce(res, rFunc##Op<Type>(), Pstream::msgType(), comm); \
539 TMP_UNARY_FUNCTION(ReturnType, gFunc)
550 #undef G_UNARY_FUNCTION
560 scalar SumProd =
sumProd(f1, f2);
598 <<
"empty field, returning zero." <<
endl;
606 #undef TMP_UNARY_FUNCTION
636 #define PRODUCT_OPERATOR(product, Op, OpFunc) \
638 template<class Type1, class Type2> \
641 Field<typename product<Type1, Type2>::type>& res, \
642 const UList<Type1>& f1, \
643 const UList<Type2>& f2 \
646 typedef typename product<Type1, Type2>::type productType; \
647 TFOR_ALL_F_OP_F_OP_F(productType, res, =, Type1, f1, Op, Type2, f2) \
650 template<class Type1, class Type2> \
651 tmp<Field<typename product<Type1, Type2>::type>> \
652 operator Op(const UList<Type1>& f1, const UList<Type2>& f2) \
654 typedef typename product<Type1, Type2>::type productType; \
655 tmp<Field<productType>> tRes(new Field<productType>(f1.size())); \
656 OpFunc(tRes.ref(), f1, f2); \
660 template<class Type1, class Type2> \
661 tmp<Field<typename product<Type1, Type2>::type>> \
662 operator Op(const UList<Type1>& f1, const tmp<Field<Type2>>& tf2) \
664 typedef typename product<Type1, Type2>::type productType; \
665 tmp<Field<productType>> tRes = reuseTmp<productType, Type2>::New(tf2); \
666 OpFunc(tRes.ref(), f1, tf2()); \
671 template<class Type1, class Type2> \
672 tmp<Field<typename product<Type1, Type2>::type>> \
673 operator Op(const tmp<Field<Type1>>& tf1, const UList<Type2>& f2) \
675 typedef typename product<Type1, Type2>::type productType; \
676 tmp<Field<productType>> tRes = reuseTmp<productType, Type1>::New(tf1); \
677 OpFunc(tRes.ref(), tf1(), f2); \
682 template<class Type1, class Type2> \
683 tmp<Field<typename product<Type1, Type2>::type>> \
684 operator Op(const tmp<Field<Type1>>& tf1, const tmp<Field<Type2>>& tf2) \
686 typedef typename product<Type1, Type2>::type productType; \
687 tmp<Field<productType>> tRes = \
688 reuseTmpTmp<productType, Type1, Type1, Type2>::New(tf1, tf2); \
689 OpFunc(tRes.ref(), tf1(), tf2()); \
695 template<class Type, class Form, class Cmpt, direction nCmpt> \
698 Field<typename product<Type, Form>::type>& res, \
699 const UList<Type>& f1, \
700 const VectorSpace<Form,Cmpt,nCmpt>& vs \
703 typedef typename product<Type, Form>::type productType; \
704 TFOR_ALL_F_OP_F_OP_S \
705 (productType, res, =,Type, f1, Op, Form, static_cast<const Form&>(vs)) \
708 template<class Type, class Form, class Cmpt, direction nCmpt> \
709 tmp<Field<typename product<Type, Form>::type>> \
710 operator Op(const UList<Type>& f1, const VectorSpace<Form,Cmpt,nCmpt>& vs) \
712 typedef typename product<Type, Form>::type productType; \
713 tmp<Field<productType>> tRes(new Field<productType>(f1.size())); \
714 OpFunc(tRes.ref(), f1, static_cast<const Form&>(vs)); \
718 template<class Type, class Form, class Cmpt, direction nCmpt> \
719 tmp<Field<typename product<Type, Form>::type>> \
722 const tmp<Field<Type>>& tf1, \
723 const VectorSpace<Form,Cmpt,nCmpt>& vs \
726 typedef typename product<Type, Form>::type productType; \
727 tmp<Field<productType>> tRes = reuseTmp<productType, Type>::New(tf1); \
728 OpFunc(tRes.ref(), tf1(), static_cast<const Form&>(vs)); \
733 template<class Form, class Cmpt, direction nCmpt, class Type> \
736 Field<typename product<Form, Type>::type>& res, \
737 const VectorSpace<Form,Cmpt,nCmpt>& vs, \
738 const UList<Type>& f1 \
741 typedef typename product<Form, Type>::type productType; \
742 TFOR_ALL_F_OP_S_OP_F \
743 (productType, res, =,Form,static_cast<const Form&>(vs), Op, Type, f1) \
746 template<class Form, class Cmpt, direction nCmpt, class Type> \
747 tmp<Field<typename product<Form, Type>::type>> \
748 operator Op(const VectorSpace<Form,Cmpt,nCmpt>& vs, const UList<Type>& f1) \
750 typedef typename product<Form, Type>::type productType; \
751 tmp<Field<productType>> tRes(new Field<productType>(f1.size())); \
752 OpFunc(tRes.ref(), static_cast<const Form&>(vs), f1); \
756 template<class Form, class Cmpt, direction nCmpt, class Type> \
757 tmp<Field<typename product<Form, Type>::type>> \
760 const VectorSpace<Form,Cmpt,nCmpt>& vs, const tmp<Field<Type>>& tf1 \
763 typedef typename product<Form, Type>::type productType; \
764 tmp<Field<productType>> tRes = reuseTmp<productType, Type>::New(tf1); \
765 OpFunc(tRes.ref(), static_cast<const Form&>(vs), tf1()); \
778 #undef PRODUCT_OPERATOR
#define BINARY_FUNCTION(ReturnType, Type1, Type2, Func)
#define UNARY_OPERATOR(ReturnType, Type1, Op, OpFunc, Dfunc)
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpName, OpFunc)
#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 PRODUCT_OPERATOR(product, Op, OpFunc)
#define TMP_UNARY_FUNCTION(ReturnType, Func)
#define TFOR_ALL_S_OP_F_OP_F(typeS, s, OP1, typeF1, f1, OP2, typeF2, f2)
#define TFOR_ALL_S_OP_F(typeS, s, OP, typeF, f)
#define TFOR_ALL_F_OP_FUNC_F_S(typeF1, f1, OP, FUNC, typeF2, f2, typeS, s)
#define TFOR_ALL_F_OP_F_FUNC(typeF1, f1, OP, typeF2, f2, FUNC)
#define TFOR_ALL_F_OP_F_FUNC_S(typeF1, f1, OP, typeF2, f2, FUNC, typeS, s)
#define TFOR_ALL_S_OP_FUNC_F(typeS, s, OP, FUNC, typeF, f)
#define TFOR_ALL_S_OP_FUNC_F_S(typeS1, s1, OP, FUNC, typeF, f, typeS2, s2)
#define TFOR_ALL_F_OP_FUNC_F(typeF1, f1, OP, FUNC, typeF2, f2)
#define TFOR_ALL_S_OP_FUNC_F_F(typeS, s, OP, FUNC, typeF1, f1, typeF2, f2)
Inter-processor communication reduction functions.
Pre-declare SubField and related Field type.
pTraits< Type >::cmptType cmptType
Component type.
void size(const label)
Override size to be inconsistent with allocated storage.
void clear()
Clear the list, i.e. set size to zero.
label size() const
Return the number of elements in the UList.
static int & msgType()
Message tag of standard messages.
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Traits class for primitives.
symmTypeOfRank< typename pTraits< arg1 >::cmptType, arg2 *direction(pTraits< arg1 >::rank) >::type type
static tmp< Field< TypeR > > New(const tmp< Field< Type1 >> &tf1)
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define WarningInFunction
Report a warning using Foam::Warning.
void negate(FieldField< Field, Type > &res, const FieldField< Field, Type > &f)
Type gSum(const FieldField< Field, Type > &f)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
scalar gSumMag(const FieldField< Field, Type > &f)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
scalar gSumSqr(const UList< Type > &f, const label comm)
Ostream & endl(Ostream &os)
Add newline and flush stream.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
void subtract(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
scalar gSumProd(const UList< Type > &f1, const UList< Type > &f2, const label comm)
void cmptMin(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
Type sumCmptProd(const UList< Type > &f1, const UList< Type > &f2)
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Type maxMagSqr(const UList< Type > &f)
void dot(FieldField< Field1, typename innerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Type gMaxMagSqr(const UList< Type > &f, const label comm)
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &df)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
dimensioned< scalar > mag(const dimensioned< Type > &)
scalar sumProd(const UList< Type > &f1, const UList< Type > &f2)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
dimensionSet cmptMag(const dimensionSet &)
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
dimensioned< Type > cmptDivide(const dimensioned< Type > &, const dimensioned< Type > &)
Type gAverage(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)
Type minMagSqr(const UList< Type > &f)
Type gMin(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)
scalar sumSqr(const UList< Type > &f)
Type gMinMagSqr(const UList< Type > &f, const label comm)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
Type gSumCmptMag(const UList< Type > &f, const label comm)
Type gMax(const FieldField< Field, Type > &f)
Type sumCmptMag(const UList< Type > &f)
void outer(FieldField< Field1, typename outerProduct< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void sumReduce(T &Value, label &Count, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensioned< scalar > sumMag(const DimensionedField< Type, GeoMesh > &df)
Type gSumCmptProd(const UList< Type > &f1, const UList< Type > &f2, const label comm)