diff --git a/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C b/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C index b33a9bc0918b83b0f457e4d9670da8bfbafed1ad..ff38ae0917fcbff04785468f71bfff36fae54786 100644 --- a/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C +++ b/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C @@ -358,6 +358,59 @@ Type sum(const UList<Type>& f) TMP_UNARY_FUNCTION(Type, sum) +template<class Type> +Type maxMagSqr(const UList<Type>& f) +{ + if (f.size()) + { + Type Max(f[0]); + TFOR_ALL_S_OP_FUNC_F_S + ( + Type, + Max, + =, + maxMagSqrOp<Type>(), + Type, + f, + Type, + Max + ) + return Max; + } + else + { + return pTraits<Type>::min; + } +} + +TMP_UNARY_FUNCTION(Type, maxMagSqr) + +template<class Type> +Type minMagSqr(const UList<Type>& f) +{ + if (f.size()) + { + Type Min(f[0]); + TFOR_ALL_S_OP_FUNC_F_S + ( + Type, + Min, + =, + minMagSqrOp<Type>(), + Type, + f, + Type, + Min + ) + return Min; + } + else + { + return pTraits<Type>::max; + } +} + +TMP_UNARY_FUNCTION(Type, minMagSqr) template<class Type> scalar sumProd(const UList<Type>& f1, const UList<Type>& f2) @@ -488,6 +541,8 @@ TMP_UNARY_FUNCTION(ReturnType, gFunc) G_UNARY_FUNCTION(Type, gMax, max, max) G_UNARY_FUNCTION(Type, gMin, min, min) G_UNARY_FUNCTION(Type, gSum, sum, sum) +G_UNARY_FUNCTION(Type, gMaxMagSqr, maxMagSqr, maxMagSqr) +G_UNARY_FUNCTION(Type, gMinMagSqr, minMagSqr, minMagSqr) G_UNARY_FUNCTION(scalar, gSumSqr, sumSqr, sum) G_UNARY_FUNCTION(scalar, gSumMag, sumMag, sum) G_UNARY_FUNCTION(Type, gSumCmptMag, sumCmptMag, sum) diff --git a/src/OpenFOAM/fields/Fields/Field/FieldFunctions.H b/src/OpenFOAM/fields/Fields/Field/FieldFunctions.H index f1fa2fdd968281bd575b0c40152099d110078705..4c51262f9e36c9f76e1489c1ab31cb6280ca0348 100644 --- a/src/OpenFOAM/fields/Fields/Field/FieldFunctions.H +++ b/src/OpenFOAM/fields/Fields/Field/FieldFunctions.H @@ -171,6 +171,16 @@ Type sum(const UList<Type>& f); TMP_UNARY_FUNCTION(Type, sum) +template<class Type> +Type maxMagSqr(const UList<Type>& f); + +TMP_UNARY_FUNCTION(Type, maxMagSqr) + +template<class Type> +Type minMagSqr(const UList<Type>& f); + +TMP_UNARY_FUNCTION(Type, minMagSqr) + template<class Type> scalar sumProd(const UList<Type>& f1, const UList<Type>& f2); @@ -208,6 +218,8 @@ TMP_UNARY_FUNCTION(ReturnType, gFunc) G_UNARY_FUNCTION(Type, gMax, max, max) G_UNARY_FUNCTION(Type, gMin, min, min) G_UNARY_FUNCTION(Type, gSum, sum, sum) +G_UNARY_FUNCTION(Type, gMaxMagSqr, maxMagSqr, maxMagSqr) +G_UNARY_FUNCTION(Type, gMinMagSqr, minMagSqr, minMagSqr) G_UNARY_FUNCTION(scalar, gSumSqr, sumSqr, sum) G_UNARY_FUNCTION(scalar, gSumMag, sumMag, sum) G_UNARY_FUNCTION(Type, gSumCmptMag, sumCmptMag, sum)