Commit 7c43b919 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

STYLE: eliminate a global reduction for field function (issue #816)

parent 5b50febf
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -86,6 +86,7 @@ void pow
gf.oriented() = pow(gf1.oriented(), r);
}
template
<
class Type,
......@@ -181,6 +182,7 @@ void sqr
gf.oriented() = sqr(gf1.oriented());
}
template<class Type, template<class> class PatchField, class GeoMesh>
tmp
<
......@@ -217,6 +219,7 @@ sqr(const GeometricField<Type, PatchField, GeoMesh>& gf)
return tSqr;
}
template<class Type, template<class> class PatchField, class GeoMesh>
tmp
<
......@@ -270,6 +273,7 @@ void magSqr
gsf.oriented() = magSqr(gf.oriented());
}
template<class Type, template<class> class PatchField, class GeoMesh>
tmp<GeometricField<scalar, PatchField, GeoMesh>> magSqr
(
......@@ -343,6 +347,7 @@ void mag
gsf.oriented() = mag(gf.oriented());
}
template<class Type, template<class> class PatchField, class GeoMesh>
tmp<GeometricField<scalar, PatchField, GeoMesh>> mag
(
......@@ -458,6 +463,7 @@ cmptAv(const GeometricField<Type, PatchField, GeoMesh>& gf)
return CmptAv;
}
template<class Type, template<class> class PatchField, class GeoMesh>
tmp
<
......@@ -500,7 +506,7 @@ cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf)
}
#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc) \
#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, binaryOp) \
\
template<class Type, template<class> class PatchField, class GeoMesh> \
dimensioned<returnType> func \
......@@ -512,7 +518,15 @@ dimensioned<returnType> func \
( \
#func "(" + gf.name() + ')', \
gf.dimensions(), \
Foam::func(gFunc(gf.primitiveField()), gFunc(gf.boundaryField())) \
returnReduce \
( \
Foam::func \
( \
Foam::func(gf.primitiveField()), \
Foam::func(gf.boundaryField()) \
), \
binaryOp<Type>() \
) \
); \
} \
\
......@@ -527,8 +541,8 @@ dimensioned<returnType> func \
return res; \
}
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, max, gMax)
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, min, gMin)
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, max, maxOp)
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, min, minOp)
#undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -212,7 +212,7 @@ tmp
cmptAv(const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf);
#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, gFunc) \
#define UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(returnType, func, binaryOp) \
\
template<class Type, template<class> class PatchField, class GeoMesh> \
dimensioned<returnType> func \
......@@ -226,8 +226,8 @@ dimensioned<returnType> func \
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf1 \
);
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, max, gMax)
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, min, gMin)
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, max, maxOp)
UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY(Type, min, minOp)
#undef UNARY_REDUCTION_FUNCTION_WITH_BOUNDARY
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment