diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C index 6476a59d354cac553e60cbd333b469628aaa29a8..559f7fe26ff5288b36970fbb224e307b21a189a5 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C @@ -46,7 +46,8 @@ Foam::tmp<GeoField> Foam::uniformInterpolate field0.time().timeName(), field0.db(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), weights[0]*(*fields[indices[0]]) ); diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixOperations.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixOperations.C index 7fa0cd403c3d432b2372dff2cacf7f152df5d74f..7945a8cd2da82752cbb4740102af3fd788d0f911 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixOperations.C +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixOperations.C @@ -90,16 +90,11 @@ template<class Type, class DType, class LUType> Foam::tmp<Foam::Field<Type>> Foam::LduMatrix<Type, DType, LUType>::H(const Field<Type>& psi) const { - tmp<Field<Type>> tHpsi - ( - new Field<Type>(lduAddr().size(), Zero) - ); + auto tHpsi = tmp<Field<Type>>::New(lduAddr().size(), Foam::zero{}); if (lowerPtr_ || upperPtr_) { - Field<Type> & Hpsi = tHpsi(); - - Type* __restrict__ HpsiPtr = Hpsi.begin(); + Type* __restrict__ HpsiPtr = tHpsi.ref().begin(); const Type* __restrict__ psiPtr = psi.begin(); diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C index cafd283abb9bff4d5ff3e9890bc5f0f52e0aaaf7..ed7eb4d260be9f3831f8a7a99766ce30895aad05 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C @@ -35,7 +35,7 @@ Description template<class Type> Foam::tmp<Foam::Field<Type>> Foam::lduMatrix::H(const Field<Type>& psi) const { - auto tHpsi = tmp<Field<Type>>::New(lduAddr().size(), Zero); + auto tHpsi = tmp<Field<Type>>::New(lduAddr().size(), Foam::zero{}); if (lowerPtr_ || upperPtr_) { diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 00480e7669db546e5701e3cea89c840d08db0449..5aba0e0d2f48d0e364ebb85e2975125929fa1d4a 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -1195,7 +1195,7 @@ void Foam::polyMesh::movePoints(const pointField& newPoints) { if (debug) { - Info<< "tmp<scalarField> polyMesh::movePoints(const pointField&) : " + Info<< "void polyMesh::movePoints(const pointField&) : " << " Storing current points for time " << time().value() << " index " << time().timeIndex() << endl; } diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C index 1a5e79754c9bad7b293ecdff0d7572a0086cdbdb..3f2530d6da8919293d6e46096c4382e97650cf92 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C @@ -333,8 +333,8 @@ const Foam::vectorField::subField Foam::polyPatch::faceAreas() const Foam::tmp<Foam::vectorField> Foam::polyPatch::faceCellCentres() const { - tmp<vectorField> tcc(new vectorField(size())); - vectorField& cc = tcc.ref(); + auto tcc = tmp<vectorField>::New(size()); + auto& cc = tcc.ref(); // get reference to global cell centres const vectorField& gcc = boundaryMesh_.mesh().cellCentres(); @@ -352,8 +352,8 @@ Foam::tmp<Foam::vectorField> Foam::polyPatch::faceCellCentres() const Foam::tmp<Foam::scalarField> Foam::polyPatch::areaFraction() const { - tmp<scalarField> tfraction(new scalarField(size())); - scalarField& fraction = tfraction.ref(); + auto tfraction = tmp<scalarField>::New(size()); + auto& fraction = tfraction.ref(); const vectorField::subField faceAreas = this->faceAreas(); const pointField& points = this->points(); diff --git a/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C b/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C index ef431b1d9e40eadaef70b1ef70b0456a1b324d48..4197ef6bac7a9e4016864aff75056dbb16e86cd2 100644 --- a/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C +++ b/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C @@ -295,46 +295,31 @@ void Foam::interfaceTrackingFvMesh::makeControlPoints() << abort(FatalError); } - IOobject controlPointsHeader + IOobject pointsIO ( "controlPoints", mesh().time().timeName(), mesh(), - IOobject::MUST_READ + IOobject::MUST_READ, + IOobject::AUTO_WRITE, + IOobject::REGISTER ); - if (controlPointsHeader.typeHeaderOk<vectorIOField>()) + if (pointsIO.typeHeaderOk<vectorIOField>()) { Info<< "Reading control points" << endl; - controlPointsPtr_ = - new vectorIOField - ( - IOobject - ( - "controlPoints", - mesh().time().timeName(), - mesh(), - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ) - ); + controlPointsPtr_ = new vectorIOField(pointsIO); } else { + pointsIO.readOpt(IOobject::NO_READ); + Info<< "Creating new control points" << endl; - controlPointsPtr_ = - new vectorIOField - ( - IOobject - ( - "controlPoints", - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - aMesh().areaCentres().internalField() - ); + controlPointsPtr_ = new vectorIOField + ( + pointsIO, + aMesh().areaCentres().internalField() + ); initializeControlPointsPosition(); } diff --git a/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C b/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C index 2c6eb27b362e40754ea701c63d82a6653fa5e597..43f12a7cd7ee6e7a727bef2b4d19a8e3c94bc091 100644 --- a/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C +++ b/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C @@ -47,8 +47,8 @@ Foam::tmp<Foam::vectorField> Foam::layerAdditionRemoval::extrusionDir() const const pointField& points = mesh.points(); const labelList& mp = masterFaceLayer.meshPoints(); - tmp<vectorField> textrusionDir(new vectorField(mp.size())); - vectorField& extrusionDir = textrusionDir.ref(); + auto textrusionDir = tmp<vectorField>::New(mp.size()); + auto& extrusionDir = textrusionDir.ref(); if (setLayerPairing()) { diff --git a/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C b/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C index dbd93a73fbcbcca1cbd7a75102ab5e84b46fa5b9..2026e4e09e424b11f20057ed50ce9e8ef0b25546 100644 --- a/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C +++ b/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C @@ -339,8 +339,8 @@ Foam::displacementInterpolationMotionSolver::curPoints() const << " points." << exit(FatalError); } - tmp<pointField> tcurPoints(new pointField(points0())); - pointField& curPoints = tcurPoints.ref(); + auto tcurPoints = tmp<pointField>::New(points0()); + auto& curPoints = tcurPoints.ref(); // Interpolate the displacement of the face zones. vectorField zoneDisp(displacements_.size(), Zero); diff --git a/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C b/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C index 5b88d28c57265ef576651d4d7f3dcd209ec01c15..645be3cea28295c511a2db6c1b1b2838e8d62ce0 100644 --- a/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C +++ b/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -338,14 +338,9 @@ void Foam::displacementLayeredMotionMotionSolver::cellZoneSolve patchi, new pointVectorField ( - IOobject + mesh().newIOobject ( - mesh().cellZones()[cellZoneI].name() + "_" + fz.name(), - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER + mesh().cellZones()[cellZoneI].name() + "_" + fz.name() ), pointDisplacement_ // to inherit the boundary conditions ) @@ -429,20 +424,18 @@ void Foam::displacementLayeredMotionMotionSolver::cellZoneSolve if (debug) { // Normalised distance - pointScalarField distance + auto tdistance = pointScalarField::New ( - IOobject + IOobject::scopedName ( - mesh().cellZones()[cellZoneI].name() + ":distance", - mesh().time().timeName(), - mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER + mesh().cellZones()[cellZoneI].name(), + "distance" ), + IOobject::NO_REGISTER, pointMesh::New(mesh()), dimensionedScalar(dimLength, Zero) ); + auto& distance = tdistance.ref(); for (const label pointi : isZonePoint) { diff --git a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C index 16314968ad17d68b15aff962ff2707999654d3df..3db5770d1799b37f30293d17e2abb0e45e413ef3 100644 --- a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C @@ -664,8 +664,8 @@ Foam::tmp<Foam::labelField> Foam::pairPatchAgglomeration::agglomerateOneLevel { const label nFineFaces = patch.size(); - tmp<labelField> tcoarseCellMap(new labelField(nFineFaces, -1)); - labelField& coarseCellMap = tcoarseCellMap.ref(); + auto tcoarseCellMap = tmp<labelField>::New(nFineFaces, -1); + auto& coarseCellMap = tcoarseCellMap.ref(); const labelListList& faceFaces = patch.faceFaces(); diff --git a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C index c0656e0516e149060fc79d80ef0ad39e9b6c04bc..541cc4882baa91673d2e68db748301940330e339 100644 --- a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C @@ -186,8 +186,8 @@ Foam::displacementComponentLaplacianFvMotionSolver::curPoints() const } else { - tmp<pointField> tcurPoints(new pointField(fvMesh_.points())); - pointField& curPoints = tcurPoints.ref(); + auto tcurPoints = tmp<pointField>::New(fvMesh_.points()); + auto& curPoints = tcurPoints.ref(); curPoints.replace ( diff --git a/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C index 68d95d1f981a185bde6a83352ceb587c6aaed84c..9fd45f1149add61e5808ba6f8cc76bc76327faba 100644 --- a/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C @@ -104,7 +104,7 @@ Foam::velocityComponentLaplacianFvMotionSolver::curPoints() const pointMotionU_ ); - tmp<pointField> tcurPoints(new pointField(fvMesh_.points())); + auto tcurPoints = tmp<pointField>::New(fvMesh_.points()); tcurPoints.ref().replace ( diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/surfaceAlignedSBRStress/surfaceAlignedSBRStressFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/surfaceAlignedSBRStress/surfaceAlignedSBRStressFvMotionSolver.C index 0d6c19e100ce7088224aa1e595f860bc377f091a..f886e65d230e0ed5500f4b952c5e3ac931a23f3e 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/surfaceAlignedSBRStress/surfaceAlignedSBRStressFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/surfaceAlignedSBRStress/surfaceAlignedSBRStressFvMotionSolver.C @@ -301,28 +301,18 @@ void Foam::surfaceAlignedSBRStressFvMotionSolver::solve() // Calculate rotations on surface intersection calculateCellRot(); - tmp<volVectorField> tUd + auto tUd = volVectorField::New ( - new volVectorField + "Ud", + IOobject::NO_REGISTER, + fvMesh_, + dimensionedVector(dimLength, Zero), + cellMotionBoundaryTypes<vector> ( - IOobject - ( - "Ud", - fvMesh_.time().timeName(), - fvMesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - fvMesh_, - dimensionedVector(dimLength, Zero), - cellMotionBoundaryTypes<vector> - ( - pointDisplacement().boundaryField() - ) + pointDisplacement().boundaryField() ) ); - - volVectorField& Ud = tUd.ref(); + auto& Ud = tUd.ref(); const vectorList& C = fvMesh_.C(); forAll(Ud, i) @@ -346,23 +336,14 @@ void Foam::surfaceAlignedSBRStressFvMotionSolver::solve() const volTensorField gradD("gradD", fvc::grad(Ud)); - tmp<volScalarField> tmu + auto tmu = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "mu", - fvMesh_.time().timeName(), - fvMesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - fvMesh_, - dimensionedScalar(dimless, Zero) - ) + "mu", + IOobject::NO_REGISTER, + fvMesh_, + dimensionedScalar(dimless, Zero) ); - volScalarField& mu = tmu.ref(); + auto& mu = tmu.ref(); const scalarList& V = fvMesh_.V(); mu.primitiveFieldRef() = (1.0/V); diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C index 2f857a3d56e2177c8bfc2542e0e6b4f470267a66..072e39dfeb96c22a7959ab2b334a190725f972d3 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C @@ -113,8 +113,8 @@ Foam::tmp<Foam::scalarField> Foam::snappyLayerDriver::avgPointData const scalarField& pointFld ) { - tmp<scalarField> tfaceFld(new scalarField(pp.size(), Zero)); - scalarField& faceFld = tfaceFld.ref(); + auto tfaceFld = tmp<scalarField>::New(pp.size(), Zero); + auto& faceFld = tfaceFld.ref(); forAll(pp.localFaces(), facei) { diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C index 9667c05783780be1afd9592239c591752e653eaa..b38620a13f0a1f24ce4097181558c9987567bc49 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C @@ -257,8 +257,8 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothInternalDisplacement // Add coupled contributions weightedPosition::syncPoints(mesh, sumLocation); - tmp<pointField> tdisplacement(new pointField(mesh.nPoints(), Zero)); - pointField& displacement = tdisplacement.ref(); + auto tdisplacement = tmp<pointField>::New(mesh.nPoints(), Zero); + auto& displacement = tdisplacement.ref(); label nAdapted = 0; @@ -490,8 +490,8 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothPatchDisplacement // Displacement to calculate. - tmp<pointField> tpatchDisp(new pointField(meshPoints.size(), Zero)); - pointField& patchDisp = tpatchDisp.ref(); + auto tpatchDisp = tmp<pointField>::New(meshPoints.size(), Zero); + auto& patchDisp = tpatchDisp.ref(); forAll(pointFaces, i) { @@ -571,8 +571,8 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothPatchDisplacement // const labelListList& pointEdges = pp.pointEdges(); // const edgeList& edges = pp.edges(); // -// tmp<pointField> tavg(new pointField(pointEdges.size(), Zero)); -// pointField& avg = tavg(); +// auto tavg = tmp<pointField>::New(pointEdges.size(), Zero); +// auto& avg = tavg.ref(); // // forAll(pointEdges, verti) // { @@ -658,8 +658,8 @@ Foam::tmp<Foam::scalarField> Foam::snappySnapDriver::edgePatchDist ); // Copy edge values into scalarField - tmp<scalarField> tedgeDist(new scalarField(mesh.nEdges())); - scalarField& edgeDist = tedgeDist.ref(); + auto tedgeDist = tmp<scalarField>::New(mesh.nEdges()); + auto& edgeDist = tedgeDist.ref(); forAll(allEdgeInfo, edgei) { @@ -1057,7 +1057,7 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::avgCellCentres // Add coupled contributions weightedPosition::syncPoints(mesh, pp.meshPoints(), avgBoundary); - tmp<pointField> tavgBoundary(new pointField(avgBoundary.size())); + auto tavgBoundary = tmp<pointField>::New(avgBoundary.size()); weightedPosition::getPoints(avgBoundary, tavgBoundary.ref()); return tavgBoundary; @@ -1073,8 +1073,8 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::avgCellCentres // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // (Ripped from snappyLayerDriver) // -// tmp<scalarField> tedgeLen(new scalarField(pp.nPoints())); -// scalarField& edgeLen = tedgeLen(); +// auto tedgeLen = tmp<scalarField>::New(pp.nPoints()); +// auto& edgeLen = tedgeLen.ref(); // { // const fvMesh& mesh = meshRefiner_.mesh(); // const scalar edge0Len = meshRefiner_.meshCutter().level0EdgeLength(); diff --git a/src/meshTools/cellQuality/cellQuality.C b/src/meshTools/cellQuality/cellQuality.C index 2ee6a6c4c3d63c46af240a9917b128e8dba711e3..fc5f7df520000a8a89f880e3ea75b9b3af55c1e1 100644 --- a/src/meshTools/cellQuality/cellQuality.C +++ b/src/meshTools/cellQuality/cellQuality.C @@ -41,15 +41,8 @@ Foam::cellQuality::cellQuality(const polyMesh& mesh) Foam::tmp<Foam::scalarField> Foam::cellQuality::nonOrthogonality() const { - tmp<scalarField> tresult - ( - new scalarField - ( - mesh_.nCells(), 0.0 - ) - ); - - scalarField& result = tresult.ref(); + auto tresult = tmp<scalarField>::New(mesh_.nCells(), Zero); + auto& result = tresult.ref(); scalarField sumArea(mesh_.nCells(), Zero); @@ -103,14 +96,8 @@ Foam::tmp<Foam::scalarField> Foam::cellQuality::nonOrthogonality() const Foam::tmp<Foam::scalarField> Foam::cellQuality::skewness() const { - tmp<scalarField> tresult - ( - new scalarField - ( - mesh_.nCells(), 0.0 - ) - ); - scalarField& result = tresult.ref(); + auto tresult = tmp<scalarField>::New(mesh_.nCells(), Zero); + auto& result = tresult.ref(); scalarField sumArea(mesh_.nCells(), Zero); @@ -182,15 +169,8 @@ Foam::tmp<Foam::scalarField> Foam::cellQuality::skewness() const Foam::tmp<Foam::scalarField> Foam::cellQuality::faceNonOrthogonality() const { - tmp<scalarField> tresult - ( - new scalarField - ( - mesh_.nFaces(), 0.0 - ) - ); - scalarField& result = tresult.ref(); - + auto tresult = tmp<scalarField>::New(mesh_.nFaces(), Zero); + auto& result = tresult.ref(); const vectorField& centres = mesh_.cellCentres(); const vectorField& areas = mesh_.faceAreas(); @@ -242,15 +222,8 @@ Foam::tmp<Foam::scalarField> Foam::cellQuality::faceNonOrthogonality() const Foam::tmp<Foam::scalarField> Foam::cellQuality::faceSkewness() const { - tmp<scalarField> tresult - ( - new scalarField - ( - mesh_.nFaces(), 0.0 - ) - ); - scalarField& result = tresult.ref(); - + auto tresult = tmp<scalarField>::New(mesh_.nFaces(), Zero); + auto& result = tresult.ref(); const vectorField& cellCtrs = mesh_.cellCentres(); const vectorField& faceCtrs = mesh_.faceCentres(); diff --git a/src/meshTools/edgeMesh/edgeMeshTools/edgeMeshFeatureProximity.C b/src/meshTools/edgeMesh/edgeMeshTools/edgeMeshFeatureProximity.C index fbb851e4b377f14d4509a0b7e5079f7fea4b3b9a..6458779c7f6321c3cbe210ff45e51ebc18d7d10c 100644 --- a/src/meshTools/edgeMesh/edgeMeshTools/edgeMeshFeatureProximity.C +++ b/src/meshTools/edgeMesh/edgeMeshTools/edgeMeshFeatureProximity.C @@ -143,8 +143,8 @@ Foam::tmp<Foam::scalarField> Foam::edgeMeshTools::featureProximity const scalar searchDistance ) { - tmp<scalarField> tfld(new scalarField(surf.size(), searchDistance)); - scalarField& featureProximity = tfld.ref(); + auto tfld = tmp<scalarField>::New(surf.size(), searchDistance); + auto& featureProximity = tfld.ref(); Info<< "Extracting proximity of close feature points and " << "edges to the surface" << endl; diff --git a/src/meshTools/momentOfInertia/momentOfInertia.C b/src/meshTools/momentOfInertia/momentOfInertia.C index 3ea48e847237bd3c0f614db89c1b2190397ccfff..ffb296a3a02e874d52fb349fd3166dd77d849539 100644 --- a/src/meshTools/momentOfInertia/momentOfInertia.C +++ b/src/meshTools/momentOfInertia/momentOfInertia.C @@ -354,9 +354,8 @@ Foam::tmp<Foam::tensorField> Foam::momentOfInertia::meshInertia const polyMesh& mesh ) { - tmp<tensorField> tTf = tmp<tensorField>(new tensorField(mesh.nCells())); - - tensorField& tf = tTf.ref(); + auto tTf = tmp<tensorField>::New(mesh.nCells()); + auto& tf = tTf.ref(); forAll(tf, cI) { diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceCloseness.C b/src/meshTools/triSurface/triSurfaceTools/triSurfaceCloseness.C index c47ee9e62fd3d36dd0a2927dbce7518c332af8d2..b9add2217b7f6f3cba5dc3fbae0b07bfeca0bbf2 100644 --- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceCloseness.C +++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceCloseness.C @@ -103,8 +103,8 @@ Foam::triSurfaceTools::writeCloseness { Pair<tmp<scalarField>> tpair ( - tmp<scalarField>(new scalarField(surf.size(), GREAT)), - tmp<scalarField>(new scalarField(surf.size(), GREAT)) + tmp<scalarField>::New(surf.size(), GREAT), + tmp<scalarField>::New(surf.size(), GREAT) ); Info<< "Extracting internal and external closeness of surface." << endl; diff --git a/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C b/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C index bb441cb79a2e2c91c8be0b0c50df88614b36e290..80237911108c8e90b10d9df3699f4a235f0c38f8 100644 --- a/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C +++ b/src/overset/cellCellStencil/cellCellStencil/cellCellStencilTemplates.C @@ -158,22 +158,15 @@ Foam::cellCellStencil::createField const UList<Type>& psi ) { - auto tfld = tmp<volScalarField>::New + auto tfld = volScalarField::New ( - IOobject - ( - name, - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + name, + IOobject::NO_REGISTER, mesh, dimensionedScalar(dimless, Zero), fvPatchFieldBase::zeroGradientType() ); - volScalarField& fld = tfld.ref(); + auto& fld = tfld.ref(); forAll(psi, cellI) { diff --git a/src/overset/oversetPolyPatch/oversetFvPatchField.C b/src/overset/oversetPolyPatch/oversetFvPatchField.C index 3beba4a72f3c05bf72e76fceebd70ee225bcd590..1ab511b730d0ca29c61e99f939b57cd34b17a199 100644 --- a/src/overset/oversetPolyPatch/oversetFvPatchField.C +++ b/src/overset/oversetPolyPatch/oversetFvPatchField.C @@ -585,10 +585,7 @@ template<class Type> Foam::tmp<Foam::Field<Type>> Foam::oversetFvPatchField<Type>:: patchNeighbourField() const { - return tmp<Field<Type>> - ( - new Field<Type>(this->size(), Zero) - ); + return tmp<Field<Type>>::New(this->size(), Zero); } diff --git a/src/overset/oversetPolyPatch/oversetFvPatchField.H b/src/overset/oversetPolyPatch/oversetFvPatchField.H index cb22fb67268188854425c16fde958ee53e5b6b27..ead67e8fab97d2905aeb84674f53bb864c061569 100644 --- a/src/overset/oversetPolyPatch/oversetFvPatchField.H +++ b/src/overset/oversetPolyPatch/oversetFvPatchField.H @@ -195,10 +195,7 @@ public: const tmp<scalarField>& ) const { - return tmp<Field<Type>> - ( - new Field<Type>(this->size(), Zero) - ); + return tmp<Field<Type>>::New(this->size(), Foam::zero{}); } //- Return the matrix source coefficients corresponding to the @@ -208,30 +205,21 @@ public: const tmp<scalarField>& ) const { - return tmp<Field<Type>> - ( - new Field<Type>(this->size(), Zero) - ); + return tmp<Field<Type>>::New(this->size(), Foam::zero{}); } //- Return the matrix diagonal coefficients corresponding to the //- evaluation of the gradient of this patchField tmp<Field<Type>> gradientInternalCoeffs() const { - return tmp<Field<Type>> - ( - new Field<Type>(this->size(), Zero) - ); + return tmp<Field<Type>>::New(this->size(), Foam::zero{}); } //- Return the matrix source coefficients corresponding to the //- evaluation of the gradient of this patchField tmp<Field<Type>> gradientBoundaryCoeffs() const { - return tmp<Field<Type>> - ( - new Field<Type>(this->size(), Zero) - ); + return tmp<Field<Type>>::New(this->size(), Foam::zero{}); } //- Manipulate matrix diff --git a/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.C b/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.C index cc03840da3e66f653c676846a7617f52880abc75..88cdd4e3af2157d3ccd86869844f05b96f999ac0 100644 --- a/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.C +++ b/src/rigidBodyDynamics/rigidBodyMotion/rigidBodyMotion.C @@ -238,8 +238,8 @@ Foam::tmp<Foam::pointField> Foam::RBD::rigidBodyMotion::transformPoints // to the current state in the global frame spatialTransform X(X0(bodyID).inv() & X00(bodyID)); - tmp<pointField> tpoints(new pointField(initialPoints.size())); - pointField& points = tpoints.ref(); + auto tpoints = tmp<pointField>::New(initialPoints.size()); + auto& points = tpoints.ref(); forAll(points, i) { @@ -265,8 +265,8 @@ Foam::tmp<Foam::pointField> Foam::RBD::rigidBodyMotion::transformPoints // interpolation septernion s(X); - tmp<pointField> tpoints(new pointField(initialPoints)); - pointField& points = tpoints.ref(); + auto tpoints = tmp<pointField>::New(initialPoints); + auto& points = tpoints.ref(); forAll(points, i) { @@ -314,8 +314,8 @@ Foam::tmp<Foam::pointField> Foam::RBD::rigidBodyMotion::transformPoints ss[bi] = septernion(X); } - tmp<pointField> tpoints(new pointField(initialPoints)); - pointField& points = tpoints.ref(); + auto tpoints = tmp<pointField>::New(initialPoints); + auto& points = tpoints.ref(); List<scalar> w(ss.size()); diff --git a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C index 780844e6e7ae6f12486516d135d40722ac45f28d..e7f4d71072a2c5d45357e751b05d6d562a2512da 100644 --- a/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C +++ b/src/rigidBodyMeshMotion/rigidBodyMeshMotion/rigidBodyMeshMotion.C @@ -224,8 +224,8 @@ Foam::rigidBodyMeshMotion::curPoints() const } else { - tmp<pointField> ttransformedPts(new pointField(mesh().points())); - pointField& transformedPts = ttransformedPts.ref(); + auto ttransformedPts = tmp<pointField>::New(mesh().points()); + auto& transformedPts = ttransformedPts.ref(); UIndirectList<point>(transformedPts, pointIDs()) = pointField(newPoints.ref(), pointIDs()); diff --git a/src/sampling/meshToMesh/meshToMeshTemplates.C b/src/sampling/meshToMesh/meshToMeshTemplates.C index a1f8b6f637b466d3adb0a38ac226dd35dd9df35b..a1df9365556f55401fc965a30bee52778e41cb77 100644 --- a/src/sampling/meshToMesh/meshToMeshTemplates.C +++ b/src/sampling/meshToMesh/meshToMeshTemplates.C @@ -218,14 +218,7 @@ Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapSrcToTgt const CombineOp& cop ) const { - tmp<Field<Type>> tresult - ( - new Field<Type> - ( - tgtToSrcCellAddr_.size(), - Zero - ) - ); + auto tresult = tmp<Field<Type>>::New(tgtToSrcCellAddr_.size(), Zero); mapSrcToTgt(srcField, cop, tresult.ref()); @@ -423,14 +416,7 @@ Foam::tmp<Foam::Field<Type>> Foam::meshToMesh::mapTgtToSrc const CombineOp& cop ) const { - tmp<Field<Type>> tresult - ( - new Field<Type> - ( - srcToTgtCellAddr_.size(), - Zero - ) - ); + auto tresult = tmp<Field<Type>>::New(srcToTgtCellAddr_.size(), Zero); mapTgtToSrc(tgtField, cop, tresult.ref()); @@ -645,13 +631,13 @@ Foam::meshToMesh::mapSrcToTgt auto tresult = tmp<VolumeField<Type>>::New ( - IOobject + tgtMesh.newIOobject ( - type() + ":interpolate(" + field.name() + ")", - tgtMesh.time().timeName(), - tgtMesh, - IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::scopedName + ( + type(), + "interpolate(" + field.name() + ")" + ) ), tgtMesh, field.dimensions(), @@ -876,13 +862,13 @@ Foam::meshToMesh::mapTgtToSrc auto tresult = tmp<VolumeField<Type>>::New ( - IOobject + srcMesh.newIOobject ( - type() + ":interpolate(" + field.name() + ")", - srcMesh.time().timeName(), - srcMesh, - IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::scopedName + ( + type(), + "interpolate(" + field.name() + ")" + ) ), srcMesh, field.dimensions(), diff --git a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C index 17cb45fb9e893a9b55897fa624e289d1274f608a..2d47649cd5e48ec412c34590e4fcf41fb1795adc 100644 --- a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C +++ b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C @@ -464,20 +464,12 @@ void Foam::sampledCuttingPlane::createGeometry() ( new volScalarField ( - IOobject - ( - "cellDistance", - mesh.time().timeName(), - mesh.time(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + mesh.newIOobject("cellDistance"), mesh, dimensionedScalar(dimLength, Zero) ) ); - const volScalarField& cellDistance = cellDistancePtr_(); + const auto& cellDistance = *cellDistancePtr_; setDistanceFields(plane_); @@ -485,20 +477,15 @@ void Foam::sampledCuttingPlane::createGeometry() { Pout<< "Writing cell distance:" << cellDistance.objectPath() << endl; cellDistance.write(); - pointScalarField pointDist + auto tpointDist = pointScalarField::New ( - IOobject - ( - "pointDistance", - mesh.time().timeName(), - mesh.time(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "pointDistance", + IOobject::NO_REGISTER, pointMesh::New(mesh), dimensionedScalar(dimLength, Zero) ); + auto& pointDist = tpointDist.ref(); + pointDist.primitiveFieldRef() = pointDistance_; Pout<< "Writing point distance:" << pointDist.objectPath() << endl; diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C index 349493e09622564876eed2fa9da9dff8c742e95b..9b0e0a592efb0abe4079c663ba70138b1d848573 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion/sixDoFRigidBodyMotion.C @@ -393,8 +393,8 @@ Foam::tmp<Foam::pointField> Foam::sixDoFRigidBodyMotion::transform quaternion(Q().T() & initialQ()) ); - tmp<pointField> tpoints(new pointField(initialPoints)); - pointField& points = tpoints.ref(); + auto tpoints = tmp<pointField>::New(initialPoints); + auto& points = tpoints.ref(); forAll(points, pointi) { diff --git a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C index 267fc1964304e01b7f3cd14444e4d7333dd616a6..33de436dcf9b2d00637c4748ef3fae610f414bae 100644 --- a/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C +++ b/src/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionSolver/sixDoFRigidBodyMotionSolver.C @@ -173,8 +173,8 @@ Foam::sixDoFRigidBodyMotionSolver::curPoints() const if (!moveAllCells()) { - tmp<pointField> ttransformedPts(new pointField(mesh().points())); - pointField& transformedPts = ttransformedPts.ref(); + auto ttransformedPts = tmp<pointField>::New(mesh().points()); + auto& transformedPts = ttransformedPts.ref(); UIndirectList<point>(transformedPts, pointIDs()) = pointField(newPoints.ref(), pointIDs()); diff --git a/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C b/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C index 4e56adeb3d8a92b1c59a54c11a9cf30ee7435ff0..d4dc7990d4ffaaa0242ab4e2414bbd0c7b28fbb8 100644 --- a/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C +++ b/src/topoChangerFvMesh/linearValveLayersFvMesh/linearValveLayersFvMesh.C @@ -275,12 +275,8 @@ bool Foam::linearValveLayersFvMesh::attached() const Foam::tmp<Foam::pointField> Foam::linearValveLayersFvMesh::newPoints() const { - tmp<pointField> tnewPoints - ( - new pointField(points()) - ); - - pointField& np = tnewPoints(); + auto tnewPoints = tmp<pointField>::New(points()); + auto& np = tnewPoints(); const word layerPatchName ( diff --git a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C index 51221b8fadfe0287f10ecd6ef0e79b3d3b5fb543..0b0d1e8bef5136639a9bdaed29285a770b60489d 100644 --- a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C +++ b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C @@ -70,8 +70,8 @@ Foam::tmp<Foam::scalarField> Foam::movingConeTopoFvMesh::vertexMarkup Info<< "Updating vertex markup. curLeft: " << curLeft << " curRight: " << curRight << endl; - tmp<scalarField> tvertexMarkup(new scalarField(p.size())); - scalarField& vertexMarkup = tvertexMarkup.ref(); + auto tvertexMarkup = tmp<scalarField>::New(p.size()); + auto& vertexMarkup = tvertexMarkup.ref(); forAll(p, pI) {