From da53fa74c55f30bee8b9b1a8997ba76b7cf25110 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 23 Jan 2024 09:33:54 +0100 Subject: [PATCH] ENH: use tmp field factory methods [2] (#2723) - src/finiteVolume, src/finiteArea --- src/finiteArea/faMatrices/faMatrix/faMatrix.C | 6 +- .../faMatrices/faMatrix/faMatrixSolve.C | 4 +- .../basic/fixedValue/fixedValueFaPatchField.C | 5 +- .../constraint/cyclic/cyclicFaPatchField.C | 4 +- .../constraint/wedge/wedgeFaPatchField.C | 19 +++-- .../clampedPlate/clampedPlateFaPatchField.H | 5 +- .../fixedValueOutflowFaPatchField.C | 5 +- .../faePatchField/faePatchField.H | 5 +- .../divSchemes/faDivScheme/faDivScheme.C | 13 ---- .../divSchemes/faDivScheme/faDivScheme.H | 35 ++++++--- .../gaussFaDivScheme/gaussFaDivScheme.H | 2 +- .../gradSchemes/gaussFaGrad/gaussFaGrad.H | 25 +++---- .../faLaplacianScheme/faLaplacianScheme.H | 35 ++++----- .../gaussFaLaplacianScheme.H | 6 +- .../cfdTools/general/MRF/MRFZoneList.C | 43 ++++------- .../general/SRF/SRFModel/SRFModel/SRFModel.C | 75 ++++++------------- .../general/fvOptions/fvOptionListTemplates.C | 12 +-- .../cfdTools/general/levelSet/levelSet.C | 25 +++---- .../general/levelSet/levelSetTemplates.C | 27 +++---- .../DarcyForchheimer/DarcyForchheimer.C | 20 +---- .../porosityModel/porosityModel.C | 2 +- .../basic/fixedValue/fixedValueFvPatchField.C | 5 +- .../zeroGradient/zeroGradientFvPatchField.C | 20 +---- .../constraint/cyclic/cyclicFvPatchField.C | 4 +- .../cyclicACMI/cyclicACMIFvPatchField.C | 5 +- .../symmetryPlane/symmetryPlaneFvPatchField.C | 28 +++---- .../constraint/wedge/wedgeFvPatchField.C | 19 +++-- .../mappedField/mappedPatchFieldBase.C | 8 +- .../fixedValue/fixedValueFvsPatchField.C | 5 +- .../divSchemes/divScheme/divScheme.H | 25 +++++-- .../gradSchemes/gaussGrad/gaussGrad.H | 22 +++--- .../laplacianScheme/laplacianScheme.C | 6 -- .../laplacianScheme/laplacianScheme.H | 42 ++++++----- .../relaxedNonOrthoGaussLaplacianScheme.C | 2 +- .../relaxedNonOrthoGaussLaplacianSchemes.C | 2 +- .../relaxedSnGrad/relaxedSnGrad.C | 2 +- .../fvMatrices/fvMatrix/fvMatrix.C | 54 ++++++------- .../fvMatrices/fvMatrix/fvMatrixSolve.C | 4 +- .../averageNeighbourFvGeometryScheme.C | 8 +- src/finiteVolume/fvMesh/fvMeshGeometry.C | 29 ++++--- .../constraint/cyclic/cyclicFvPatch.C | 4 +- .../Poisson/PoissonPatchDistMethod.C | 21 ++---- .../LimitedScheme/LimitedScheme.C | 16 +--- .../schemes/midPoint/midPoint.H | 23 ++---- .../schemes/reverseLinear/reverseLinear.H | 23 ++---- .../surfaceInterpolation/surfaceInterpolate.C | 14 ++-- .../volPointInterpolate.C | 7 +- 47 files changed, 311 insertions(+), 460 deletions(-) diff --git a/src/finiteArea/faMatrices/faMatrix/faMatrix.C b/src/finiteArea/faMatrices/faMatrix/faMatrix.C index 074cc0693a8..4d06db262d2 100644 --- a/src/finiteArea/faMatrices/faMatrix/faMatrix.C +++ b/src/finiteArea/faMatrices/faMatrix/faMatrix.C @@ -1207,7 +1207,7 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::operator+ ) { checkMethod(A, B, "+"); - tmp<faMatrix<Type>> tC(new faMatrix<Type>(A)); + auto tC = tmp<faMatrix<Type>>::New(A); tC.ref() += B; return tC; } @@ -1262,7 +1262,7 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::operator- const faMatrix<Type>& A ) { - tmp<faMatrix<Type>> tC(new faMatrix<Type>(A)); + auto tC = tmp<faMatrix<Type>>::New(A); tC.ref().negate(); return tC; } @@ -1288,7 +1288,7 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::operator- ) { checkMethod(A, B, "-"); - tmp<faMatrix<Type>> tC(new faMatrix<Type>(A)); + auto tC = tmp<faMatrix<Type>>::New(A); tC.ref() -= B; return tC; } diff --git a/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C b/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C index 87d5ef0e03d..600adc3ce06 100644 --- a/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C +++ b/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C @@ -192,8 +192,8 @@ Foam::SolverPerformance<Type> Foam::faMatrix<Type>::solve() template<class Type> Foam::tmp<Foam::Field<Type>> Foam::faMatrix<Type>::residual() const { - tmp<Field<Type>> tres(new Field<Type>(source_)); - Field<Type>& res = tres().ref(); + auto tres = tmp<Field<Type>>::New(source_); + auto& res = tres().ref(); addBoundarySource(res); diff --git a/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.C b/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.C index 728fa8e89b1..f4d1e26592d 100644 --- a/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/basic/fixedValue/fixedValueFaPatchField.C @@ -108,10 +108,7 @@ Foam::fixedValueFaPatchField<Type>::valueInternalCoeffs const tmp<scalarField>& ) const { - return tmp<Field<Type>> - ( - new Field<Type>(this->size(), Zero) - ); + return tmp<Field<Type>>::New(this->size(), Foam::zero{}); } diff --git a/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C index 8aa6296aa07..70b711375f2 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/constraint/cyclic/cyclicFaPatchField.C @@ -130,8 +130,8 @@ Foam::cyclicFaPatchField<Type>::patchNeighbourField() const const Field<Type>& iField = this->primitiveField(); const labelUList& faceCells = cyclicPatch_.faceCells(); - tmp<Field<Type>> tpnf(new Field<Type>(this->size())); - Field<Type>& pnf = tpnf.ref(); + auto tpnf = tmp<Field<Type>>::New(this->size()); + auto& pnf = tpnf.ref(); const label sizeby2 = this->size()/2; diff --git a/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C b/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C index e9bd75e3ff6..d3e5c31d78d 100644 --- a/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/constraint/wedge/wedgeFaPatchField.C @@ -143,19 +143,18 @@ Foam::wedgeFaPatchField<Type>::snGradTransformDiag() const const vector diagV(diagT.xx(), diagT.yy(), diagT.zz()); - return tmp<Field<Type>> + return tmp<Field<Type>>::New ( - new Field<Type> + this->size(), + transformMask<Type> ( - this->size(), - transformMask<Type> + pow ( - pow - ( - diagV, - pTraits<typename powProduct<vector, pTraits<Type>::rank> - ::type>::zero - ) + diagV, + pTraits + < + typename powProduct<vector, pTraits<Type>::rank>::type + >::zero ) ) ); diff --git a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H index 828937bb6ca..4cb191c158f 100644 --- a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H @@ -149,10 +149,7 @@ public: //- Return gradient at boundary virtual tmp<Field<Type>> snGrad() const { - return tmp<Field<Type>> - ( - new Field<Type>(this->size(), Zero) - ); + return tmp<Field<Type>>::New(this->size(), Foam::zero{}); } //- Evaluate the patch field diff --git a/src/finiteArea/fields/faPatchFields/derived/fixedValueOutflow/fixedValueOutflowFaPatchField.C b/src/finiteArea/fields/faPatchFields/derived/fixedValueOutflow/fixedValueOutflowFaPatchField.C index 3b04c3fbbdb..b9d26257fb8 100644 --- a/src/finiteArea/fields/faPatchFields/derived/fixedValueOutflow/fixedValueOutflowFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/derived/fixedValueOutflow/fixedValueOutflowFaPatchField.C @@ -95,10 +95,7 @@ Foam::fixedValueOutflowFaPatchField<Type>::valueInternalCoeffs const tmp<scalarField>& weights ) const { - return tmp<Field<Type>> - ( - new Field<Type>(Type(pTraits<Type>::one)*weights) - ); + return pTraits<Type>::one*weights; } diff --git a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H index 96428b68fd4..fd1c318d8e8 100644 --- a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H +++ b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H @@ -377,10 +377,7 @@ public: const DimensionedField<Type, edgeMesh>& iF ) const { - return tmp<faePatchField<Type>> - ( - new faePatchField<Type>(*this, iF) - ); + return tmp<faePatchField<Type>>::New(*this, iF); } diff --git a/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.C b/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.C index ee05ffe259f..6d85dfafd9b 100644 --- a/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.C +++ b/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.C @@ -34,9 +34,6 @@ License namespace Foam { - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - namespace fa { @@ -84,19 +81,9 @@ tmp<divScheme<Type>> divScheme<Type>::New } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template<class Type> -divScheme<Type>::~divScheme() -{} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace fa - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - } // End namespace Foam // ************************************************************************* // diff --git a/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.H b/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.H index 56f4abc5342..47414a91231 100644 --- a/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.H +++ b/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef faDivScheme_H -#define faDivScheme_H +#ifndef Foam_faDivScheme_H +#define Foam_faDivScheme_H #include "tmp.H" #include "areaFieldsFwd.H" @@ -50,9 +50,8 @@ SourceFiles namespace Foam { -template<class Type> -class faMatrix; - +// Forward Declarations +template<class Type> class faMatrix; class faMesh; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -69,12 +68,12 @@ class divScheme : public refCount { - protected: - // Protected data + // Protected Data const faMesh& mesh_; + tmp<edgeInterpolationScheme<Type>> tinterpScheme_; @@ -113,9 +112,23 @@ public: //- Construct from mesh and Istream divScheme(const faMesh& mesh, Istream& is) : - mesh_(mesh), - tinterpScheme_(edgeInterpolationScheme<Type>::New(mesh, is)) - {} + mesh_(mesh) + { + if (is.eof()) + { + tinterpScheme_.reset + ( + new linearEdgeInterpolation<Type>(mesh) + ); + } + else + { + tinterpScheme_.reset + ( + edgeInterpolationScheme<Type>::New(mesh, is) + ); + } + } // Selectors @@ -129,7 +142,7 @@ public: //- Destructor - virtual ~divScheme(); + virtual ~divScheme() = default; // Member Functions diff --git a/src/finiteArea/finiteArea/divSchemes/gaussFaDivScheme/gaussFaDivScheme.H b/src/finiteArea/finiteArea/divSchemes/gaussFaDivScheme/gaussFaDivScheme.H index d92add74ee8..98e834128fe 100644 --- a/src/finiteArea/finiteArea/divSchemes/gaussFaDivScheme/gaussFaDivScheme.H +++ b/src/finiteArea/finiteArea/divSchemes/gaussFaDivScheme/gaussFaDivScheme.H @@ -76,7 +76,7 @@ public: // Constructors - //- Construct null + //- Construct from mesh gaussDivScheme(const faMesh& mesh) : divScheme<Type>(mesh) diff --git a/src/finiteArea/finiteArea/gradSchemes/gaussFaGrad/gaussFaGrad.H b/src/finiteArea/finiteArea/gradSchemes/gaussFaGrad/gaussFaGrad.H index f0348ffdda9..59fc08d91d4 100644 --- a/src/finiteArea/finiteArea/gradSchemes/gaussFaGrad/gaussFaGrad.H +++ b/src/finiteArea/finiteArea/gradSchemes/gaussFaGrad/gaussFaGrad.H @@ -37,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef gaussFaGrad_H -#define gaussFaGrad_H +#ifndef Foam_gaussFaGrad_H +#define Foam_gaussFaGrad_H #include "faGradScheme.H" #include "edgeInterpolationScheme.H" @@ -96,24 +96,21 @@ public: //- Construct from Istream gaussGrad(const faMesh& mesh, Istream& is) : - gradScheme<Type>(mesh), - tinterpScheme_(nullptr) + gradScheme<Type>(mesh) { if (is.eof()) { - tinterpScheme_ = - tmp<edgeInterpolationScheme<Type>> - ( - new linearEdgeInterpolation<Type>(mesh) - ); + tinterpScheme_.reset + ( + new linearEdgeInterpolation<Type>(mesh) + ); } else { - tinterpScheme_ = - tmp<edgeInterpolationScheme<Type>> - ( - edgeInterpolationScheme<Type>::New(mesh, is) - ); + tinterpScheme_.reset + ( + edgeInterpolationScheme<Type>::New(mesh, is) + ); } } diff --git a/src/finiteArea/finiteArea/laplacianSchemes/faLaplacianScheme/faLaplacianScheme.H b/src/finiteArea/finiteArea/laplacianSchemes/faLaplacianScheme/faLaplacianScheme.H index 01a1e347872..009d2a80014 100644 --- a/src/finiteArea/finiteArea/laplacianSchemes/faLaplacianScheme/faLaplacianScheme.H +++ b/src/finiteArea/finiteArea/laplacianSchemes/faLaplacianScheme/faLaplacianScheme.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef faLaplacianScheme_H -#define faLaplacianScheme_H +#ifndef Foam_faLaplacianScheme_H +#define Foam_faLaplacianScheme_H #include "tmp.H" #include "areaFieldsFwd.H" @@ -51,9 +51,8 @@ SourceFiles namespace Foam { -template<class Type> -class faMatrix; - +// Forward Declarations +template<class Type> class faMatrix; class faMesh; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -70,12 +69,12 @@ class laplacianScheme : public refCount { - protected: - // Protected data + // Protected Data const faMesh& mesh_; + tmp<edgeInterpolationScheme<scalar>> tinterpGammaScheme_; tmp<lnGradScheme<Type>> tlnGradScheme_; @@ -116,30 +115,28 @@ public: //- Construct from mesh and Istream laplacianScheme(const faMesh& mesh, Istream& is) : - mesh_(mesh), - tinterpGammaScheme_(nullptr), - tlnGradScheme_(nullptr) + mesh_(mesh) { if (is.eof()) { - tinterpGammaScheme_ = tmp<edgeInterpolationScheme<scalar>> + tinterpGammaScheme_.reset ( new linearEdgeInterpolation<scalar>(mesh) ); - tlnGradScheme_ = tmp<lnGradScheme<Type>> + tlnGradScheme_.reset ( new correctedLnGrad<Type>(mesh) ); } else { - tinterpGammaScheme_ = tmp<edgeInterpolationScheme<scalar>> + tinterpGammaScheme_.reset ( edgeInterpolationScheme<scalar>::New(mesh, is) ); - tlnGradScheme_ = tmp<lnGradScheme<Type>> + tlnGradScheme_.reset ( lnGradScheme<Type>::New(mesh, is) ); @@ -218,11 +215,11 @@ public: \ namespace Foam \ { \ - namespace fa \ - { \ - laplacianScheme<Type>::addIstreamConstructorToTable<SS<Type>> \ - add##SS##Type##IstreamConstructorToTable_; \ - } \ + namespace fa \ + { \ + laplacianScheme<Type>::addIstreamConstructorToTable<SS<Type>> \ + add##SS##Type##IstreamConstructorToTable_; \ + } \ } diff --git a/src/finiteArea/finiteArea/laplacianSchemes/gaussFaLaplacianScheme/gaussFaLaplacianScheme.H b/src/finiteArea/finiteArea/laplacianSchemes/gaussFaLaplacianScheme/gaussFaLaplacianScheme.H index fac32562ccb..7da23957004 100644 --- a/src/finiteArea/finiteArea/laplacianSchemes/gaussFaLaplacianScheme/gaussFaLaplacianScheme.H +++ b/src/finiteArea/finiteArea/laplacianSchemes/gaussFaLaplacianScheme/gaussFaLaplacianScheme.H @@ -35,8 +35,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef gaussFaLaplacianScheme_H -#define gaussFaLaplacianScheme_H +#ifndef Foam_gaussFaLaplacianScheme_H +#define Foam_gaussFaLaplacianScheme_H #include "faLaplacianScheme.H" @@ -76,7 +76,7 @@ public: // Constructors - //- Construct null + //- Construct from mesh gaussLaplacianScheme(const faMesh& mesh) : laplacianScheme<Type>(mesh) diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C index c3b40841314..a66957b9ec8 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C @@ -188,18 +188,13 @@ Foam::tmp<Foam::volVectorField> Foam::MRFZoneList::DDt const volVectorField& U ) const { - auto tacceleration = - tmp<volVectorField>::New - ( - IOobject - ( - "MRFZoneList:acceleration", - U.mesh().time().timeName(), - U.mesh().thisDb() - ), - U.mesh(), - dimensionedVector(U.dimensions()/dimTime, Zero) - ); + auto tacceleration = volVectorField::New + ( + IOobject::scopedName("MRFZoneList", "acceleration"), + IOobject::NO_REGISTER, + U.mesh(), + dimensionedVector(U.dimensions()/dimTime, Zero) + ); auto& acceleration = tacceleration.ref(); for (const auto& mrf: *this) @@ -263,10 +258,8 @@ Foam::tmp<Foam::surfaceScalarField> Foam::MRFZoneList::relative return rphi; } - else - { - return tmp<surfaceScalarField>(tphi, true); - } + + return tmp<surfaceScalarField>(tphi, true); } @@ -289,10 +282,8 @@ Foam::MRFZoneList::relative return rphi; } - else - { - return tmp<FieldField<fvsPatchField, scalar>>(tphi, true); - } + + return tmp<FieldField<fvsPatchField, scalar>>(tphi, true); } @@ -316,10 +307,8 @@ Foam::MRFZoneList::relative return rphi; } - else - { - return tmp<Field<scalar>>(tphi, true); - } + + return tmp<Field<scalar>>(tphi, true); } @@ -378,10 +367,8 @@ Foam::tmp<Foam::surfaceScalarField> Foam::MRFZoneList::absolute return rphi; } - else - { - return tmp<surfaceScalarField>(tphi, true); - } + + return tmp<surfaceScalarField>(tphi, true); } diff --git a/src/finiteVolume/cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C b/src/finiteVolume/cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C index 683f2a9c66b..58b002be2d3 100644 --- a/src/finiteVolume/cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C +++ b/src/finiteVolume/cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C @@ -55,8 +55,9 @@ Foam::SRF::SRFModel::SRFModel "SRFProperties", Urel.time().constant(), Urel.db(), - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE + IOobject::READ_MODIFIED, + IOobject::NO_WRITE, + IOobject::REGISTER ) ), Urel_(Urel), @@ -118,19 +119,12 @@ const Foam::dimensionedVector& Foam::SRF::SRFModel::omega() const Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh>> Foam::SRF::SRFModel::Fcoriolis() const { - return tmp<volVectorField::Internal> + return volVectorField::Internal::New ( - new volVectorField::Internal + "Fcoriolis", + IOobject::NO_REGISTER, ( - IOobject - ( - "Fcoriolis", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - 2.0*omega_ ^ Urel_ + 2.0*omega_ ^ Urel_.internalField() ) ); } @@ -139,18 +133,11 @@ Foam::SRF::SRFModel::Fcoriolis() const Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh>> Foam::SRF::SRFModel::Fcentrifugal() const { - return tmp<volVectorField::Internal> + return volVectorField::Internal::New ( - new volVectorField::Internal + "Fcentrifugal", + IOobject::NO_REGISTER, ( - IOobject - ( - "Fcentrifugal", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), omega_ ^ (omega_ ^ (mesh_.C().internalField() - origin_)) ) ); @@ -169,14 +156,14 @@ Foam::vectorField Foam::SRF::SRFModel::velocity const vectorField& positions ) const { - tmp<vectorField> tfld = + return vectorField + ( omega_.value() ^ ( (positions - origin_.value()) - axis_*(axis_ & (positions - origin_.value())) - ); - - return tfld(); + ) + ); } @@ -186,18 +173,11 @@ Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::U() const volVectorField::Boundary::localConsistency = 0; tmp<volVectorField> relPos(mesh_.C() - origin_); - tmp<volVectorField> tU + auto tU = volVectorField::New ( - new volVectorField + "Usrf", + IOobject::NO_REGISTER, ( - IOobject - ( - "Usrf", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), omega_ ^ (relPos() - axis_*(axis_ & relPos())) ) ); @@ -211,24 +191,13 @@ Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::Uabs() const { tmp<volVectorField> Usrf = U(); - tmp<volVectorField> tUabs + auto tUabs = volVectorField::New ( - new volVectorField - ( - IOobject - ( - "Uabs", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - Usrf - ) + "Uabs", + IOobject::NO_REGISTER, + Usrf ); - - volVectorField& Uabs = tUabs.ref(); + auto& Uabs = tUabs.ref(); // Add SRF contribution to internal field Uabs.primitiveFieldRef() += Urel_.primitiveField(); diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C index 8112e1c6899..201ecb634dc 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C @@ -42,8 +42,8 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::source { checkApplied(); - tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds)); - fvMatrix<Type>& mtx = tmtx.ref(); + auto tmtx = tmp<fvMatrix<Type>>::New(field, ds); + auto& mtx = tmtx.ref(); for (fv::option& source : *this) { @@ -129,8 +129,8 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator() rho.dimensions()*field.dimensions()/dimTime*dimVolume ); - tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds)); - fvMatrix<Type>& mtx = tmtx.ref(); + auto tmtx = tmp<fvMatrix<Type>>::New(field, ds); + auto& mtx = tmtx.ref(); for (fv::option& source : *this) { @@ -198,8 +198,8 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator() /dimTime*dimVolume ); - tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds)); - fvMatrix<Type>& mtx = tmtx.ref(); + auto tmtx = tmp<fvMatrix<Type>>::New(field, ds); + auto& mtx = tmtx.ref(); for (fv::option& source : *this) { diff --git a/src/finiteVolume/cfdTools/general/levelSet/levelSet.C b/src/finiteVolume/cfdTools/general/levelSet/levelSet.C index 4e800b71a01..2dcea81c816 100644 --- a/src/finiteVolume/cfdTools/general/levelSet/levelSet.C +++ b/src/finiteVolume/cfdTools/general/levelSet/levelSet.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,21 +42,14 @@ Foam::levelSetFraction const bool above ) { - tmp<DimensionedField<scalar, volMesh>> tResult + auto tResult = DimensionedField<scalar, volMesh>::New ( - new DimensionedField<scalar, volMesh> - ( - IOobject - ( - "levelSetFraction", - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedScalar(dimless, Zero) - ) + "levelSetFraction", + IOobject::NO_REGISTER, + mesh, + dimensionedScalar(dimless, Zero) ); - DimensionedField<scalar, volMesh>& result = tResult.ref(); + auto& result = tResult.ref(); forAll(result, cI) { @@ -113,8 +106,8 @@ Foam::tmp<Foam::scalarField> Foam::levelSetFraction const bool above ) { - tmp<scalarField> tResult(new scalarField(patch.size(), Zero)); - scalarField& result = tResult.ref(); + auto tResult = tmp<scalarField>::New(patch.size(), Zero); + auto& result = tResult.ref(); forAll(result, fI) { diff --git a/src/finiteVolume/cfdTools/general/levelSet/levelSetTemplates.C b/src/finiteVolume/cfdTools/general/levelSet/levelSetTemplates.C index f5e154f93b4..17b8e935ac7 100644 --- a/src/finiteVolume/cfdTools/general/levelSet/levelSetTemplates.C +++ b/src/finiteVolume/cfdTools/general/levelSet/levelSetTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,21 +45,14 @@ Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh>> Foam::levelSetAverage const DimensionedField<Type, pointMesh>& negativeP ) { - tmp<DimensionedField<Type, volMesh>> tResult + auto tresult = DimensionedField<Type, volMesh>::New ( - new DimensionedField<Type, volMesh> - ( - IOobject - ( - positiveC.name() + ":levelSetAverage", - mesh.time().timeName(), - mesh - ), - mesh, - dimensioned<Type>(positiveC.dimensions(), Zero) - ) + IOobject::scopedName(positiveC.name(), "levelSetAverage"), + mesh, + Foam::zero{}, // value + positiveC.dimensions() ); - DimensionedField<Type, volMesh>& result = tResult.ref(); + auto& result = tresult.ref(); forAll(result, cI) { @@ -114,7 +107,7 @@ Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh>> Foam::levelSetAverage result[cI] = r/v; } - return tResult; + return tresult; } @@ -132,8 +125,8 @@ Foam::tmp<Foam::Field<Type>> Foam::levelSetAverage { typedef typename outerProduct<Type, vector>::type sumType; - tmp<Field<Type>> tResult(new Field<Type>(patch.size(), Zero)); - Field<Type>& result = tResult.ref(); + auto tResult = tmp<Field<Type>>::New(patch.size(), Zero); + auto& result = tResult.ref(); forAll(result, fI) { diff --git a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C index 2ac51692d2b..5fbe22d2846 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/DarcyForchheimer/DarcyForchheimer.C @@ -126,32 +126,18 @@ void Foam::porosityModels::DarcyForchheimer::calcTransformModelData() { volTensorField Dout ( - IOobject - ( - typeName + ":D", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + mesh_.newIOobject(IOobject::scopedName(typeName, "D")), mesh_, dimensionedTensor(dXYZ_.dimensions(), Zero) ); + volTensorField Fout ( - IOobject - ( - typeName + ":F", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + mesh_.newIOobject(IOobject::scopedName(typeName, "F")), mesh_, dimensionedTensor(fXYZ_.dimensions(), Zero) ); - forAll(cellZoneIDs_, zonei) { const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zonei]]; diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C index 283e46f9aeb..eb4ea67311e 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModel.C @@ -173,7 +173,7 @@ Foam::tmp<Foam::vectorField> Foam::porosityModel::porosityModel::force { transformModelData(); - tmp<vectorField> tforce(new vectorField(U.size(), Zero)); + auto tforce = tmp<vectorField>::New(U.size(), Zero); if (!cellZoneIDs_.empty()) { diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C index dd3731399d8..8a567b71508 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C @@ -119,10 +119,7 @@ Foam::fixedValueFvPatchField<Type>::valueInternalCoeffs const tmp<scalarField>& ) const { - return tmp<Field<Type>> - ( - new Field<Type>(this->size(), Zero) - ); + return tmp<Field<Type>>::New(this->size(), Foam::zero{}); } diff --git a/src/finiteVolume/fields/fvPatchFields/basic/zeroGradient/zeroGradientFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/zeroGradient/zeroGradientFvPatchField.C index 65f532974fc..e7aad92d1ac 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/zeroGradient/zeroGradientFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/zeroGradient/zeroGradientFvPatchField.C @@ -112,10 +112,7 @@ Foam::zeroGradientFvPatchField<Type>::valueInternalCoeffs const tmp<scalarField>& ) const { - return tmp<Field<Type>> - ( - new Field<Type>(this->size(), pTraits<Type>::one) - ); + return tmp<Field<Type>>::New(this->size(), pTraits<Type>::one); } @@ -126,10 +123,7 @@ Foam::zeroGradientFvPatchField<Type>::valueBoundaryCoeffs const tmp<scalarField>& ) const { - return tmp<Field<Type>> - ( - new Field<Type>(this->size(), Zero) - ); + return tmp<Field<Type>>::New(this->size(), Foam::zero{}); } @@ -137,10 +131,7 @@ template<class Type> Foam::tmp<Foam::Field<Type>> Foam::zeroGradientFvPatchField<Type>::gradientInternalCoeffs() const { - return tmp<Field<Type>> - ( - new Field<Type>(this->size(), Zero) - ); + return tmp<Field<Type>>::New(this->size(), Foam::zero{}); } @@ -148,10 +139,7 @@ template<class Type> Foam::tmp<Foam::Field<Type>> Foam::zeroGradientFvPatchField<Type>::gradientBoundaryCoeffs() const { - return tmp<Field<Type>> - ( - new Field<Type>(this->size(), Zero) - ); + return tmp<Field<Type>>::New(this->size(), Foam::zero{}); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C index 0d6dac5c156..487bdb8dff5 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C @@ -134,8 +134,8 @@ Foam::cyclicFvPatchField<Type>::patchNeighbourField() const const labelUList& nbrFaceCells = cyclicPatch().cyclicPatch().neighbPatch().faceCells(); - tmp<Field<Type>> tpnf(new Field<Type>(this->size())); - Field<Type>& pnf = tpnf.ref(); + auto tpnf = tmp<Field<Type>>::New(this->size()); + auto& pnf = tpnf.ref(); if (doTransform()) diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C index 3bc1a504bb3..bda508ab318 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C @@ -881,7 +881,8 @@ Foam::cyclicACMIFvPatchField<Type>::coeffs matrix.lduMeshAssembly().cellBoundMap()[mat][index].size() ); - Field<scalar> mapCoeffs(nSubFaces, Zero); + auto tmapCoeffs = tmp<Field<scalar>>::New(nSubFaces, Zero); + auto& mapCoeffs = tmapCoeffs.ref(); const scalarListList& srcWeight = cyclicACMIPatch_.cyclicACMIPatch().AMI().srcWeights(); @@ -906,7 +907,7 @@ Foam::cyclicACMIFvPatchField<Type>::coeffs } } - return tmp<Field<scalar>>(new Field<scalar>(mapCoeffs)); + return tmapCoeffs; } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C index 53851b7e007..b83f6c80a96 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C @@ -157,27 +157,21 @@ Foam::symmetryPlaneFvPatchField<Type>::snGradTransformDiag() const { vector nHat(symmetryPlanePatch_.n()); - const vector diag - ( - mag(nHat.component(vector::X)), - mag(nHat.component(vector::Y)), - mag(nHat.component(vector::Z)) - ); + const vector diag(mag(nHat.x()), mag(nHat.y()), mag(nHat.z())); - return tmp<Field<Type>> + return tmp<Field<Type>>::New ( - new Field<Type> + this->size(), + transformMask<Type> ( - this->size(), - transformMask<Type> + //pow<vector, pTraits<Type>::rank>(diag) + pow ( - //pow<vector, pTraits<Type>::rank>(diag) - pow - ( - diag, - pTraits<typename powProduct<vector, pTraits<Type>::rank> - ::type>::zero - ) + diag, + pTraits + < + typename powProduct<vector, pTraits<Type>::rank>::type + >::zero ) ) ); diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C index 8d63c8a5d86..e3fd64d58d2 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C @@ -157,19 +157,18 @@ Foam::wedgeFvPatchField<Type>::snGradTransformDiag() const const vector diagV(diagT.xx(), diagT.yy(), diagT.zz()); - return tmp<Field<Type>> + return tmp<Field<Type>>::New ( - new Field<Type> + this->size(), + transformMask<Type> ( - this->size(), - transformMask<Type> + pow ( - pow - ( - diagV, - pTraits<typename powProduct<vector, pTraits<Type>::rank> - ::type>::zero - ) + diagV, + pTraits + < + typename powProduct<vector, pTraits<Type>::rank>::type + >::zero ) ) ); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C index 117913ff8e7..786ab2511b8 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C @@ -821,8 +821,8 @@ Foam::tmp<Foam::Field<Type>> Foam::mappedPatchFieldBase<Type>::mappedInternalField() const { // Swap to obtain full local values of neighbour internal field - tmp<Field<Type>> tnbrIntFld(new Field<Type>()); - Field<Type>& nbrIntFld = tnbrIntFld.ref(); + auto tnbrIntFld = tmp<Field<Type>>::New(); + auto& nbrIntFld = tnbrIntFld.ref(); if (mapper_.sameWorld()) { @@ -855,8 +855,8 @@ Foam::tmp<Foam::scalarField> Foam::mappedPatchFieldBase<Type>::mappedWeightField() const { // Swap to obtain full local values of neighbour internal field - tmp<scalarField> tnbrKDelta(new scalarField()); - scalarField& nbrKDelta = tnbrKDelta.ref(); + auto tnbrKDelta = tmp<scalarField>::New(); + auto& nbrKDelta = tnbrKDelta.ref(); if (mapper_.sameWorld()) { diff --git a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C index e6818521035..f457b1d07df 100644 --- a/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/basic/fixedValue/fixedValueFvsPatchField.C @@ -107,10 +107,7 @@ Foam::fixedValueFvsPatchField<Type>::valueInternalCoeffs const tmp<scalarField>& ) const { - return tmp<Field<Type>> - ( - new Field<Type>(this->size(), Zero) - ); + return tmp<Field<Type>>::New(this->size(), Foam::zero{}); } diff --git a/src/finiteVolume/finiteVolume/divSchemes/divScheme/divScheme.H b/src/finiteVolume/finiteVolume/divSchemes/divScheme/divScheme.H index 3cf30c8e4d5..61b4707f077 100644 --- a/src/finiteVolume/finiteVolume/divSchemes/divScheme/divScheme.H +++ b/src/finiteVolume/finiteVolume/divSchemes/divScheme/divScheme.H @@ -37,8 +37,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef divScheme_H -#define divScheme_H +#ifndef Foam_divScheme_H +#define Foam_divScheme_H #include "tmp.H" #include "volFieldsFwd.H" @@ -71,12 +71,12 @@ class divScheme : public refCount { - protected: // Protected data const fvMesh& mesh_; + tmp<surfaceInterpolationScheme<Type>> tinterpScheme_; @@ -120,8 +120,23 @@ public: divScheme(const fvMesh& mesh, Istream& is) : mesh_(mesh), - tinterpScheme_(surfaceInterpolationScheme<Type>::New(mesh, is)) - {} + tinterpScheme_(nullptr) + { + if (is.eof()) + { + tinterpScheme_.reset + ( + new linear<Type>(mesh) + ); + } + else + { + tinterpScheme_.reset + ( + surfaceInterpolationScheme<Type>::New(mesh, is) + ); + } + } // Selectors diff --git a/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H index a5ceacf97a6..3b4b306f618 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H +++ b/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H @@ -39,8 +39,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef gaussGrad_H -#define gaussGrad_H +#ifndef Foam_gaussGrad_H +#define Foam_gaussGrad_H #include "gradScheme.H" #include "surfaceInterpolationScheme.H" @@ -103,19 +103,17 @@ public: { if (is.eof()) { - tinterpScheme_ = - tmp<surfaceInterpolationScheme<Type>> - ( - new linear<Type>(mesh) - ); + tinterpScheme_.reset + ( + new linear<Type>(mesh) + ); } else { - tinterpScheme_ = - tmp<surfaceInterpolationScheme<Type>> - ( - surfaceInterpolationScheme<Type>::New(mesh, is) - ); + tinterpScheme_.reset + ( + surfaceInterpolationScheme<Type>::New(mesh, is) + ); } } diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C b/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C index 8e032da8cc4..8de5e717cf8 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C @@ -35,9 +35,6 @@ License namespace Foam { - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - namespace fv { @@ -112,9 +109,6 @@ laplacianScheme<Type, GType>::fvcLaplacian // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - } // End namespace Foam // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.H b/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.H index fe1eba20771..ab8b82a211a 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.H +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.H @@ -53,9 +53,8 @@ SourceFiles namespace Foam { -template<class Type> -class fvMatrix; - +// Forward Declarations +template<class Type> class fvMatrix; class fvMesh; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -72,19 +71,16 @@ class laplacianScheme : public refCount { - protected: - // Protected data + // Protected Data const fvMesh& mesh_; tmp<surfaceInterpolationScheme<GType>> tinterpGammaScheme_; tmp<snGradScheme<Type>> tsnGradScheme_; -private: - - // Private Member Functions + // Protected Member Functions //- No copy construct laplacianScheme(const laplacianScheme&) = delete; @@ -124,19 +120,25 @@ public: //- Construct from mesh and Istream laplacianScheme(const fvMesh& mesh, Istream& is) : - mesh_(mesh), - tinterpGammaScheme_(nullptr), - tsnGradScheme_(nullptr) + mesh_(mesh) { - tinterpGammaScheme_ = tmp<surfaceInterpolationScheme<GType>> - ( - surfaceInterpolationScheme<GType>::New(mesh, is) - ); - - tsnGradScheme_ = tmp<snGradScheme<Type>> - ( - snGradScheme<Type>::New(mesh, is) - ); + if (is.eof()) + { + tinterpGammaScheme_.reset(new linear<GType>(mesh)); + tsnGradScheme_.reset(new correctedSnGrad<Type>(mesh)); + } + else + { + tinterpGammaScheme_.reset + ( + surfaceInterpolationScheme<GType>::New(mesh, is) + ); + + tsnGradScheme_.reset + ( + snGradScheme<Type>::New(mesh, is) + ); + } } //- Construct from mesh, interpolation and snGradScheme schemes diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianScheme.C b/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianScheme.C index d0732bf1241..ef0efdb299f 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianScheme.C +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianScheme.C @@ -192,7 +192,7 @@ relaxedNonOrthoGaussLaplacianScheme<Type, GType>::fvmLaplacian const word corrName(tfaceFluxCorrection().name()); - tmp<SType> trelaxedCorrection(new SType(tfaceFluxCorrection())); + auto trelaxedCorrection = tmp<SType>::New(tfaceFluxCorrection()); const word oldName(corrName + "_0"); const scalar relax(vf.mesh().equationRelaxationFactor(oldName)); diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianSchemes.C b/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianSchemes.C index 7aa0027ec98..ce32fd20fbb 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianSchemes.C +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianSchemes.C @@ -66,7 +66,7 @@ fvmLaplacian \ const word corrName(tCorr().name()); \ tmp<SType> tfaceFluxCorrection(gammaMagSf*tCorr); \ \ - tmp<SType> trelaxedCorrection(new SType(tfaceFluxCorrection())); \ + auto trelaxedCorrection = tmp<SType>::New(tfaceFluxCorrection()); \ \ const word oldName(corrName + "_0"); \ const scalar relax(vf.mesh().equationRelaxationFactor(corrName)); \ diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/relaxedSnGrad/relaxedSnGrad.C b/src/finiteVolume/finiteVolume/snGradSchemes/relaxedSnGrad/relaxedSnGrad.C index 0b018126770..0506e7dc1a7 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/relaxedSnGrad/relaxedSnGrad.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/relaxedSnGrad/relaxedSnGrad.C @@ -61,7 +61,7 @@ Foam::fv::relaxedSnGrad<Type>::correction } // Return under/over-relaxed explicit correction field - tmp<SurfFieldType> trelaxedCorrection(new SurfFieldType(tcorrection())); + auto trelaxedCorrection = tmp<SurfFieldType>::New(tcorrection()); SurfFieldType& oldCorrection = obr.lookupObjectRef<SurfFieldType>(oldFieldName); diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index 716a2b18960..bf2ab42635a 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -2078,7 +2078,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator== ) { checkMethod(A, su, "=="); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() += su.mesh().V()*su.field(); return tC; } @@ -2091,7 +2091,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator== ) { checkMethod(A, tsu(), "=="); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() += tsu().mesh().V()*tsu().field(); tsu.clear(); return tC; @@ -2105,7 +2105,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator== ) { checkMethod(A, tsu(), "=="); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() += tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); return tC; @@ -2160,7 +2160,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator== ) { checkMethod(A, su, "=="); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() += A.psi().mesh().V()*su.value(); return tC; } @@ -2206,7 +2206,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator- const fvMatrix<Type>& A ) { - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().negate(); return tC; } @@ -2231,7 +2231,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+ ) { checkMethod(A, B, "+"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref() += B; return tC; } @@ -2284,7 +2284,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+ ) { checkMethod(A, su, "+"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() -= su.mesh().V()*su.field(); return tC; } @@ -2297,7 +2297,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+ ) { checkMethod(A, tsu(), "+"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() -= tsu().mesh().V()*tsu().field(); tsu.clear(); return tC; @@ -2311,7 +2311,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+ ) { checkMethod(A, tsu(), "+"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); return tC; @@ -2366,7 +2366,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+ ) { checkMethod(A, su, "+"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() -= su.mesh().V()*su.field(); return tC; } @@ -2379,7 +2379,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+ ) { checkMethod(A, tsu(), "+"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() -= tsu().mesh().V()*tsu().field(); tsu.clear(); return tC; @@ -2393,7 +2393,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+ ) { checkMethod(A, tsu(), "+"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); return tC; @@ -2449,7 +2449,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator- ) { checkMethod(A, B, "-"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref() -= B; return tC; } @@ -2503,7 +2503,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator- ) { checkMethod(A, su, "-"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() += su.mesh().V()*su.field(); return tC; } @@ -2516,7 +2516,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator- ) { checkMethod(A, tsu(), "-"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() += tsu().mesh().V()*tsu().field(); tsu.clear(); return tC; @@ -2530,7 +2530,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator- ) { checkMethod(A, tsu(), "-"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() += tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); return tC; @@ -2585,7 +2585,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator- ) { checkMethod(A, su, "-"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().negate(); tC.ref().source() -= su.mesh().V()*su.field(); return tC; @@ -2599,7 +2599,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator- ) { checkMethod(A, tsu(), "-"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().negate(); tC.ref().source() -= tsu().mesh().V()*tsu().field(); tsu.clear(); @@ -2614,7 +2614,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator- ) { checkMethod(A, tsu(), "-"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().negate(); tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); @@ -2673,7 +2673,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+ ) { checkMethod(A, su, "+"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() -= su.value()*A.psi().mesh().V(); return tC; } @@ -2699,7 +2699,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+ ) { checkMethod(A, su, "+"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() -= su.value()*A.psi().mesh().V(); return tC; } @@ -2725,7 +2725,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator- ) { checkMethod(A, su, "-"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().source() += su.value()*tC().psi().mesh().V(); return tC; } @@ -2751,7 +2751,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator- ) { checkMethod(A, su, "-"); - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref().negate(); tC.ref().source() -= su.value()*A.psi().mesh().V(); return tC; @@ -2779,7 +2779,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator* const fvMatrix<Type>& A ) { - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref() *= dsf; return tC; } @@ -2791,7 +2791,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator* const fvMatrix<Type>& A ) { - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref() *= tdsf; return tC; } @@ -2803,7 +2803,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator* const fvMatrix<Type>& A ) { - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref() *= tvsf; return tC; } @@ -2851,7 +2851,7 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::operator* const fvMatrix<Type>& A ) { - tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A)); + auto tC = tmp<fvMatrix<Type>>::New(A); tC.ref() *= ds; return tC; } diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C index 8fbd1150031..000306e3523 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C @@ -363,8 +363,8 @@ Foam::SolverPerformance<Type> Foam::fvMatrix<Type>::solve() template<class Type> Foam::tmp<Foam::Field<Type>> Foam::fvMatrix<Type>::residual() const { - tmp<Field<Type>> tres(new Field<Type>(source_)); - Field<Type>& res = tres.ref(); + auto tres = tmp<Field<Type>>::New(source_); + auto& res = tres.ref(); addBoundarySource(res); diff --git a/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C b/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C index 8476a24df44..6cfef0e9448 100644 --- a/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C +++ b/src/finiteVolume/fvMesh/fvGeometryScheme/averageNeighbour/averageNeighbourFvGeometryScheme.C @@ -272,8 +272,8 @@ Foam::averageNeighbourFvGeometryScheme::averageNeighbourCentres const labelList& nei = mesh_.faceNeighbour(); - tmp<pointField> tcc(new pointField(mesh_.nCells(), Zero)); - pointField& cc = tcc.ref(); + auto tcc = tmp<pointField>::New(mesh_.nCells(), Zero); + auto& cc = tcc.ref(); Field<solveScalar> cellWeights(mesh_.nCells(), Zero); @@ -382,8 +382,8 @@ Foam::averageNeighbourFvGeometryScheme::averageCentres const labelList& nei = mesh_.faceNeighbour(); - tmp<pointField> tnewFc(new pointField(faceCentres)); - pointField& newFc = tnewFc.ref(); + auto tnewFc = tmp<pointField>::New(faceCentres); + auto& newFc = tnewFc.ref(); // Internal faces for (label facei = 0; facei < mesh_.nInternalFaces(); facei++) diff --git a/src/finiteVolume/fvMesh/fvMeshGeometry.C b/src/finiteVolume/fvMesh/fvMeshGeometry.C index e7afa733b17..4b34dc5e275 100644 --- a/src/finiteVolume/fvMesh/fvMeshGeometry.C +++ b/src/finiteVolume/fvMesh/fvMeshGeometry.C @@ -376,25 +376,22 @@ Foam::tmp<Foam::surfaceVectorField> Foam::fvMesh::delta() const { DebugInFunction << "Calculating face deltas" << endl; - tmp<surfaceVectorField> tdelta + auto tdelta = tmp<surfaceVectorField>::New ( - new surfaceVectorField + IOobject ( - IOobject - ( - "delta", - pointsInstance(), - meshSubDir, - *this, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "delta", + pointsInstance(), + meshSubDir, *this, - dimLength - ) + IOobject::NO_READ, + IOobject::NO_WRITE, + IOobject::NO_REGISTER + ), + *this, + dimLength ); - surfaceVectorField& delta = tdelta.ref(); + auto& delta = tdelta.ref(); delta.setOriented(); const volVectorField& C = this->C(); @@ -406,7 +403,7 @@ Foam::tmp<Foam::surfaceVectorField> Foam::fvMesh::delta() const delta[facei] = C[neighbour[facei]] - C[owner[facei]]; } - surfaceVectorField::Boundary& deltabf = delta.boundaryFieldRef(); + auto& deltabf = delta.boundaryFieldRef(); forAll(deltabf, patchi) { diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C index a8eccd2c9fc..af2cb8a4ed0 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclic/cyclicFvPatch.C @@ -64,8 +64,8 @@ Foam::tmp<Foam::vectorField> Foam::cyclicFvPatch::delta() const const vectorField patchD(coupledFvPatch::delta()); const vectorField nbrPatchD(neighbFvPatch().coupledFvPatch::delta()); - tmp<vectorField> tpdv(new vectorField(patchD.size())); - vectorField& pdv = tpdv.ref(); + auto tpdv = tmp<vectorField>::New(patchD.size()); + auto& pdv = tpdv.ref(); // To the transformation if necessary if (parallel()) diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C index 5984f960c7c..7141a428d3d 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C @@ -81,23 +81,16 @@ bool Foam::patchDistMethods::Poisson::correct { if (!tyPsi_) { - tyPsi_ = tmp<volScalarField> + tyPsi_ = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "yPsi", - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedScalar(sqr(dimLength), Zero), - y.boundaryFieldRef().types() - ) + "yPsi", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(sqr(dimLength), Zero), + y.boundaryFieldRef().types() ); } - volScalarField& yPsi = tyPsi_.ref(); + auto& yPsi = tyPsi_.ref(); solve(fvm::laplacian(yPsi) == dimensionedScalar("1", dimless, -1.0)); diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C index e72725405bb..a6beca477aa 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C @@ -184,19 +184,11 @@ Foam::LimitedScheme<Type, Limiter, LimitFunc>::limiter } else { - tmp<surfaceScalarField> tlimiterField + auto tlimiterField = surfaceScalarField::New ( - new surfaceScalarField - ( - IOobject - ( - limiterFieldName, - mesh.time().timeName(), - mesh - ), - mesh, - dimless - ) + limiterFieldName, + mesh, + dimless ); calcLimiter(phi, tlimiterField.ref()); diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/midPoint/midPoint.H b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/midPoint/midPoint.H index 8bfb0360dc2..5ad8ee370c9 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/midPoint/midPoint.H +++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/midPoint/midPoint.H @@ -103,26 +103,15 @@ public: const GeometricField<Type, fvPatchField, volMesh>& ) const { - tmp<surfaceScalarField> taw + auto taw = surfaceScalarField::New ( - new surfaceScalarField - ( - IOobject - ( - "midPointWeights", - this->mesh().time().timeName(), - this->mesh().thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar("0.5", dimless, 0.5) - ) + "midPointWeights", + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar("0.5", dimless, 0.5) ); - surfaceScalarField::Boundary& awBf = - taw.ref().boundaryFieldRef(); + auto& awBf = taw.ref().boundaryFieldRef(); forAll(awBf, patchi) { diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H index 6ce1aa91e8f..f6964af2b43 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H +++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/reverseLinear/reverseLinear.H @@ -113,28 +113,19 @@ public: ); const surfaceScalarField& cdWeights = tcdWeights(); - tmp<surfaceScalarField> treverseLinearWeights + auto treverseLinearWeights = surfaceScalarField::New ( - new surfaceScalarField - ( - IOobject - ( - "reverseLinearWeights", - mesh.time().timeName(), - mesh - ), - mesh, - dimless - ) + "reverseLinearWeights", + IOobject::NO_REGISTER, + mesh, + dimless ); - surfaceScalarField& reverseLinearWeights = - treverseLinearWeights.ref(); + auto& reverseLinearWeights = treverseLinearWeights.ref(); reverseLinearWeights.primitiveFieldRef() = 1.0 - cdWeights.primitiveField(); - surfaceScalarField::Boundary& rlwbf = - reverseLinearWeights.boundaryFieldRef(); + auto& rlwbf = reverseLinearWeights.boundaryFieldRef(); forAll(mesh.boundary(), patchi) diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolate.C b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolate.C index edfdf8a9921..15d99ffe654 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolate.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/surfaceInterpolation/surfaceInterpolate.C @@ -278,22 +278,20 @@ Foam::fvc::interpolate const FieldField<fvPatchField, Type>& fvpff ) { - FieldField<fvsPatchField, Type>* fvspffPtr - ( - new FieldField<fvsPatchField, Type>(fvpff.size()) - ); + auto tresult = tmp<FieldField<fvsPatchField, Type>>::New(fvpff.size()); + auto& result = tresult.ref(); - forAll(*fvspffPtr, patchi) + forAll(result, patchi) { - fvspffPtr->set + result.set ( patchi, fvsPatchField<Type>::NewCalculatedType(fvpff[patchi].patch()).ptr() ); - (*fvspffPtr)[patchi] = fvpff[patchi]; + result[patchi] = fvpff[patchi]; } - return tmp<FieldField<fvsPatchField, Type>>(fvspffPtr); + return tresult; } diff --git a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C index 798c3bf1525..fac2318f22d 100644 --- a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C +++ b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C @@ -232,11 +232,8 @@ Foam::tmp<Foam::Field<Type>> Foam::volPointInterpolation::flatBoundaryField const fvMesh& mesh = vf.mesh(); const fvBoundaryMesh& bm = mesh.boundary(); - tmp<Field<Type>> tboundaryVals - ( - new Field<Type>(mesh.nBoundaryFaces()) - ); - Field<Type>& boundaryVals = tboundaryVals.ref(); + auto tboundaryVals = tmp<Field<Type>>::New(mesh.nBoundaryFaces()); + auto& boundaryVals = tboundaryVals.ref(); forAll(vf.boundaryField(), patchi) { -- GitLab