From 9b48a244abf8092f39912314eb94832713037500 Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Mon, 24 Sep 2018 16:57:22 +0200 Subject: [PATCH] Bugfix and improvement in interpolateXY template 1. Bugfix: template instantiation failed for anything except scalar for function returning Field because the author used scalarField instead of Field to calculate interpolated values. 2. Improvement: returning tmp > instead of Field to avoid copying. --- src/foam/interpolations/interpolateXY/interpolateXY.C | 7 ++++--- src/foam/interpolations/interpolateXY/interpolateXY.H | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/foam/interpolations/interpolateXY/interpolateXY.C b/src/foam/interpolations/interpolateXY/interpolateXY.C index 3b73558dd..dc3683db1 100644 --- a/src/foam/interpolations/interpolateXY/interpolateXY.C +++ b/src/foam/interpolations/interpolateXY/interpolateXY.C @@ -34,21 +34,22 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -Field interpolateXY +tmp > interpolateXY ( const scalarField& xNew, const scalarField& xOld, const Field& yOld ) { - scalarField yNew(xNew.size()); + tmp > tyNew(new Field(xNew.size())); + Field& yNew = tyNew(); forAll(xNew, i) { yNew[i] = interpolateXY(xNew[i], xOld, yOld); } - return yNew; + return tyNew; } diff --git a/src/foam/interpolations/interpolateXY/interpolateXY.H b/src/foam/interpolations/interpolateXY/interpolateXY.H index 72cb1eb0f..d354dbfba 100644 --- a/src/foam/interpolations/interpolateXY/interpolateXY.H +++ b/src/foam/interpolations/interpolateXY/interpolateXY.H @@ -47,7 +47,7 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -Field interpolateXY +tmp > interpolateXY ( const scalarField& xNew, const scalarField& xOld,