diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index f6ec16baf7..8e5d875e1b 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -1021,25 +1021,22 @@ template class PatchField, class GeoMesh> Foam::tmp> Foam::GeometricField::T() const { - tmp> result + auto tresult = tmp>::New ( - new GeometricField + IOobject ( - IOobject - ( - this->name() + ".T()", - this->instance(), - this->db() - ), - this->mesh(), - this->dimensions() - ) + this->name() + ".T()", + this->instance(), + this->db() + ), + this->mesh(), + this->dimensions() ); - Foam::T(result.ref().primitiveFieldRef(), primitiveField()); - Foam::T(result.ref().boundaryFieldRef(), boundaryField()); + Foam::T(tresult.ref().primitiveFieldRef(), primitiveField()); + Foam::T(tresult.ref().boundaryFieldRef(), boundaryField()); - return result; + return tresult; } @@ -1058,25 +1055,22 @@ Foam::GeometricField::component const direction d ) const { - tmp> Component + auto tresult = tmp>::New ( - new GeometricField + IOobject ( - IOobject - ( - this->name() + ".component(" + Foam::name(d) + ')', - this->instance(), - this->db() - ), - this->mesh(), - this->dimensions() - ) + this->name() + ".component(" + Foam::name(d) + ')', + this->instance(), + this->db() + ), + this->mesh(), + this->dimensions() ); - Foam::component(Component.ref().primitiveFieldRef(), primitiveField(), d); - Foam::component(Component.ref().boundaryFieldRef(), boundaryField(), d); + Foam::component(tresult.ref().primitiveFieldRef(), primitiveField(), d); + Foam::component(tresult.ref().boundaryFieldRef(), boundaryField(), d); - return Component; + return tresult; } diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C index 855a944057..967da81885 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctions.C @@ -103,9 +103,8 @@ pow { typedef typename powProduct::type powProductType; - tmp> tPow - ( - new GeometricField + auto tres = + tmp>::New ( IOobject ( @@ -117,12 +116,11 @@ pow ), gf.mesh(), pow(gf.dimensions(), r) - ) - ); + ); - pow(tPow.ref(), gf); + pow(tres.ref(), gf); - return tPow; + return tres; } @@ -144,9 +142,8 @@ pow const GeometricField& gf = tgf(); - tmp> tPow - ( - new GeometricField + auto tres = + tmp>::New ( IOobject ( @@ -158,14 +155,12 @@ pow ), gf.mesh(), pow(gf.dimensions(), r) - ) - ); + ); - pow(tPow.ref(), gf); + pow(tres.ref(), gf); tgf.clear(); - - return tPow; + return tres; } @@ -197,9 +192,8 @@ sqr(const GeometricField& gf) { typedef typename outerProduct::type outerProductType; - tmp> tSqr - ( - new GeometricField + auto tres = + tmp>::New ( IOobject ( @@ -211,12 +205,11 @@ sqr(const GeometricField& gf) ), gf.mesh(), sqr(gf.dimensions()) - ) - ); + ); - sqr(tSqr.ref(), gf); + sqr(tres.ref(), gf); - return tSqr; + return tres; } @@ -236,9 +229,8 @@ sqr(const tmp>& tgf) const GeometricField& gf = tgf(); - tmp> tSqr - ( - new GeometricField + auto tres = + tmp>::New ( IOobject ( @@ -250,14 +242,13 @@ sqr(const tmp>& tgf) ), gf.mesh(), sqr(gf.dimensions()) - ) - ); + ); - sqr(tSqr.ref(), gf); + sqr(tres.ref(), gf); tgf.clear(); - return tSqr; + return tres; } @@ -280,9 +271,8 @@ tmp> magSqr const GeometricField& gf ) { - tmp> tMagSqr - ( - new GeometricField + auto tres = + tmp>::New ( IOobject ( @@ -294,12 +284,11 @@ tmp> magSqr ), gf.mesh(), sqr(gf.dimensions()) - ) - ); + ); - magSqr(tMagSqr.ref(), gf); + magSqr(tres.ref(), gf); - return tMagSqr; + return tres; } template class PatchField, class GeoMesh> @@ -310,9 +299,8 @@ tmp> magSqr { const GeometricField& gf = tgf(); - tmp> tMagSqr - ( - new GeometricField + auto tres = + tmp>::New ( IOobject ( @@ -324,14 +312,13 @@ tmp> magSqr ), gf.mesh(), sqr(gf.dimensions()) - ) - ); + ); - magSqr(tMagSqr.ref(), gf); + magSqr(tres.ref(), gf); tgf.clear(); - return tMagSqr; + return tres; } @@ -354,9 +341,8 @@ tmp> mag const GeometricField& gf ) { - tmp> tMag - ( - new GeometricField + auto tres = + tmp>::New ( IOobject ( @@ -368,12 +354,11 @@ tmp> mag ), gf.mesh(), gf.dimensions() - ) - ); + ); - mag(tMag.ref(), gf); + mag(tres.ref(), gf); - return tMag; + return tres; } template class PatchField, class GeoMesh> @@ -384,9 +369,8 @@ tmp> mag { const GeometricField& gf = tgf(); - tmp> tMag - ( - new GeometricField + auto tres = + tmp>::New ( IOobject ( @@ -398,14 +382,13 @@ tmp> mag ), gf.mesh(), gf.dimensions() - ) - ); + ); - mag(tMag.ref(), gf); + mag(tres.ref(), gf); tgf.clear(); - return tMag; + return tres; } @@ -441,9 +424,8 @@ cmptAv(const GeometricField& gf) typedef typename GeometricField::cmptType cmptType; - tmp> CmptAv - ( - new GeometricField + auto tres = + tmp>::New ( IOobject ( @@ -455,12 +437,11 @@ cmptAv(const GeometricField& gf) ), gf.mesh(), gf.dimensions() - ) - ); + ); - cmptAv(CmptAv.ref(), gf); + cmptAv(tres.ref(), gf); - return CmptAv; + return tres; } @@ -481,9 +462,8 @@ cmptAv(const tmp>& tgf) const GeometricField& gf = tgf(); - tmp> CmptAv - ( - new GeometricField + auto tres = + tmp>::New ( IOobject ( @@ -495,14 +475,13 @@ cmptAv(const tmp>& tgf) ), gf.mesh(), gf.dimensions() - ) - ); + ); - cmptAv(CmptAv.ref(), gf); + cmptAv(tres.ref(), gf); tgf.clear(); - return CmptAv; + return tres; } @@ -649,9 +628,9 @@ operator op \ ) \ { \ typedef typename product::type productType; \ - tmp> tRes \ - ( \ - new GeometricField \ + \ + auto tres = \ + tmp>::New \ ( \ IOobject \ ( \ @@ -663,14 +642,14 @@ operator op \ ), \ gf1.mesh(), \ gf1.dimensions() op gf2.dimensions() \ - ) \ - ); \ + ); \ \ - Foam::opFunc(tRes.ref(), gf1, gf2); \ + Foam::opFunc(tres.ref(), gf1, gf2); \ \ - return tRes; \ + return tres; \ } \ \ + \ template \ class PatchField, class GeoMesh> \ tmp \ @@ -687,7 +666,7 @@ operator op \ \ const GeometricField& gf2 = tgf2(); \ \ - tmp> tRes = \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf2, \ @@ -695,11 +674,11 @@ operator op \ gf1.dimensions() op gf2.dimensions() \ ); \ \ - Foam::opFunc(tRes.ref(), gf1, gf2); \ + Foam::opFunc(tres.ref(), gf1, gf2); \ \ tgf2.clear(); \ \ - return tRes; \ + return tres; \ } \ \ template \ @@ -718,7 +697,7 @@ operator op \ \ const GeometricField& gf1 = tgf1(); \ \ - tmp> tRes = \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf1, \ @@ -726,11 +705,11 @@ operator op \ gf1.dimensions() op gf2.dimensions() \ ); \ \ - Foam::opFunc(tRes.ref(), gf1, gf2); \ + Foam::opFunc(tres.ref(), gf1, gf2); \ \ tgf1.clear(); \ \ - return tRes; \ + return tres; \ } \ \ template \ @@ -750,7 +729,7 @@ operator op \ const GeometricField& gf1 = tgf1(); \ const GeometricField& gf2 = tgf2(); \ \ - tmp> tRes = \ + auto tres = \ reuseTmpTmpGeometricField \ ::New \ ( \ @@ -760,12 +739,12 @@ operator op \ gf1.dimensions() op gf2.dimensions() \ ); \ \ - Foam::opFunc(tRes.ref(), gf1, gf2); \ + Foam::opFunc(tres.ref(), gf1, gf2); \ \ tgf1.clear(); \ tgf2.clear(); \ \ - return tRes; \ + return tres; \ } \ \ template \ @@ -794,9 +773,8 @@ operator op \ { \ typedef typename product::type productType; \ \ - tmp> tRes \ - ( \ - new GeometricField \ + auto tres = \ + tmp>::New \ ( \ IOobject \ ( \ @@ -808,12 +786,11 @@ operator op \ ), \ gf1.mesh(), \ gf1.dimensions() op dvs.dimensions() \ - ) \ - ); \ + ); \ \ - Foam::opFunc(tRes.ref(), gf1, dvs); \ + Foam::opFunc(tres.ref(), gf1, dvs); \ \ - return tRes; \ + return tres; \ } \ \ template \ @@ -848,7 +825,7 @@ operator op \ \ const GeometricField& gf1 = tgf1(); \ \ - tmp> tRes = \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf1, \ @@ -856,11 +833,11 @@ operator op \ gf1.dimensions() op dvs.dimensions() \ ); \ \ - Foam::opFunc(tRes.ref(), gf1, dvs); \ + Foam::opFunc(tres.ref(), gf1, dvs); \ \ tgf1.clear(); \ \ - return tRes; \ + return tres; \ } \ \ template \ @@ -907,9 +884,9 @@ operator op \ ) \ { \ typedef typename product::type productType; \ - tmp> tRes \ - ( \ - new GeometricField \ + \ + auto tres = \ + tmp>::New \ ( \ IOobject \ ( \ @@ -921,12 +898,11 @@ operator op \ ), \ gf1.mesh(), \ dvs.dimensions() op gf1.dimensions() \ - ) \ - ); \ + ); \ \ - Foam::opFunc(tRes.ref(), dvs, gf1); \ + Foam::opFunc(tres.ref(), dvs, gf1); \ \ - return tRes; \ + return tres; \ } \ \ template \ @@ -960,7 +936,7 @@ operator op \ \ const GeometricField& gf1 = tgf1(); \ \ - tmp> tRes = \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf1, \ @@ -968,11 +944,11 @@ operator op \ dvs.dimensions() op gf1.dimensions() \ ); \ \ - Foam::opFunc(tRes.ref(), dvs, gf1); \ + Foam::opFunc(tres.ref(), dvs, gf1); \ \ tgf1.clear(); \ \ - return tRes; \ + return tres; \ } \ \ template \ diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctionsM.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctionsM.C index 9ff2ed8639..717852ea30 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctionsM.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricFieldFunctionsM.C @@ -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) 2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,15 +46,15 @@ void Func \ res.oriented() = gf1.oriented(); \ } \ \ + \ TEMPLATE \ tmp> Func \ ( \ const GeometricField& gf1 \ ) \ { \ - tmp> tRes \ - ( \ - new GeometricField \ + auto tres = \ + tmp>::New \ ( \ IOobject \ ( \ @@ -66,14 +66,14 @@ tmp> Func \ ), \ gf1.mesh(), \ Dfunc(gf1.dimensions()) \ - ) \ - ); \ + ); \ \ - Foam::Func(tRes.ref(), gf1); \ + Foam::Func(tres.ref(), gf1); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> Func \ ( \ @@ -82,21 +82,19 @@ tmp> Func \ { \ const GeometricField& gf1 = tgf1(); \ \ - tmp> tRes \ - ( \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf1, \ #Func "(" + gf1.name() + ')', \ Dfunc(gf1.dimensions()) \ - ) \ - ); \ + ); \ \ - Foam::Func(tRes.ref(), gf1); \ + Foam::Func(tres.ref(), gf1); \ \ tgf1.clear(); \ \ - return tRes; \ + return tres; \ } @@ -122,9 +120,8 @@ tmp> operator Op \ const GeometricField& gf1 \ ) \ { \ - tmp> tRes \ - ( \ - new GeometricField \ + auto tres = \ + tmp>::New \ ( \ IOobject \ ( \ @@ -136,14 +133,14 @@ tmp> operator Op \ ), \ gf1.mesh(), \ Dfunc(gf1.dimensions()) \ - ) \ - ); \ + ); \ \ - Foam::OpFunc(tRes.ref(), gf1); \ + Foam::OpFunc(tres.ref(), gf1); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> operator Op \ ( \ @@ -152,21 +149,19 @@ tmp> operator Op \ { \ const GeometricField& gf1 = tgf1(); \ \ - tmp> tRes \ - ( \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf1, \ #Op + gf1.name(), \ Dfunc(gf1.dimensions()) \ - ) \ - ); \ + ); \ \ - Foam::OpFunc(tRes.ref(), gf1); \ + Foam::OpFunc(tres.ref(), gf1); \ \ tgf1.clear(); \ \ - return tRes; \ + return tres; \ } @@ -197,6 +192,7 @@ void Func \ res.oriented() = Func(gf1.oriented(), gf2.oriented()); \ } \ \ + \ TEMPLATE \ tmp> Func \ ( \ @@ -204,9 +200,8 @@ tmp> Func \ const GeometricField& gf2 \ ) \ { \ - tmp> tRes \ - ( \ - new GeometricField \ + auto tres = \ + tmp>::New \ ( \ IOobject \ ( \ @@ -218,14 +213,14 @@ tmp> Func \ ), \ gf1.mesh(), \ Func(gf1.dimensions(), gf2.dimensions()) \ - ) \ - ); \ + ); \ \ - Foam::Func(tRes.ref(), gf1, gf2); \ + Foam::Func(tres.ref(), gf1, gf2); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> Func \ ( \ @@ -235,23 +230,22 @@ tmp> Func \ { \ const GeometricField& gf2 = tgf2(); \ \ - tmp> tRes \ - ( \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf2, \ #Func "(" + gf1.name() + ',' + gf2.name() + ')', \ Func(gf1.dimensions(), gf2.dimensions()) \ - ) \ - ); \ + ); \ \ - Foam::Func(tRes.ref(), gf1, gf2); \ + Foam::Func(tres.ref(), gf1, gf2); \ \ tgf2.clear(); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> Func \ ( \ @@ -261,23 +255,22 @@ tmp> Func \ { \ const GeometricField& gf1 = tgf1(); \ \ - tmp> tRes \ - ( \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf1, \ #Func "(" + gf1.name() + ',' + gf2.name() + ')', \ Func(gf1.dimensions(), gf2.dimensions()) \ - ) \ - ); \ + ); \ \ - Foam::Func(tRes.ref(), gf1, gf2); \ + Foam::Func(tres.ref(), gf1, gf2); \ \ tgf1.clear(); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> Func \ ( \ @@ -288,8 +281,7 @@ tmp> Func \ const GeometricField& gf1 = tgf1(); \ const GeometricField& gf2 = tgf2(); \ \ - tmp> tRes \ - ( \ + auto tres = \ reuseTmpTmpGeometricField \ \ ::New \ @@ -298,17 +290,17 @@ tmp> Func \ tgf2, \ #Func "(" + gf1.name() + ',' + gf2.name() + ')', \ Func(gf1.dimensions(), gf2.dimensions()) \ - ) \ - ); \ + ); \ \ - Foam::Func(tRes.ref(), gf1, gf2); \ + Foam::Func(tres.ref(), gf1, gf2); \ \ tgf1.clear(); \ tgf2.clear(); \ \ - return tRes; \ + return tres; \ } + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #define BINARY_TYPE_FUNCTION_SF(ReturnType, Type1, Type2, Func) \ @@ -326,6 +318,7 @@ void Func \ res.oriented() = gf2.oriented(); \ } \ \ + \ TEMPLATE \ tmp> Func \ ( \ @@ -333,9 +326,8 @@ tmp> Func \ const GeometricField& gf2 \ ) \ { \ - tmp> tRes \ - ( \ - new GeometricField \ + auto tres = \ + tmp>::New \ ( \ IOobject \ ( \ @@ -347,14 +339,14 @@ tmp> Func \ ), \ gf2.mesh(), \ Func(dt1.dimensions(), gf2.dimensions()) \ - ) \ - ); \ + ); \ \ - Foam::Func(tRes.ref(), dt1, gf2); \ + Foam::Func(tres.ref(), dt1, gf2); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> Func \ ( \ @@ -375,23 +367,22 @@ tmp> Func \ { \ const GeometricField& gf2 = tgf2(); \ \ - tmp> tRes \ - ( \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf2, \ #Func "(" + dt1.name() + gf2.name() + ',' + ')', \ Func(dt1.dimensions(), gf2.dimensions()) \ - ) \ - ); \ + ); \ \ - Foam::Func(tRes.ref(), dt1, gf2); \ + Foam::Func(tres.ref(), dt1, gf2); \ \ tgf2.clear(); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> Func \ ( \ @@ -418,6 +409,7 @@ void Func \ res.oriented() = gf1.oriented(); \ } \ \ + \ TEMPLATE \ tmp> Func \ ( \ @@ -425,9 +417,8 @@ tmp> Func \ const dimensioned& dt2 \ ) \ { \ - tmp> tRes \ - ( \ - new GeometricField \ + auto tres = \ + tmp>::New \ ( \ IOobject \ ( \ @@ -439,14 +430,14 @@ tmp> Func \ ), \ gf1.mesh(), \ Func(gf1.dimensions(), dt2.dimensions()) \ - ) \ - ); \ + ); \ \ - Foam::Func(tRes.ref(), gf1, dt2); \ + Foam::Func(tres.ref(), gf1, dt2); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> Func \ ( \ @@ -467,23 +458,22 @@ tmp> Func \ { \ const GeometricField& gf1 = tgf1(); \ \ - tmp> tRes \ - ( \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf1, \ #Func "(" + gf1.name() + ',' + dt2.name() + ')', \ Func(gf1.dimensions(), dt2.dimensions()) \ - ) \ - ); \ + ); \ \ - Foam::Func(tRes.ref(), gf1, dt2); \ + Foam::Func(tres.ref(), gf1, dt2); \ \ tgf1.clear(); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> Func \ ( \ @@ -519,6 +509,7 @@ void OpFunc \ res.oriented() = gf1.oriented() Op gf2.oriented(); \ } \ \ + \ TEMPLATE \ tmp> operator Op \ ( \ @@ -526,9 +517,8 @@ tmp> operator Op \ const GeometricField& gf2 \ ) \ { \ - tmp> tRes \ - ( \ - new GeometricField \ + auto tres = \ + tmp>::New \ ( \ IOobject \ ( \ @@ -540,14 +530,14 @@ tmp> operator Op \ ), \ gf1.mesh(), \ gf1.dimensions() Op gf2.dimensions() \ - ) \ - ); \ + ); \ \ - Foam::OpFunc(tRes.ref(), gf1, gf2); \ + Foam::OpFunc(tres.ref(), gf1, gf2); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> operator Op \ ( \ @@ -557,23 +547,22 @@ tmp> operator Op \ { \ const GeometricField& gf2 = tgf2(); \ \ - tmp> tRes \ - ( \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf2, \ '(' + gf1.name() + OpName + gf2.name() + ')', \ gf1.dimensions() Op gf2.dimensions() \ - ) \ - ); \ + ); \ \ - Foam::OpFunc(tRes.ref(), gf1, gf2); \ + Foam::OpFunc(tres.ref(), gf1, gf2); \ \ tgf2.clear(); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> operator Op \ ( \ @@ -583,23 +572,22 @@ tmp> operator Op \ { \ const GeometricField& gf1 = tgf1(); \ \ - tmp> tRes \ - ( \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf1, \ '(' + gf1.name() + OpName + gf2.name() + ')', \ gf1.dimensions() Op gf2.dimensions() \ - ) \ - ); \ + ); \ \ - Foam::OpFunc(tRes.ref(), gf1, gf2); \ + Foam::OpFunc(tres.ref(), gf1, gf2); \ \ tgf1.clear(); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> operator Op \ ( \ @@ -610,8 +598,7 @@ tmp> operator Op \ const GeometricField& gf1 = tgf1(); \ const GeometricField& gf2 = tgf2(); \ \ - tmp> tRes \ - ( \ + auto tres = \ reuseTmpTmpGeometricField \ ::New \ ( \ @@ -619,15 +606,14 @@ tmp> operator Op \ tgf2, \ '(' + gf1.name() + OpName + gf2.name() + ')', \ gf1.dimensions() Op gf2.dimensions() \ - ) \ - ); \ + ); \ \ - Foam::OpFunc(tRes.ref(), gf1, gf2); \ + Foam::OpFunc(tres.ref(), gf1, gf2); \ \ tgf1.clear(); \ tgf2.clear(); \ \ - return tRes; \ + return tres; \ } @@ -656,9 +642,8 @@ tmp> operator Op \ const GeometricField& gf2 \ ) \ { \ - tmp> tRes \ - ( \ - new GeometricField \ + auto tres = \ + tmp>::New \ ( \ IOobject \ ( \ @@ -670,14 +655,14 @@ tmp> operator Op \ ), \ gf2.mesh(), \ dt1.dimensions() Op gf2.dimensions() \ - ) \ - ); \ + ); \ \ - Foam::OpFunc(tRes.ref(), dt1, gf2); \ + Foam::OpFunc(tres.ref(), dt1, gf2); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> operator Op \ ( \ @@ -698,23 +683,22 @@ tmp> operator Op \ { \ const GeometricField& gf2 = tgf2(); \ \ - tmp> tRes \ - ( \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf2, \ '(' + dt1.name() + OpName + gf2.name() + ')', \ dt1.dimensions() Op gf2.dimensions() \ - ) \ - ); \ + ) ; \ \ - Foam::OpFunc(tRes.ref(), dt1, gf2); \ + Foam::OpFunc(tres.ref(), dt1, gf2); \ \ tgf2.clear(); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> operator Op \ ( \ @@ -741,6 +725,7 @@ void OpFunc \ res.oriented() = gf1.oriented(); \ } \ \ + \ TEMPLATE \ tmp> operator Op \ ( \ @@ -748,9 +733,8 @@ tmp> operator Op \ const dimensioned& dt2 \ ) \ { \ - tmp> tRes \ - ( \ - new GeometricField \ + auto tres = \ + tmp>::New \ ( \ IOobject \ ( \ @@ -762,14 +746,14 @@ tmp> operator Op \ ), \ gf1.mesh(), \ gf1.dimensions() Op dt2.dimensions() \ - ) \ - ); \ + ); \ \ - Foam::OpFunc(tRes.ref(), gf1, dt2); \ + Foam::OpFunc(tres.ref(), gf1, dt2); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> operator Op \ ( \ @@ -790,23 +774,22 @@ tmp> operator Op \ { \ const GeometricField& gf1 = tgf1(); \ \ - tmp> tRes \ - ( \ + auto tres = \ reuseTmpGeometricField::New \ ( \ tgf1, \ '(' + gf1.name() + OpName + dt2.name() + ')', \ gf1.dimensions() Op dt2.dimensions() \ - ) \ - ); \ + ); \ \ - Foam::OpFunc(tRes.ref(), gf1, dt2); \ + Foam::OpFunc(tres.ref(), gf1, dt2); \ \ tgf1.clear(); \ \ - return tRes; \ + return tres; \ } \ \ + \ TEMPLATE \ tmp> operator Op \ ( \ diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C index beceeeefc0..ee8dc23739 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C @@ -23,7 +23,6 @@ License \*---------------------------------------------------------------------------*/ - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template @@ -37,22 +36,19 @@ Foam::tmp Foam::uniformInterpolate const GeoField& field0 = *(*fields.begin()); // Interpolate - tmp tfld + auto tfld = tmp::New ( - new GeoField + IOobject ( - IOobject - ( - "uniformInterpolate(" + field0.name() + ')', - field0.time().timeName(), - field0.db(), - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - weights[0]*(*fields[indices[0]]) - ) + "uniformInterpolate(" + field0.name() + ')', + field0.time().timeName(), + field0.db(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + weights[0]*(*fields[indices[0]]) ); - GeoField& fld = tfld(); + auto& fld = tfld(); for (label i = 1; i < indices.size(); ++i) { @@ -91,25 +87,16 @@ Foam::tmp Foam::uniformInterpolate // Interpolate - tmp tfld(new GeoField(fieldIO, weights[0]*field0)); + auto tfld = tmp::New(fieldIO, weights[0]*field0); GeoField& fld = tfld.ref(); for (label i = 1; i < times.size(); ++i) { - const objectRegistry& timeIFields = fieldsCache.lookupObject - < - const objectRegistry - > - ( - times[i] - ); - const GeoField& fieldi = timeIFields.lookupObject - < - const GeoField - > - ( - fieldName - ); + const objectRegistry& timeIFields = + fieldsCache.lookupObject(times[i]); + + const GeoField& fieldi = + timeIFields.lookupObject(fieldName); fld += weights[i]*fieldi; }