From c11de2384f44961d0c36286ecffcdee51d463ef5 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 7 Oct 2011 10:18:43 +0100 Subject: [PATCH] ENH: Added templated binary ops to AMI interpolation functions --- .../AMIInterpolation/AMIInterpolation.C | 76 ++++++++++++++++--- .../AMIInterpolation/AMIInterpolation.H | 47 +++++++++++- 2 files changed, 107 insertions(+), 16 deletions(-) diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index 535583a9e1..2e6a4b4384 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -1333,11 +1333,12 @@ void Foam::AMIInterpolation::update template -template +template Foam::tmp > Foam::AMIInterpolation::interpolateToSource ( - const Field& fld + const Field& fld, + const BinaryOp& bop ) const { if (fld.size() != tgtAddress_.size()) @@ -1377,7 +1378,7 @@ Foam::AMIInterpolation::interpolateToSource forAll(faces, i) { - result[faceI] += work[faces[i]]*weights[i]; + result[faceI] = bop(result[faceI], work[faces[i]]*weights[i]); } } } @@ -1390,7 +1391,7 @@ Foam::AMIInterpolation::interpolateToSource forAll(faces, i) { - result[faceI] += fld[faces[i]]*weights[i]; + result[faceI] = bop(result[faceI], fld[faces[i]]*weights[i]); } } } @@ -1400,24 +1401,26 @@ Foam::AMIInterpolation::interpolateToSource template -template +template Foam::tmp > Foam::AMIInterpolation::interpolateToSource ( - const tmp >& tFld + const tmp >& tFld, + const BinaryOp& bop ) const { - return interpolateToSource(tFld()); + return interpolateToSource(tFld(), bop); } template -template +template Foam::tmp > Foam::AMIInterpolation::interpolateToTarget ( - const Field& fld + const Field& fld, + const BinaryOp& bop ) const { if (fld.size() != srcAddress_.size()) @@ -1457,7 +1460,7 @@ Foam::AMIInterpolation::interpolateToTarget forAll(faces, i) { - result[faceI] += work[faces[i]]*weights[i]; + result[faceI] = bop(result[faceI], work[faces[i]]*weights[i]); } } } @@ -1470,7 +1473,7 @@ Foam::AMIInterpolation::interpolateToTarget forAll(faces, i) { - result[faceI] += fld[faces[i]]*weights[i]; + result[faceI] = bop(result[faceI], fld[faces[i]]*weights[i]); } } } @@ -1479,6 +1482,55 @@ Foam::AMIInterpolation::interpolateToTarget } +template +template +Foam::tmp > +Foam::AMIInterpolation::interpolateToTarget +( + const tmp >& tFld, + const BinaryOp& bop +) const +{ + return interpolateToTarget(tFld(), bop); +} + + +template +template +Foam::tmp > +Foam::AMIInterpolation::interpolateToSource +( + const Field& fld +) const +{ + return interpolateToSource(fld, sumOp()); +} + + +template +template +Foam::tmp > +Foam::AMIInterpolation::interpolateToSource +( + const tmp >& tFld +) const +{ + return interpolateToSource(tFld, sumOp()); +} + + +template +template +Foam::tmp > +Foam::AMIInterpolation::interpolateToTarget +( + const Field& fld +) const +{ + return interpolateToSource(fld, sumOp()); +} + + template template Foam::tmp > @@ -1487,7 +1539,7 @@ Foam::AMIInterpolation::interpolateToTarget const tmp >& tFld ) const { - return interpolateToTarget(tFld()); + return interpolateToSource(tFld, sumOp()); } diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H index b9d73f24ee..8df0d6fb4a 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H @@ -53,6 +53,7 @@ SourceFiles #include "treeBoundBox.H" #include "treeBoundBoxList.H" #include "globalIndex.H" +#include "ops.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -345,11 +346,46 @@ public: // Evaluation + //- Interpolate from target to source with supplied op + template + tmp > interpolateToSource + ( + const Field& fld, + const BinaryOp& bop + ) const; + + //- Interpolate from target tmp field to source with supplied op + template + tmp > interpolateToSource + ( + const tmp >& tFld, + const BinaryOp& bop + ) const; + + //- Interpolate from source to target with supplied op + template + tmp > interpolateToTarget + ( + const Field& fld, + const BinaryOp& bop + ) const; + + //- Interpolate from source tmp field to target with supplied op + template + tmp > interpolateToTarget + ( + const tmp >& tFld, + const BinaryOp& bop + ) const; + //- Interpolate from target to source template - tmp > interpolateToSource(const Field& fld) const; + tmp > interpolateToSource + ( + const Field& fld + ) const; - //- Interpolate from target tmp field to source + //- Interpolate from target tmp field template tmp > interpolateToSource ( @@ -358,9 +394,12 @@ public: //- Interpolate from source to target template - tmp > interpolateToTarget(const Field& fld) const; + tmp > interpolateToTarget + ( + const Field& fld + ) const; - //- Interpolate from source tmp field to target + //- Interpolate from source tmp field template tmp > interpolateToTarget (