diff --git a/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C b/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C index b33a9bc091..ff38ae0917 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& f) TMP_UNARY_FUNCTION(Type, sum) +template +Type maxMagSqr(const UList& f) +{ + if (f.size()) + { + Type Max(f[0]); + TFOR_ALL_S_OP_FUNC_F_S + ( + Type, + Max, + =, + maxMagSqrOp(), + Type, + f, + Type, + Max + ) + return Max; + } + else + { + return pTraits::min; + } +} + +TMP_UNARY_FUNCTION(Type, maxMagSqr) + +template +Type minMagSqr(const UList& f) +{ + if (f.size()) + { + Type Min(f[0]); + TFOR_ALL_S_OP_FUNC_F_S + ( + Type, + Min, + =, + minMagSqrOp(), + Type, + f, + Type, + Min + ) + return Min; + } + else + { + return pTraits::max; + } +} + +TMP_UNARY_FUNCTION(Type, minMagSqr) template scalar sumProd(const UList& f1, const UList& 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 f1fa2fdd96..4c51262f9e 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& f); TMP_UNARY_FUNCTION(Type, sum) +template +Type maxMagSqr(const UList& f); + +TMP_UNARY_FUNCTION(Type, maxMagSqr) + +template +Type minMagSqr(const UList& f); + +TMP_UNARY_FUNCTION(Type, minMagSqr) + template scalar sumProd(const UList& f1, const UList& 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)