From ff473b983319dc6cff2e18ba156191d9047321e5 Mon Sep 17 00:00:00 2001 From: graham Date: Thu, 4 Nov 2010 16:47:42 +0000 Subject: [PATCH] ENH: cmptProduct function, i.e. cmptProduct(vector(a, b, c)) = a*b*c. --- applications/test/vector/vectorTest.C | 6 +++++- src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/applications/test/vector/vectorTest.C b/applications/test/vector/vectorTest.C index f48f65d711..65e995ae4a 100644 --- a/applications/test/vector/vectorTest.C +++ b/applications/test/vector/vectorTest.C @@ -27,7 +27,11 @@ int main() Info<< magSqr(d) << endl; vector d2(0.5, 0.51, -0.5); - Info<< cmptMax(d2) << " " << cmptSum(d2) << " " << cmptMag(d2) << endl; + Info<< cmptMax(d2) << " " + << cmptSum(d2) << " " + << cmptProduct(d2) << " " + << cmptMag(d2) + << endl; Info<< min(d, d2) << endl; return 0; } diff --git a/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H b/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H index 1eff60d99b..d655990e21 100644 --- a/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H +++ b/src/OpenFOAM/primitives/VectorSpace/VectorSpaceI.H @@ -406,6 +406,17 @@ inline Cmpt cmptAv return cmptSum(vs)/nCmpt; } +template +inline Cmpt cmptProduct +( + const VectorSpace& vs +) +{ + Cmpt product = vs.v_[0]; + VectorSpaceOps::SeqOp(product, vs, multiplyEqOp()); + return product; +} + template inline Form cmptMag