ENH: Added templated binary ops to AMI interpolation functions

This commit is contained in:
andy
2011-10-07 10:18:43 +01:00
parent 34695f5845
commit c11de2384f
2 changed files with 107 additions and 16 deletions

View File

@ -1333,11 +1333,12 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
template<class SourcePatch, class TargetPatch>
template<class Type>
template<class Type, class BinaryOp>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
const Field<Type>& fld
const Field<Type>& fld,
const BinaryOp& bop
) const
{
if (fld.size() != tgtAddress_.size())
@ -1377,7 +1378,7 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::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<SourcePatch, TargetPatch>::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<SourcePatch, TargetPatch>::interpolateToSource
template<class SourcePatch, class TargetPatch>
template<class Type>
template<class Type, class BinaryOp>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
const tmp<Field<Type> >& tFld
const tmp<Field<Type> >& tFld,
const BinaryOp& bop
) const
{
return interpolateToSource(tFld());
return interpolateToSource(tFld(), bop);
}
template<class SourcePatch, class TargetPatch>
template<class Type>
template<class Type, class BinaryOp>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
(
const Field<Type>& fld
const Field<Type>& fld,
const BinaryOp& bop
) const
{
if (fld.size() != srcAddress_.size())
@ -1457,7 +1460,7 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::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<SourcePatch, TargetPatch>::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<SourcePatch, TargetPatch>::interpolateToTarget
}
template<class SourcePatch, class TargetPatch>
template<class Type, class BinaryOp>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
(
const tmp<Field<Type> >& tFld,
const BinaryOp& bop
) const
{
return interpolateToTarget(tFld(), bop);
}
template<class SourcePatch, class TargetPatch>
template<class Type>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
const Field<Type>& fld
) const
{
return interpolateToSource(fld, sumOp<Type>());
}
template<class SourcePatch, class TargetPatch>
template<class Type>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToSource
(
const tmp<Field<Type> >& tFld
) const
{
return interpolateToSource(tFld, sumOp<Type>());
}
template<class SourcePatch, class TargetPatch>
template<class Type>
Foam::tmp<Foam::Field<Type> >
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
(
const Field<Type>& fld
) const
{
return interpolateToSource(fld, sumOp<Type>());
}
template<class SourcePatch, class TargetPatch>
template<class Type>
Foam::tmp<Foam::Field<Type> >
@ -1487,7 +1539,7 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolateToTarget
const tmp<Field<Type> >& tFld
) const
{
return interpolateToTarget(tFld());
return interpolateToSource(tFld, sumOp<Type>());
}

View File

@ -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<class Type, class BinaryOp>
tmp<Field<Type> > interpolateToSource
(
const Field<Type>& fld,
const BinaryOp& bop
) const;
//- Interpolate from target tmp field to source with supplied op
template<class Type, class BinaryOp>
tmp<Field<Type> > interpolateToSource
(
const tmp<Field<Type> >& tFld,
const BinaryOp& bop
) const;
//- Interpolate from source to target with supplied op
template<class Type, class BinaryOp>
tmp<Field<Type> > interpolateToTarget
(
const Field<Type>& fld,
const BinaryOp& bop
) const;
//- Interpolate from source tmp field to target with supplied op
template<class Type, class BinaryOp>
tmp<Field<Type> > interpolateToTarget
(
const tmp<Field<Type> >& tFld,
const BinaryOp& bop
) const;
//- Interpolate from target to source
template<class Type>
tmp<Field<Type> > interpolateToSource(const Field<Type>& fld) const;
tmp<Field<Type> > interpolateToSource
(
const Field<Type>& fld
) const;
//- Interpolate from target tmp field to source
//- Interpolate from target tmp field
template<class Type>
tmp<Field<Type> > interpolateToSource
(
@ -358,9 +394,12 @@ public:
//- Interpolate from source to target
template<class Type>
tmp<Field<Type> > interpolateToTarget(const Field<Type>& fld) const;
tmp<Field<Type> > interpolateToTarget
(
const Field<Type>& fld
) const;
//- Interpolate from source tmp field to target
//- Interpolate from source tmp field
template<class Type>
tmp<Field<Type> > interpolateToTarget
(