diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/basic/basic.C b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/basic/basic.C index ed72bbe540..b48af20fea 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/basic/basic.C +++ b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/basic/basic.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -93,24 +94,14 @@ Foam::PDRDragModels::basic::~basic() Foam::tmp Foam::PDRDragModels::basic::Dcu() const { - tmp tDragDcu + auto tDragDcu = volSymmTensorField::New ( - new volSymmTensorField - ( - IOobject - ( - "tDragDcu", - U_.mesh().time().constant(), - U_.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - U_.mesh(), - dimensionedSymmTensor(dimMass/dimTime/dimVolume, Zero) - ) + "tDragDcu", + IOobject::NO_REGISTER, + U_.mesh(), + dimensionedSymmTensor(dimMass/dimTime/dimVolume, Zero) ); - - volSymmTensorField& DragDcu = tDragDcu.ref(); + auto& DragDcu = tDragDcu.ref(); if (on_) { @@ -127,24 +118,14 @@ Foam::tmp Foam::PDRDragModels::basic::Dcu() const Foam::tmp Foam::PDRDragModels::basic::Gk() const { - tmp tGk + auto tGk = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "tGk", - U_.mesh().time().constant(), - U_.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - U_.mesh(), - dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) - ) + "tGk", + IOobject::NO_REGISTER, + U_.mesh(), + dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); - - volScalarField& Gk = tGk.ref(); + auto& Gk = tGk.ref(); if (on_) { diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.C b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.C index b80b72a4c7..04f977f208 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.C +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -93,23 +94,14 @@ Foam::tmp Foam::XiEqModels::SCOPEXiEq::XiEq() const volScalarField K(0.157*upBySu/sqrt(Rl)); volScalarField Ma(MaModel.Ma()); - tmp tXiEq + auto tXiEq = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "XiEq", - epsilon.time().timeName(), - epsilon.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - epsilon.mesh(), - dimensionedScalar(dimless, Zero) - ) + "XiEq", + IOobject::NO_REGISTER, + epsilon.mesh(), + dimensionedScalar(dimless, Zero) ); - volScalarField& xieq = tXiEq.ref(); + auto& xieq = tXiEq.ref(); forAll(xieq, celli) { diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModel.C b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModel.C index 084ffc1aef..5d87437f6c 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModel.C +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModel.C @@ -78,11 +78,10 @@ bool Foam::XiEqModel::read(const dictionary& XiEqProperties) void Foam::XiEqModel::writeFields() const { //***HGW It is not clear why B is written here - if (Su_.mesh().foundObject("B")) + const auto* B = Su_.mesh().cfindObject("B"); + if (B) { - const volSymmTensorField& B = - Su_.mesh().lookupObject("B"); - B.write(); + B->write(); } } @@ -98,39 +97,26 @@ Foam::XiEqModel::calculateSchelkinEffect(const scalar uPrimeCoef) const const volSymmTensorField& nsv = mesh.lookupObject("nsv"); - tmp tN + auto tN = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "tN", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh, - dimensionedScalar(Nv.dimensions(), Zero) - ) + "tN", + IOobject::NO_REGISTER, + mesh, + dimensionedScalar(Nv.dimensions(), Zero) ); - volScalarField& N = tN.ref(); + auto& N = tN.ref(); + N.primitiveFieldRef() = Nv.primitiveField()*pow(mesh.V(), 2.0/3.0); - volSymmTensorField ns + auto tns = volSymmTensorField::New ( - IOobject - ( - "tns", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "tns", + IOobject::NO_REGISTER, mesh, dimensionedSymmTensor(nsv.dimensions(), Zero) ); + auto& ns = tns.ref(); + ns.primitiveFieldRef() = nsv.primitiveField()*pow(mesh.V(), 2.0/3.0); const volVectorField Uhat diff --git a/applications/solvers/combustion/PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.C b/applications/solvers/combustion/PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.C index 6c9a7e1085..805c2f5989 100644 --- a/applications/solvers/combustion/PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.C +++ b/applications/solvers/combustion/PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -255,24 +256,14 @@ Foam::tmp Foam::laminarFlameSpeedModels::SCOPE::Su0pTphi scalar phi ) const { - tmp tSu0 + auto tSu0 = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Su0", - p.time().timeName(), - p.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - p.mesh(), - dimensionedScalar(dimVelocity, Zero) - ) + "Su0", + IOobject::NO_REGISTER, + p.mesh(), + dimensionedScalar(dimVelocity, Zero) ); - - volScalarField& Su0 = tSu0.ref(); + auto& Su0 = tSu0.ref(); forAll(Su0, celli) { @@ -304,24 +295,14 @@ Foam::tmp Foam::laminarFlameSpeedModels::SCOPE::Su0pTphi const volScalarField& phi ) const { - tmp tSu0 + auto tSu0 = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Su0", - p.time().timeName(), - p.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - p.mesh(), - dimensionedScalar(dimVelocity, Zero) - ) + "Su0", + IOobject::NO_REGISTER, + p.mesh(), + dimensionedScalar(dimVelocity, Zero) ); - - volScalarField& Su0 = tSu0.ref(); + auto& Su0 = tSu0.ref(); forAll(Su0, celli) { @@ -358,24 +339,14 @@ Foam::tmp Foam::laminarFlameSpeedModels::SCOPE::Ma const volScalarField& phi ) const { - tmp tMa + auto tMa = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Ma", - phi.time().timeName(), - phi.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - phi.mesh(), - dimensionedScalar(dimless, Zero) - ) + "Ma", + IOobject::NO_REGISTER, + phi.mesh(), + dimensionedScalar(dimless, Zero) ); - - volScalarField& ma = tMa.ref(); + auto& ma = tMa.ref(); forAll(ma, celli) { @@ -418,21 +389,12 @@ Foam::laminarFlameSpeedModels::SCOPE::Ma() const { const fvMesh& mesh = psiuReactionThermo_.p().mesh(); - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Ma", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh, - dimensionedScalar("Ma", dimless, Ma(equivalenceRatio_)) - ) + "Ma", + IOobject::NO_REGISTER, + mesh, + dimensionedScalar("Ma", dimless, Ma(equivalenceRatio_)) ); } } diff --git a/applications/solvers/combustion/fireFoam/phrghEqn.H b/applications/solvers/combustion/fireFoam/phrghEqn.H index 482355f12a..022006494f 100644 --- a/applications/solvers/combustion/fireFoam/phrghEqn.H +++ b/applications/solvers/combustion/fireFoam/phrghEqn.H @@ -10,7 +10,8 @@ if (pimple.dict().getOrDefault("hydrostaticInitialization", false)) "0", mesh, IOobject::MUST_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), mesh ) diff --git a/applications/solvers/multiphase/MPPICInterFoam/alphaEqnSubCycle.H b/applications/solvers/multiphase/MPPICInterFoam/alphaEqnSubCycle.H index 16269f7c4c..392a953b6a 100644 --- a/applications/solvers/multiphase/MPPICInterFoam/alphaEqnSubCycle.H +++ b/applications/solvers/multiphase/MPPICInterFoam/alphaEqnSubCycle.H @@ -3,12 +3,7 @@ if (nAlphaSubCycles > 1) dimensionedScalar totalDeltaT = runTime.deltaT(); surfaceScalarField rhoPhiSum ( - IOobject - ( - "rhoPhiSum", - runTime.timeName(), - mesh - ), + mesh.newIOobject("rhoPhiSum"), mesh, dimensionedScalar(rhoPhi.dimensions(), Zero) ); diff --git a/applications/solvers/multiphase/VoF/alphaEqnSubCycle.H b/applications/solvers/multiphase/VoF/alphaEqnSubCycle.H index c53d6e106b..9ca190cb6f 100644 --- a/applications/solvers/multiphase/VoF/alphaEqnSubCycle.H +++ b/applications/solvers/multiphase/VoF/alphaEqnSubCycle.H @@ -3,12 +3,7 @@ if (nAlphaSubCycles > 1) dimensionedScalar totalDeltaT = runTime.deltaT(); surfaceScalarField rhoPhiSum ( - IOobject - ( - "rhoPhiSum", - runTime.timeName(), - mesh - ), + mesh.newIOobject("rhoPhiSum"), mesh, dimensionedScalar(rhoPhi.dimensions(), Zero) ); diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleAlphaEqnSubCycle.H b/applications/solvers/multiphase/compressibleInterFoam/compressibleAlphaEqnSubCycle.H index 51dd6ea56c..3f4c977945 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleAlphaEqnSubCycle.H +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleAlphaEqnSubCycle.H @@ -4,26 +4,19 @@ if (nAlphaSubCycles > 1) { dimensionedScalar totalDeltaT = runTime.deltaT(); - talphaPhi1 = new surfaceScalarField + talphaPhi1.reset ( - IOobject + new surfaceScalarField ( - "alphaPhi1", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar(alphaPhi10.dimensions(), Zero) + mesh.newIOobject("alphaPhi1"), + mesh, + dimensionedScalar(alphaPhi10.dimensions(), Zero) + ) ); surfaceScalarField rhoPhiSum ( - IOobject - ( - "rhoPhiSum", - runTime.timeName(), - mesh - ), + mesh.newIOobject("rhoPhiSum"), mesh, dimensionedScalar(rhoPhi.dimensions(), Zero) ); diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterIsoFoam/compressibleAlphaEqnSubCycle.H b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterIsoFoam/compressibleAlphaEqnSubCycle.H index 5fda0912c5..45d4077f4c 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterIsoFoam/compressibleAlphaEqnSubCycle.H +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterIsoFoam/compressibleAlphaEqnSubCycle.H @@ -13,26 +13,19 @@ if (nAlphaSubCycles > 1) { dimensionedScalar totalDeltaT = runTime.deltaT(); - talphaPhi1 = new surfaceScalarField + talphaPhi1.reset ( - IOobject + new surfaceScalarField ( - "alphaPhi1", - runTime.timeName(), - mesh - ), - mesh, - dimensionedScalar(alphaPhi10.dimensions(), Zero) + mesh.newIOobject("alphaPhi1"), + mesh, + dimensionedScalar(alphaPhi10.dimensions(), Zero) + ) ); surfaceScalarField rhoPhiSum ( - IOobject - ( - "rhoPhiSum", - runTime.timeName(), - mesh - ), + mesh.newIOobject("rhoPhiSum"), mesh, dimensionedScalar(rhoPhi.dimensions(), Zero) ); diff --git a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C index 77d276973f..a190682c4a 100644 --- a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C +++ b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C @@ -99,7 +99,8 @@ Foam::multiphaseMixtureThermo::multiphaseMixtureThermo mesh_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimless, Zero) @@ -998,19 +999,12 @@ Foam::tmp Foam::multiphaseMixtureThermo::K Foam::tmp Foam::multiphaseMixtureThermo::nearInterface() const { - tmp tnearInt + auto tnearInt = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "nearInterface", - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedScalar(dimless, Zero) - ) + "nearInterface", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimless, Zero) ); for (const phaseModel& phase : phases_) diff --git a/applications/solvers/multiphase/driftFluxFoam/alphaEqnSubCycle.H b/applications/solvers/multiphase/driftFluxFoam/alphaEqnSubCycle.H index b38144700c..ac51ae482e 100644 --- a/applications/solvers/multiphase/driftFluxFoam/alphaEqnSubCycle.H +++ b/applications/solvers/multiphase/driftFluxFoam/alphaEqnSubCycle.H @@ -18,12 +18,7 @@ dimensionedScalar totalDeltaT = runTime.deltaT(); surfaceScalarField alphaPhiSum ( - IOobject - ( - "alphaPhiSum", - runTime.timeName(), - mesh - ), + mesh.newIOobject("alphaPhiSum"), mesh, dimensionedScalar(phi.dimensions(), Zero) ); diff --git a/applications/solvers/multiphase/driftFluxFoam/relativeVelocityModels/relativeVelocityModel/relativeVelocityModel.C b/applications/solvers/multiphase/driftFluxFoam/relativeVelocityModels/relativeVelocityModel/relativeVelocityModel.C index dc36b96e6a..e88b24f32d 100644 --- a/applications/solvers/multiphase/driftFluxFoam/relativeVelocityModels/relativeVelocityModel/relativeVelocityModel.C +++ b/applications/solvers/multiphase/driftFluxFoam/relativeVelocityModels/relativeVelocityModel/relativeVelocityModel.C @@ -158,13 +158,11 @@ Foam::tmp Foam::relativeVelocityModel::tauDm() const // Calculate the relative velocity of the continuous phase w.r.t the mean volVectorField Ucm(betad*Udm_/betac); - return tmp + return volSymmTensorField::New ( - new volSymmTensorField - ( - "tauDm", - betad*sqr(Udm_) + betac*sqr(Ucm) - ) + "tauDm", + IOobject::NO_REGISTER, + betad*sqr(Udm_) + betac*sqr(Ucm) ); } diff --git a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C index 6524c571ae..40c906b57e 100644 --- a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C +++ b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/laserDTRM.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -407,7 +407,8 @@ Foam::radiation::laserDTRM::laserDTRM(const volScalarField& T) mesh_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimPower/dimVolume, Zero) @@ -504,7 +505,8 @@ Foam::radiation::laserDTRM::laserDTRM mesh_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimPower/pow3(dimLength), Zero) @@ -535,42 +537,23 @@ Foam::label Foam::radiation::laserDTRM::nBands() const void Foam::radiation::laserDTRM::calculate() { - tmp treflectingCells + auto treflectingCells = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "reflectingCellsVol", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar("zero", dimless, -1) - ) + "reflectingCellsVol", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar("zero", dimless, -1) ); - volScalarField& reflectingCellsVol = treflectingCells.ref(); + auto& reflectingCellsVol = treflectingCells.ref(); - - tmp tnHat + auto tnHat = volVectorField::New ( - new volVectorField - ( - IOobject - ( - "nHat", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedVector(dimless, Zero) - ) + "nHat", + IOobject::NO_REGISTER, + mesh_, + dimensionedVector(dimless, Zero) ); - volVectorField& nHat = tnHat.ref(); + auto& nHat = tnHat.ref(); // Reset the field @@ -686,9 +669,9 @@ void Foam::radiation::laserDTRM::calculate() globalIndex::gatherInplaceOp(lines); - if (Pstream::master()) + if (UPstream::master()) { - OBJstream os(type() + ":particlePath.obj"); + OBJstream os(type() + "-particlePath.obj"); for (label pointi = 0; pointi < lines.size(); pointi += 2) { diff --git a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/localDensityAbsorptionEmission/localDensityAbsorptionEmission.C b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/localDensityAbsorptionEmission/localDensityAbsorptionEmission.C index 72e3d08d90..a2cabf5d86 100644 --- a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/localDensityAbsorptionEmission/localDensityAbsorptionEmission.C +++ b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/laserDTRM/localDensityAbsorptionEmission/localDensityAbsorptionEmission.C @@ -88,25 +88,14 @@ Foam::radiation::localDensityAbsorptionEmission::localDensityAbsorptionEmission Foam::tmp Foam::radiation::localDensityAbsorptionEmission::aCont(const label bandI) const { - tmp ta + auto ta = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "a", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(inv(dimLength), Zero) - ) + "a", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(inv(dimLength), Zero) ); - - volScalarField& a = ta.ref(); + auto& a = ta.ref(); forAll(alphaNames_, i) { @@ -121,25 +110,14 @@ Foam::radiation::localDensityAbsorptionEmission::aCont(const label bandI) const Foam::tmp Foam::radiation::localDensityAbsorptionEmission::eCont(const label bandI) const { - tmp te + auto te = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "e", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(inv(dimLength), Zero) - ) + "e", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(inv(dimLength), Zero) ); - - volScalarField& e = te.ref(); + auto& e = te.ref(); forAll(alphaNames_, i) { @@ -154,22 +132,12 @@ Foam::radiation::localDensityAbsorptionEmission::eCont(const label bandI) const Foam::tmp Foam::radiation::localDensityAbsorptionEmission::ECont(const label bandI) const { - tmp tE + auto tE = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "E", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) - ) + "E", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); scalarField& E = tE.ref().primitiveFieldRef(); diff --git a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/constant/constant.C b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/constant/constant.C index 8f1fb0f883..121d3a5027 100644 --- a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/constant/constant.C +++ b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/constant/constant.C @@ -171,16 +171,8 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::TSource() const const volScalarField& T = mesh_.lookupObject("T"); - tmp tTSource - ( - new fvScalarMatrix - ( - T, - dimEnergy/dimTime - ) - ); - - fvScalarMatrix& TSource = tTSource.ref(); + auto tTSource = tmp::New(T, dimEnergy/dimTime); + auto& TSource = tTSource.ref(); const twoPhaseMixtureEThermo& thermo = refCast diff --git a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.C b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.C index 0cf652dbf5..f877106c19 100644 --- a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.C +++ b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/twoPhaseMixtureEThermo/twoPhaseMixtureEThermo.C @@ -382,7 +382,7 @@ Foam::tmp Foam::twoPhaseMixtureEThermo::kappaEff const volScalarField& kappat ) const { - tmp kappaEff(kappa() + kappat); + tmp kappaEff(kappa() + kappat); kappaEff.ref().rename("kappaEff"); return kappaEff; } diff --git a/applications/solvers/multiphase/interFoam/interMixingFoam/alphaEqnSubCycle.H b/applications/solvers/multiphase/interFoam/interMixingFoam/alphaEqnSubCycle.H index 117e593c69..acbea8e9b9 100644 --- a/applications/solvers/multiphase/interFoam/interMixingFoam/alphaEqnSubCycle.H +++ b/applications/solvers/multiphase/interFoam/interMixingFoam/alphaEqnSubCycle.H @@ -3,12 +3,7 @@ if (nAlphaSubCycles > 1) dimensionedScalar totalDeltaT = runTime.deltaT(); surfaceScalarField rhoPhiSum ( - IOobject - ( - "rhoPhiSum", - runTime.timeName(), - mesh - ), + mesh.newIOobject("rhoPhiSum"), mesh, dimensionedScalar(rhoPhi.dimensions(), Zero) ); diff --git a/applications/solvers/multiphase/interIsoFoam/alphaEqnSubCycle.H b/applications/solvers/multiphase/interIsoFoam/alphaEqnSubCycle.H index 65376d61fe..3189654bf5 100644 --- a/applications/solvers/multiphase/interIsoFoam/alphaEqnSubCycle.H +++ b/applications/solvers/multiphase/interIsoFoam/alphaEqnSubCycle.H @@ -32,12 +32,7 @@ if (nAlphaSubCycles > 1) dimensionedScalar totalDeltaT = runTime.deltaT(); surfaceScalarField rhoPhiSum ( - IOobject - ( - "rhoPhiSum", - runTime.timeName(), - mesh - ), + mesh.newIOobject("rhoPhiSum"), mesh, dimensionedScalar(rhoPhi.dimensions(), Zero) ); diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqnSubCycle.H b/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqnSubCycle.H index f4643f1df4..8957673969 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqnSubCycle.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/alphaEqnSubCycle.H @@ -21,12 +21,7 @@ dimensionedScalar totalDeltaT = runTime.deltaT(); surfaceScalarField rhoPhiSum ( - IOobject - ( - "rhoPhiSum", - runTime.timeName(), - mesh - ), + mesh.newIOobject("rhoPhiSum"), mesh, dimensionedScalar(rhoPhi.dimensions(), Zero) ); diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/pEqn.H b/applications/solvers/multiphase/multiphaseEulerFoam/pEqn.H index 02ae8778b9..8861561888 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/pEqn.H +++ b/applications/solvers/multiphase/multiphaseEulerFoam/pEqn.H @@ -50,7 +50,8 @@ runTime.timeName(), mesh, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh, dimensionedScalar(dimVelocity*dimArea, Zero) diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C index 9c6ff5d331..67db0089ab 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C +++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C @@ -68,8 +68,9 @@ Foam::multiphaseMixture::multiphaseMixture "transportProperties", U.time().constant(), U.db(), - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE + IOobject::READ_MODIFIED, + IOobject::NO_WRITE, + IOobject::REGISTER ) ), @@ -85,9 +86,7 @@ Foam::multiphaseMixture::multiphaseMixture ( "rhoPhi", mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE + mesh_ ), mesh_, dimensionedScalar(dimMass/dimTime, Zero) @@ -101,7 +100,8 @@ Foam::multiphaseMixture::multiphaseMixture mesh_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimless, Zero) @@ -257,19 +257,12 @@ Foam::multiphaseMixture::nuf() const Foam::tmp Foam::multiphaseMixture::surfaceTensionForce() const { - tmp tstf + auto tstf = surfaceScalarField::New ( - new surfaceScalarField - ( - IOobject - ( - "surfaceTensionForce", - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedScalar(dimensionSet(1, -2, -2, 0, 0), Zero) - ) + "surfaceTensionForce", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimensionSet(1, -2, -2, 0, 0), Zero) ); surfaceScalarField& stf = tstf.ref(); @@ -324,12 +317,7 @@ void Foam::multiphaseMixture::solve() { surfaceScalarField rhoPhiSum ( - IOobject - ( - "rhoPhiSum", - runTime.timeName(), - mesh_ - ), + mesh_.newIOobject("rhoPhiSum"), mesh_, dimensionedScalar(rhoPhi_.dimensions(), Zero) ); @@ -552,19 +540,12 @@ Foam::tmp Foam::multiphaseMixture::K Foam::tmp Foam::multiphaseMixture::nearInterface() const { - tmp tnearInt + auto tnearInt = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "nearInterface", - mesh_.time().timeName(), - mesh_ - ), - mesh_, - dimensionedScalar(dimless, Zero) - ) + "nearInterface", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimless, Zero) ); for (const phase& ph : phases_) @@ -649,12 +630,7 @@ void Foam::multiphaseMixture::solveAlphas volScalarField sumAlpha ( - IOobject - ( - "sumAlpha", - mesh_.time().timeName(), - mesh_ - ), + mesh_.newIOobject("sumAlpha"), mesh_, dimensionedScalar(dimless, Zero) ); diff --git a/applications/solvers/multiphase/twoLiquidMixingFoam/alphaEqnSubCycle.H b/applications/solvers/multiphase/twoLiquidMixingFoam/alphaEqnSubCycle.H index 0347512d28..5fb0d16041 100644 --- a/applications/solvers/multiphase/twoLiquidMixingFoam/alphaEqnSubCycle.H +++ b/applications/solvers/multiphase/twoLiquidMixingFoam/alphaEqnSubCycle.H @@ -5,12 +5,7 @@ if (nAlphaSubCycles > 1) dimensionedScalar totalDeltaT = runTime.deltaT(); surfaceScalarField rhoPhiSum ( - IOobject - ( - "rhoPhiSum", - runTime.timeName(), - mesh - ), + mesh.newIOobject("rhoPhiSum"), mesh, dimensionedScalar(rhoPhi.dimensions(), Zero) ); diff --git a/applications/test/PatchTools/Test-PatchTools.C b/applications/test/PatchTools/Test-PatchTools.C index c722234006..6adfedd36d 100644 --- a/applications/test/PatchTools/Test-PatchTools.C +++ b/applications/test/PatchTools/Test-PatchTools.C @@ -67,8 +67,8 @@ using namespace Foam; // // (note:without calculating pointNormals // // to avoid them being stored) // -// tmp textrudeN(new pointField(p.nPoints(), Zero)); -// pointField& extrudeN = textrudeN(); +// auto textrudeN = tmp::New(p.nPoints(), Zero); +// auto& extrudeN = textrudeN.ref(); // { // const faceList& localFaces = p.localFaces(); // const vectorField& faceAreas = mesh.faceAreas(); diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C index decbb1aa56..f558637ce5 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C @@ -1088,8 +1088,8 @@ tmp calcOffset { vectorField::subField fc = pp.faceCentres(); - tmp toffsets(new pointField(fc.size())); - pointField& offsets = toffsets.ref(); + auto toffsets = tmp::New(fc.size()); + auto& offsets = toffsets.ref(); forAll(fc, i) { diff --git a/applications/utilities/mesh/generation/foamyMesh/cellSizeAndAlignmentGrid/cellSizeAndAlignmentGrid.C b/applications/utilities/mesh/generation/foamyMesh/cellSizeAndAlignmentGrid/cellSizeAndAlignmentGrid.C index 6d96b054a2..6b8c08a947 100644 --- a/applications/utilities/mesh/generation/foamyMesh/cellSizeAndAlignmentGrid/cellSizeAndAlignmentGrid.C +++ b/applications/utilities/mesh/generation/foamyMesh/cellSizeAndAlignmentGrid/cellSizeAndAlignmentGrid.C @@ -64,8 +64,8 @@ Foam::tmp> filterFarPoints const Field& field ) { - tmp> tNewField(new Field(field.size())); - Field& newField = tNewField.ref(); + auto tNewField = tmp>::New(field.size()); + auto& newField = tNewField.ref(); label added = 0; label count = 0; diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMeshTools/DelaunayMeshToolsTemplates.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMeshTools/DelaunayMeshToolsTemplates.C index 70cae969d5..5b0bbc3028 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMeshTools/DelaunayMeshToolsTemplates.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMeshTools/DelaunayMeshToolsTemplates.C @@ -268,8 +268,8 @@ Foam::tmp Foam::DelaunayMeshTools::allPoints const Triangulation& t ) { - tmp tpts(new pointField(t.vertexCount(), point::max)); - pointField& pts = tpts.ref(); + auto tpts = tmp::New(t.vertexCount(), point::max); + auto& pts = tpts.ref(); for ( diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C index 3df705a82c..27ebc07801 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C @@ -258,8 +258,8 @@ Foam::label Foam::cellShapeControlMesh::removePoints() Foam::tmp Foam::cellShapeControlMesh::cellCentres() const { - tmp tcellCentres(new pointField(number_of_finite_cells())); - pointField& cellCentres = tcellCentres.ref(); + auto tcellCentres = tmp::New(number_of_finite_cells()); + auto& cellCentres = tcellCentres.ref(); label count = 0; for diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/smoothAlignmentSolver/smoothAlignmentSolver.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/smoothAlignmentSolver/smoothAlignmentSolver.C index fa4748d1c7..8ad03d0b2f 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/smoothAlignmentSolver/smoothAlignmentSolver.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/smoothAlignmentSolver/smoothAlignmentSolver.C @@ -36,8 +36,8 @@ Foam::tmp> Foam::smoothAlignmentSolver::filterFarPoints const Field& field ) { - tmp> tNewField(new Field(field.size())); - Field& newField = tNewField.ref(); + auto tNewField = tmp>::New(field.size()); + auto& newField = tNewField.ref(); label added = 0; label count = 0; diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C index b17e8c7c26..3ac559c82a 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C @@ -310,8 +310,8 @@ tmp signedDistance const labelList& surfaces ) { - tmp tfld(new scalarField(points.size(), Foam::sqr(GREAT))); - scalarField& fld = tfld.ref(); + auto tfld = tmp::New(points.size(), Foam::sqr(GREAT)); + auto& fld = tfld.ref(); // Find nearest List nearest; diff --git a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C index 9b2a97bbed..bff76e88fd 100644 --- a/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C +++ b/applications/utilities/miscellaneous/foamDictionary/foamDictionary.C @@ -368,7 +368,7 @@ int main(int argc, char *argv[]) const auto dictFileName = args.get(1); - autoPtr dictFile(new IFstream(dictFileName)); + auto dictFile = autoPtr::New(dictFileName); if (!dictFile().good()) { FatalErrorInFunction diff --git a/applications/utilities/postProcessing/miscellaneous/createROMfields/readFields.H b/applications/utilities/postProcessing/miscellaneous/createROMfields/readFields.H index a1d345d1c8..084d0c16bd 100644 --- a/applications/utilities/postProcessing/miscellaneous/createROMfields/readFields.H +++ b/applications/utilities/postProcessing/miscellaneous/createROMfields/readFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021-2022 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,7 +71,7 @@ class readFieldsHandler Log << " Reading " << io.name() << " (" << FieldType::typeName << ')' << endl; - mesh_.objectRegistry::store(new FieldType(io, mesh_)); + regIOobject::store(new FieldType(io, mesh_)); return true; } diff --git a/applications/utilities/preProcessing/setExprBoundaryFields/readFields.H b/applications/utilities/preProcessing/setExprBoundaryFields/readFields.H index 07e0bb443e..e72ac18820 100644 --- a/applications/utilities/preProcessing/setExprBoundaryFields/readFields.H +++ b/applications/utilities/preProcessing/setExprBoundaryFields/readFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,7 +71,7 @@ class readFieldsHandler Log << " Reading " << io.name() << " (" << FieldType::typeName << ')' << endl; - mesh_.objectRegistry::store(new FieldType(io, mesh_)); + regIOobject::store(new FieldType(io, mesh_)); return true; } diff --git a/applications/utilities/preProcessing/setExprFields/readFields.H b/applications/utilities/preProcessing/setExprFields/readFields.H index 8ab2063ed9..b150c97d97 100644 --- a/applications/utilities/preProcessing/setExprFields/readFields.H +++ b/applications/utilities/preProcessing/setExprFields/readFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021-2022 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,7 +71,7 @@ class readFieldsHandler Log << " Reading " << io.name() << " (" << FieldType::typeName << ')' << endl; - mesh_.objectRegistry::store(new FieldType(io, mesh_)); + regIOobject::store(new FieldType(io, mesh_)); return true; } diff --git a/applications/utilities/surface/surfaceInflate/surfaceInflate.C b/applications/utilities/surface/surfaceInflate/surfaceInflate.C index 69adf9f171..3292780ef7 100644 --- a/applications/utilities/surface/surfaceInflate/surfaceInflate.C +++ b/applications/utilities/surface/surfaceInflate/surfaceInflate.C @@ -360,8 +360,8 @@ tmp avg const scalarField& edgeWeights ) { - tmp tres(new scalarField(s.nPoints(), Zero)); - scalarField& res = tres.ref(); + auto tres = tmp::New(s.nPoints(), Zero); + auto& res = tres.ref(); scalarField sumWeight(s.nPoints(), Zero); diff --git a/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C b/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C index cde4e69ae5..097c6d57fb 100644 --- a/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C +++ b/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C @@ -62,8 +62,8 @@ tmp avg { const labelListList& pointEdges = s.pointEdges(); - tmp tavg(new pointField(s.nPoints(), Zero)); - pointField& avg = tavg.ref(); + auto tavg = tmp::New(s.nPoints(), Zero); + auto& avg = tavg.ref(); forAll(pointEdges, vertI) { diff --git a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObjectTemplates.C b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObjectTemplates.C index c1c0f740b6..0c295eca2b 100644 --- a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObjectTemplates.C +++ b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObjectTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -139,7 +139,7 @@ bool Foam::functionObjects::regionFunctionObject::store } else { - obr().objectRegistry::store(tfield.ptr()); + regIOobject::store(tfield.ptr()); } } else @@ -153,7 +153,7 @@ bool Foam::functionObjects::regionFunctionObject::store fieldName = tfield().name(); } - obr().objectRegistry::store(tfield.ptr()); + regIOobject::store(tfield.ptr()); } return true; @@ -179,8 +179,11 @@ bool Foam::functionObjects::regionFunctionObject::storeInDb } else { - tfield.ref().rename(fieldName); - obr.objectRegistry::store(tfield.ptr()); + if (fieldName.size() && fieldName != tfield().name()) + { + tfield.ref().rename(fieldName); + } + regIOobject::store(tfield.ptr()); } return true; diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C index 6476a59d35..559f7fe26f 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C @@ -46,7 +46,8 @@ Foam::tmp 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 7fa0cd403c..7945a8cd2d 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixOperations.C +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixOperations.C @@ -90,16 +90,11 @@ template Foam::tmp> Foam::LduMatrix::H(const Field& psi) const { - tmp> tHpsi - ( - new Field(lduAddr().size(), Zero) - ); + auto tHpsi = tmp>::New(lduAddr().size(), Foam::zero{}); if (lowerPtr_ || upperPtr_) { - Field & 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 cafd283abb..ed7eb4d260 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTemplates.C @@ -35,7 +35,7 @@ Description template Foam::tmp> Foam::lduMatrix::H(const Field& psi) const { - auto tHpsi = tmp>::New(lduAddr().size(), Zero); + auto tHpsi = tmp>::New(lduAddr().size(), Foam::zero{}); if (lowerPtr_ || upperPtr_) { diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C index b6b6291552..1ced04106f 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGAgglomerations/GAMGAgglomeration/GAMGAgglomeration.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2023 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -348,7 +348,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New { agglomPtr().printLevels(); } - return store(agglomPtr.ptr()); + return regIOobject::store(agglomPtr); } } @@ -398,7 +398,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New { agglomPtr().printLevels(); } - return store(agglomPtr.ptr()); + return regIOobject::store(agglomPtr); } } } @@ -463,7 +463,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New { agglomPtr().printLevels(); } - return store(agglomPtr.ptr()); + return regIOobject::store(agglomPtr); } } diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 00480e7669..5aba0e0d2f 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 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 1a5e79754c..3f2530d6da 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::polyPatch::faceCellCentres() const { - tmp tcc(new vectorField(size())); - vectorField& cc = tcc.ref(); + auto tcc = tmp::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::polyPatch::faceCellCentres() const Foam::tmp Foam::polyPatch::areaFraction() const { - tmp tfraction(new scalarField(size())); - scalarField& fraction = tfraction.ref(); + auto tfraction = tmp::New(size()); + auto& fraction = tfraction.ref(); const vectorField::subField faceAreas = this->faceAreas(); const pointField& points = this->points(); diff --git a/src/TurbulenceModels/compressible/ThermalDiffusivity/ThermalDiffusivity.C b/src/TurbulenceModels/compressible/ThermalDiffusivity/ThermalDiffusivity.C index b249146c06..e658882d6a 100644 --- a/src/TurbulenceModels/compressible/ThermalDiffusivity/ThermalDiffusivity.C +++ b/src/TurbulenceModels/compressible/ThermalDiffusivity/ThermalDiffusivity.C @@ -143,10 +143,7 @@ Foam::ThermalDiffusivity::alphat const label patchi ) const { - return tmp - ( - new scalarField(this->mesh_.boundary()[patchi].size(), Zero) - ); + return tmp::New(this->mesh_.boundary()[patchi].size(), Zero); } diff --git a/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H b/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H index 62618f3260..7d9720679c 100644 --- a/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H +++ b/src/TurbulenceModels/schemes/DEShybrid/DEShybrid.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation - Copyright (C) 2015-2022 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. Copyright (C) 2022 Upstream CFD GmbH ------------------------------------------------------------------------------- License @@ -301,7 +301,7 @@ class DEShybrid ( factorName, mesh.time().timeName(), - mesh, + mesh.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -321,7 +321,7 @@ class DEShybrid dimensionedScalar(dimless, Zero) ); - const_cast(mesh).objectRegistry::store(factorPtr); + regIOobject::store(factorPtr); } auto& factor = *factorPtr; diff --git a/src/TurbulenceModels/turbulenceModels/DES/DESModel/DESModel.C b/src/TurbulenceModels/turbulenceModels/DES/DESModel/DESModel.C index c99d84c6f7..cf223102f4 100644 --- a/src/TurbulenceModels/turbulenceModels/DES/DESModel/DESModel.C +++ b/src/TurbulenceModels/turbulenceModels/DES/DESModel/DESModel.C @@ -168,16 +168,10 @@ tmp DESModel::Ssigma template tmp DESModel::fd() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - "fd", - this->mesh_.time().timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "fd", + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(dimless, Zero) ); diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.C b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.C index 5ae16f229b..8386344061 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESdeltas/IDDESDelta/IDDESDelta.C @@ -53,21 +53,12 @@ void Foam::LESModels::IDDESDelta::calcDelta() // Wall-normal vectors const volVectorField& n = wallDist::New(mesh).n(); - tmp tfaceToFacenMax + auto tfaceToFacenMax = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "faceToFaceMax", - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh, - dimensionedScalar(dimLength, Zero) - ) + "faceToFaceMax", + IOobject::NO_REGISTER, + mesh, + dimensionedScalar(dimLength, Zero) ); scalarField& faceToFacenMax = tfaceToFacenMax.ref().primitiveFieldRef(); diff --git a/src/TurbulenceModels/turbulenceModels/LES/LESfilters/anisotropicFilter/anisotropicFilter.C b/src/TurbulenceModels/turbulenceModels/LES/LESfilters/anisotropicFilter/anisotropicFilter.C index f0b284fb76..1ef8a7673f 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/LESfilters/anisotropicFilter/anisotropicFilter.C +++ b/src/TurbulenceModels/turbulenceModels/LES/LESfilters/anisotropicFilter/anisotropicFilter.C @@ -182,19 +182,12 @@ Foam::tmp Foam::anisotropicFilter::operator() { correctBoundaryConditions(unFilteredField); - tmp tmpFilteredField + auto tmpFilteredField = volSymmTensorField::New ( - new volSymmTensorField - ( - IOobject - ( - "anisotropicFilteredSymmTensorField", - mesh().time().timeName(), - mesh() - ), - mesh(), - unFilteredField().dimensions() - ) + "anisotropicFilteredSymmTensorField", + IOobject::NO_REGISTER, + mesh(), + unFilteredField().dimensions() ); for (direction d=0; d Foam::anisotropicFilter::operator() { correctBoundaryConditions(unFilteredField); - tmp tmpFilteredField + auto tmpFilteredField = volTensorField::New ( - new volTensorField - ( - IOobject - ( - "anisotropicFilteredTensorField", - mesh().time().timeName(), - mesh() - ), - mesh(), - unFilteredField().dimensions() - ) + "anisotropicFilteredTensorField", + IOobject::NO_REGISTER, + mesh(), + unFilteredField().dimensions() ); for (direction d=0; d::correctNut() template tmp dynamicKEqn::kSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - k_, - dimVolume*this->rho_.dimensions()*k_.dimensions() - /dimTime - ) + k_, + dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime ); } diff --git a/src/TurbulenceModels/turbulenceModels/LES/kEqn/kEqn.C b/src/TurbulenceModels/turbulenceModels/LES/kEqn/kEqn.C index 50fb5f029f..6ecd8118f6 100644 --- a/src/TurbulenceModels/turbulenceModels/LES/kEqn/kEqn.C +++ b/src/TurbulenceModels/turbulenceModels/LES/kEqn/kEqn.C @@ -52,14 +52,10 @@ void kEqn::correctNut() template tmp kEqn::kSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - k_, - dimVolume*this->rho_.dimensions()*k_.dimensions() - /dimTime - ) + k_, + dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime ); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/LaunderSharmaKE/LaunderSharmaKE.C b/src/TurbulenceModels/turbulenceModels/RAS/LaunderSharmaKE/LaunderSharmaKE.C index f0a84979f4..a414e8bc4e 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/LaunderSharmaKE/LaunderSharmaKE.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/LaunderSharmaKE/LaunderSharmaKE.C @@ -69,14 +69,10 @@ void LaunderSharmaKE::correctNut() template tmp LaunderSharmaKE::kSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - k_, - dimVolume*this->rho_.dimensions()*k_.dimensions() - /dimTime - ) + k_, + dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime ); } @@ -84,14 +80,10 @@ tmp LaunderSharmaKE::kSource() const template tmp LaunderSharmaKE::epsilonSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - epsilon_, - dimVolume*this->rho_.dimensions()*epsilon_.dimensions() - /dimTime - ) + epsilon_, + dimVolume*this->rho_.dimensions()*epsilon_.dimensions()/dimTime ); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C b/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C index 661f65ebba..aefac5045e 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/RASModel/RASModel.C @@ -193,14 +193,10 @@ Foam::RASModel::epsilon() const { const scalar Cmu = 0.09; - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("epsilon", this->alphaRhoPhi_.group()), - this->mesh_.time().timeName(), - this->mesh_ - ), + IOobject::groupName("epsilon", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, Cmu*this->k()*this->omega() ); } @@ -213,14 +209,10 @@ Foam::RASModel::omega() const const scalar betaStar = 0.09; const dimensionedScalar k0(sqr(dimLength/dimTime), SMALL); - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("omega", this->alphaRhoPhi_.group()), - this->mesh_.time().timeName(), - this->mesh_ - ), + IOobject::groupName("omega", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->epsilon()/(betaStar*(this->k() + k0)) ); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/RNGkEpsilon/RNGkEpsilon.C b/src/TurbulenceModels/turbulenceModels/RAS/RNGkEpsilon/RNGkEpsilon.C index 3f7df45d61..6760dc8269 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/RNGkEpsilon/RNGkEpsilon.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/RNGkEpsilon/RNGkEpsilon.C @@ -53,14 +53,10 @@ void RNGkEpsilon::correctNut() template tmp RNGkEpsilon::kSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - k_, - dimVolume*this->rho_.dimensions()*k_.dimensions() - /dimTime - ) + k_, + dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime ); } @@ -68,14 +64,10 @@ tmp RNGkEpsilon::kSource() const template tmp RNGkEpsilon::epsilonSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - epsilon_, - dimVolume*this->rho_.dimensions()*epsilon_.dimensions() - /dimTime - ) + epsilon_, + dimVolume*this->rho_.dimensions()*epsilon_.dimensions()/dimTime ); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kEpsilon/kEpsilon.C b/src/TurbulenceModels/turbulenceModels/RAS/kEpsilon/kEpsilon.C index ead17ff204..d66b80be90 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kEpsilon/kEpsilon.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/kEpsilon/kEpsilon.C @@ -53,14 +53,10 @@ void kEpsilon::correctNut() template tmp kEpsilon::kSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - k_, - dimVolume*this->rho_.dimensions()*k_.dimensions() - /dimTime - ) + k_, + dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime ); } @@ -68,14 +64,10 @@ tmp kEpsilon::kSource() const template tmp kEpsilon::epsilonSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - epsilon_, - dimVolume*this->rho_.dimensions()*epsilon_.dimensions() - /dimTime - ) + epsilon_, + dimVolume*this->rho_.dimensions()*epsilon_.dimensions()/dimTime ); } diff --git a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C index b691180936..eb3acb2abd 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTLM/kOmegaSSTLM.C @@ -95,11 +95,11 @@ tmp kOmegaSSTLM::Fthetat const volScalarField::Internal ReOmega(sqr(y)*omega/nu); const volScalarField::Internal Fwake(exp(-sqr(ReOmega/1e5))); - return tmp + return volScalarField::Internal::New ( - new volScalarField::Internal + IOobject::groupName("Fthetat", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, ( - IOobject::groupName("Fthetat", this->alphaRhoPhi_.group()), min ( max @@ -118,21 +118,14 @@ template tmp kOmegaSSTLM::ReThetac() const { - tmp tReThetac + auto tReThetac = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - IOobject::groupName("ReThetac", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_ - ), - this->mesh_, - dimless - ) + IOobject::groupName("ReThetac", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + this->mesh_, + dimless ); - volScalarField::Internal& ReThetac = tReThetac.ref(); + auto& ReThetac = tReThetac.ref(); forAll(ReThetac, celli) { @@ -161,21 +154,14 @@ tmp kOmegaSSTLM::Flength const volScalarField::Internal& nu ) const { - tmp tFlength + auto tFlength = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - IOobject::groupName("Flength", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_ - ), - this->mesh_, - dimless - ) + IOobject::groupName("Flength", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + this->mesh_, + dimless ); - volScalarField::Internal& Flength = tFlength.ref(); + auto& Flength = tFlength.ref(); const volScalarField::Internal& omega = this->omega_(); const volScalarField::Internal& y = this->y_(); @@ -226,21 +212,14 @@ tmp kOmegaSSTLM::ReThetat0 const volScalarField::Internal& nu ) const { - tmp tReThetat0 + auto tReThetat0 = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - IOobject::groupName("ReThetat0", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_ - ), - this->mesh_, - dimless - ) + IOobject::groupName("ReThetat0", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + this->mesh_, + dimless ); - volScalarField::Internal& ReThetat0 = tReThetat0.ref(); + auto& ReThetat0 = tReThetat0.ref(); const volScalarField& k = this->k_; @@ -349,13 +328,11 @@ tmp kOmegaSSTLM::Fonset const volScalarField::Internal Fonset3(max(1 - pow3(RT/2.5), scalar(0))); - return tmp + return volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject::groupName("Fonset", this->alphaRhoPhi_.group()), - max(Fonset2 - Fonset3, scalar(0)) - ) + IOobject::groupName("Fonset", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + max(Fonset2 - Fonset3, scalar(0)) ); } @@ -459,7 +436,8 @@ kOmegaSSTLM::kOmegaSSTLM this->runTime_.timeName(), this->mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh_ ), @@ -472,7 +450,8 @@ kOmegaSSTLM::kOmegaSSTLM this->runTime_.timeName(), this->mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh_ ), diff --git a/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C b/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C index 6e08625a61..b5712400c5 100644 --- a/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C +++ b/src/TurbulenceModels/turbulenceModels/RAS/realizableKE/realizableKE.C @@ -101,14 +101,10 @@ void realizableKE::correctNut() template tmp realizableKE::kSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - k_, - dimVolume*this->rho_.dimensions()*k_.dimensions() - /dimTime - ) + k_, + dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime ); } @@ -116,14 +112,10 @@ tmp realizableKE::kSource() const template tmp realizableKE::epsilonSource() const { - return tmp + return tmp::New ( - new fvScalarMatrix - ( - epsilon_, - dimVolume*this->rho_.dimensions()*epsilon_.dimensions() - /dimTime - ) + epsilon_, + dimVolume*this->rho_.dimensions()*epsilon_.dimensions()/dimTime ); } diff --git a/src/TurbulenceModels/turbulenceModels/eddyViscosity/eddyViscosity.C b/src/TurbulenceModels/turbulenceModels/eddyViscosity/eddyViscosity.C index 65ae0c2d3e..f37ad54b4e 100644 --- a/src/TurbulenceModels/turbulenceModels/eddyViscosity/eddyViscosity.C +++ b/src/TurbulenceModels/turbulenceModels/eddyViscosity/eddyViscosity.C @@ -65,7 +65,8 @@ Foam::eddyViscosity::eddyViscosity this->runTime_.timeName(), this->mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh_ ) @@ -104,22 +105,12 @@ Foam::eddyViscosity::R() const } } - return tmp + return volSymmTensorField::New ( - new volSymmTensorField - ( - IOobject - ( - IOobject::groupName("R", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - ((2.0/3.0)*I)*tk() - (nut_)*devTwoSymm(fvc::grad(this->U_)), - patchFieldTypes - ) + IOobject::groupName("R", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + ((2.0/3.0)*I)*tk() - (nut_)*devTwoSymm(fvc::grad(this->U_)), + patchFieldTypes ); } diff --git a/src/TurbulenceModels/turbulenceModels/laminar/Stokes/Stokes.C b/src/TurbulenceModels/turbulenceModels/laminar/Stokes/Stokes.C index 0e42398ef3..e45fab2853 100644 --- a/src/TurbulenceModels/turbulenceModels/laminar/Stokes/Stokes.C +++ b/src/TurbulenceModels/turbulenceModels/laminar/Stokes/Stokes.C @@ -89,17 +89,10 @@ template tmp Stokes::nut() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("nut", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("nut", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(dimViscosity, Zero) ); @@ -113,10 +106,7 @@ Stokes::nut const label patchi ) const { - return tmp - ( - new scalarField(this->mesh_.boundary()[patchi].size(), Zero) - ); + return tmp::New(this->mesh_.boundary()[patchi].size(), Zero); } @@ -124,12 +114,11 @@ template tmp Stokes::nuEff() const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject::groupName("nuEff", this->alphaRhoPhi_.group()), this->nu() - ) + IOobject::groupName("nuEff", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + this->nu() ); } diff --git a/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C b/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C index 22e7af0fbc..41444d6420 100644 --- a/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C +++ b/src/TurbulenceModels/turbulenceModels/laminar/laminarModel/laminarModel.C @@ -189,17 +189,10 @@ template Foam::tmp Foam::laminarModel::nut() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("nut", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("nut", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(dimViscosity, Zero) ); @@ -213,10 +206,7 @@ Foam::laminarModel::nut const label patchi ) const { - return tmp - ( - new scalarField(this->mesh_.boundary()[patchi].size(), Zero) - ); + return tmp::New(this->mesh_.boundary()[patchi].size(), Zero); } @@ -224,12 +214,11 @@ template Foam::tmp Foam::laminarModel::nuEff() const { - return tmp + return volScalarField::New ( - new volScalarField - ( - IOobject::groupName("nuEff", this->alphaRhoPhi_.group()), this->nu() - ) + IOobject::groupName("nuEff", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, + this->nu() ); } @@ -249,17 +238,10 @@ template Foam::tmp Foam::laminarModel::k() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("k", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("k", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(sqr(this->U_.dimensions()), Zero) ); @@ -270,17 +252,10 @@ template Foam::tmp Foam::laminarModel::epsilon() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("epsilon", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("epsilon", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(sqr(this->U_.dimensions())/dimTime, Zero) ); @@ -291,17 +266,10 @@ template Foam::tmp Foam::laminarModel::omega() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("omega", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("omega", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(dimless/dimTime, Zero) ); @@ -312,17 +280,10 @@ template Foam::tmp Foam::laminarModel::R() const { - return tmp::New + return volSymmTensorField::New ( - IOobject - ( - IOobject::groupName("R", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("R", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedSymmTensor(sqr(this->U_.dimensions()), Zero) ); diff --git a/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C b/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C index ed01512dbd..b5b72cc4f3 100644 --- a/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C +++ b/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 ENERCON GmbH - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -58,14 +58,14 @@ Foam::volScalarField& Foam::fv::atmPlantCanopyTurbSource::getOrReadField ( fieldName, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::AUTO_WRITE, IOobject::REGISTER ), mesh_ ); - mesh_.objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C b/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C index 89beb35193..683d112c95 100644 --- a/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C +++ b/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 ENERCON GmbH - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,14 +59,14 @@ Foam::volScalarField& Foam::fv::atmPlantCanopyUSource::getOrReadField ( fieldName, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::AUTO_WRITE, IOobject::REGISTER ), mesh_ ); - mesh_.objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/atmosphericModels/turbulenceModels/RAS/kL/kL.C b/src/atmosphericModels/turbulenceModels/RAS/kL/kL.C index 982e3cc705..7fded669b3 100644 --- a/src/atmosphericModels/turbulenceModels/RAS/kL/kL.C +++ b/src/atmosphericModels/turbulenceModels/RAS/kL/kL.C @@ -80,17 +80,10 @@ tmp kL::epsilonCanopy() const return Cd*LAD*mag(U)*k_; } - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("epsilonCanopy", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("epsilonCanopy", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(sqr(dimLength)/pow3(dimTime), Zero) ); @@ -118,26 +111,22 @@ tmp kL::epsilon() const template tmp kL::canopyHeight() const { - const auto* canopyHeightPtr = - this->mesh_.template findObject("canopyHeight"); + tmp tcanopy; - if (canopyHeightPtr) + tcanopy.cref + ( + this->mesh_.template cfindObject("canopyHeight") + ); + + if (tcanopy) { - const auto& canopyHeight = *canopyHeightPtr; - return canopyHeight; + return tcanopy; } - return tmp::New + return volScalarField::New ( - IOobject - ( - IOobject::groupName("canopyHeight", this->alphaRhoPhi_.group()), - this->runTime_.timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::groupName("canopyHeight", this->alphaRhoPhi_.group()), + IOobject::NO_REGISTER, this->mesh_, dimensionedScalar(dimLength, Zero) ); diff --git a/src/combustionModels/EDC/EDC.C b/src/combustionModels/EDC/EDC.C index 3e55ba9ce1..90fc7e2605 100644 --- a/src/combustionModels/EDC/EDC.C +++ b/src/combustionModels/EDC/EDC.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2019-2020,2023 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,11 +59,12 @@ Foam::combustionModels::EDC::EDC ( IOobject ( - this->thermo().phasePropertyName(typeName + ":kappa"), + this->thermo().phaseScopedName(typeName, "kappa"), this->mesh().time().timeName(), this->mesh(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimless, Zero) @@ -86,23 +87,23 @@ void Foam::combustionModels::EDC::correct() if (this->active()) { tmp tepsilon(this->turbulence().epsilon()); - const volScalarField& epsilon = tepsilon(); + const auto& epsilon = tepsilon(); tmp tmu(this->turbulence().mu()); - const volScalarField& mu = tmu(); + const auto& mu = tmu(); tmp tk(this->turbulence().k()); - const volScalarField& k = tk(); + const auto& k = tk(); tmp trho(this->rho()); - const volScalarField& rho = trho(); + const auto& rho = trho(); scalarField tauStar(epsilon.size(), Zero); if (version_ == EDCversions::v2016) { tmp ttc(this->chemistryPtr_->tc()); - const volScalarField& tc = ttc(); + const auto& tc = ttc(); forAll(tauStar, i) { @@ -199,22 +200,12 @@ template Foam::tmp Foam::combustionModels::EDC::Qdot() const { - tmp tQdot + auto tQdot = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->thermo().phasePropertyName(typeName + ":Qdot"), - this->mesh().time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) - ) + this->thermo().phaseScopedName(typeName, "Qdot"), + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) ); if (this->active()) diff --git a/src/combustionModels/FSD/FSD.C b/src/combustionModels/FSD/FSD.C index ef9f1d382d..03e4b93f68 100644 --- a/src/combustionModels/FSD/FSD.C +++ b/src/combustionModels/FSD/FSD.C @@ -72,7 +72,8 @@ FSD::FSD this->mesh().time().timeName(), this->mesh(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimless, Zero) @@ -149,43 +150,23 @@ void FSD::calculateSourceNorm() s.value()*YFuelFuelStream_.value() + YO2OxiStream_.value() ); - tmp tPc + auto tPc = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->thermo().phasePropertyName("Pc"), - U.time().timeName(), - U.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - U.mesh(), - dimensionedScalar(dimless, Zero) - ) + this->thermo().phasePropertyName("Pc"), + IOobject::NO_REGISTER, + U.mesh(), + dimensionedScalar(dimless, Zero) ); + auto& pc = tPc.ref(); - volScalarField& pc = tPc.ref(); - - tmp tomegaFuel + auto tomegaFuel = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->thermo().phasePropertyName("omegaFuelBar"), - U.time().timeName(), - U.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - U.mesh(), - dimensionedScalar(omegaFuel.dimensions(), Zero) - ) + this->thermo().phasePropertyName("omegaFuelBar"), + IOobject::NO_REGISTER, + U.mesh(), + dimensionedScalar(omegaFuel.dimensions(), Zero) ); - - volScalarField& omegaFuelBar = tomegaFuel.ref(); + auto& omegaFuelBar = tomegaFuel.ref(); // Calculation of the mixture fraction variance (ftVar) const compressible::LESModel& lesModel = @@ -294,24 +275,14 @@ void FSD::calculateSourceNorm() } } - tmp tproducts + auto tproducts = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->thermo().phasePropertyName("products"), - U.time().timeName(), - U.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - U.mesh(), - dimensionedScalar(dimless, Zero) - ) + this->thermo().phasePropertyName("products"), + IOobject::NO_REGISTER, + U.mesh(), + dimensionedScalar(dimless, Zero) ); - - volScalarField& products = tproducts.ref(); + auto& products = tproducts.ref(); forAll(productsIndex, j) { diff --git a/src/combustionModels/FSD/reactionRateFlameAreaModels/consumptionSpeed/consumptionSpeed.C b/src/combustionModels/FSD/reactionRateFlameAreaModels/consumptionSpeed/consumptionSpeed.C index 2322572550..808348cd20 100644 --- a/src/combustionModels/FSD/reactionRateFlameAreaModels/consumptionSpeed/consumptionSpeed.C +++ b/src/combustionModels/FSD/reactionRateFlameAreaModels/consumptionSpeed/consumptionSpeed.C @@ -82,24 +82,14 @@ Foam::tmp Foam::consumptionSpeed::omega0Sigma const volScalarField& sigma ) { - tmp tomega0 + auto tomega0 = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "omega0", - sigma.time().timeName(), - sigma.db(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - sigma.mesh(), - dimensionedScalar(dimensionSet(1, -2, -1, 0, 0, 0, 0), Zero) - ) + "omega0", + IOobject::NO_REGISTER, + sigma.mesh(), + dimensionedScalar(dimensionSet(1, -2, -1, 0, 0, 0, 0), Zero) ); - - volScalarField& omega0 = tomega0.ref(); + auto& omega0 = tomega0.ref(); volScalarField::Internal& iomega0 = omega0; diff --git a/src/combustionModels/PaSR/PaSR.C b/src/combustionModels/PaSR/PaSR.C index 63559a0aaf..77c75294fb 100644 --- a/src/combustionModels/PaSR/PaSR.C +++ b/src/combustionModels/PaSR/PaSR.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019,2023 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,11 +45,12 @@ Foam::combustionModels::PaSR::PaSR ( IOobject ( - thermo.phasePropertyName(typeName + ":kappa"), + thermo.phaseScopedName(typeName, "kappa"), this->mesh().time().timeName(), this->mesh(), IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimless, Zero) @@ -74,16 +75,16 @@ void Foam::combustionModels::PaSR::correct() laminar::correct(); tmp tepsilon(this->turbulence().epsilon()); - const scalarField& epsilon = tepsilon(); + const auto& epsilon = tepsilon(); tmp tmuEff(this->turbulence().muEff()); - const scalarField& muEff = tmuEff(); + const auto& muEff = tmuEff(); tmp ttc(this->tc()); - const scalarField& tc = ttc(); + const auto& tc = ttc(); tmp trho(this->rho()); - const scalarField& rho = trho(); + const auto& rho = trho(); forAll(epsilon, i) { @@ -118,13 +119,11 @@ template Foam::tmp Foam::combustionModels::PaSR::Qdot() const { - return tmp + return volScalarField::New ( - new volScalarField - ( - this->thermo().phasePropertyName(typeName + ":Qdot"), - kappa_*laminar::Qdot() - ) + this->thermo().phaseScopedName(typeName, "Qdot"), + IOobject::NO_REGISTER, + kappa_*laminar::Qdot() ); } diff --git a/src/combustionModels/diffusionMulticomponent/diffusionMulticomponent.C b/src/combustionModels/diffusionMulticomponent/diffusionMulticomponent.C index fb5c155625..7a10ab2a17 100644 --- a/src/combustionModels/diffusionMulticomponent/diffusionMulticomponent.C +++ b/src/combustionModels/diffusionMulticomponent/diffusionMulticomponent.C @@ -60,15 +60,7 @@ diffusionMulticomponent::init() k, new volScalarField ( - IOobject - ( - "Rijk" + Foam::name(k), - this->mesh_.time().timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + this->mesh_.newIOobject("Rijk" + Foam::name(k)), this->mesh_, dimensionedScalar(dimMass/dimTime/dimVolume, Zero), fvPatchFieldBase::zeroGradientType() @@ -198,15 +190,7 @@ diffusionMulticomponent::correct() k, new volScalarField ( - IOobject - ( - "Rijl" + Foam::name(k), - this->mesh_.time().timeName(), - this->mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + this->mesh_.newIOobject("Rijl" + Foam::name(k)), this->mesh_, dimensionedScalar(dimMass/dimTime/dimVolume, Zero), fvPatchFieldBase::zeroGradientType() @@ -374,9 +358,8 @@ Foam::combustionModels::diffusionMulticomponent::R volScalarField& Y ) const { - tmp tSu(new fvScalarMatrix(Y, dimMass/dimTime)); - - fvScalarMatrix& Su = tSu.ref(); + auto tSu = tmp::New(Y, dimMass/dimTime); + auto& Su = tSu.ref(); if (this->active()) { @@ -395,23 +378,13 @@ Foam::tmp Foam::combustionModels:: diffusionMulticomponent::Qdot() const { - tmp tQdot + auto tQdot = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "Qdot", - this->mesh().time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimEnergy/dimTime/dimVolume, Zero), - fvPatchFieldBase::zeroGradientType() - ) + "Qdot", + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimEnergy/dimTime/dimVolume, Zero), + fvPatchFieldBase::zeroGradientType() ); if (this->active()) diff --git a/src/combustionModels/eddyDissipationDiffusionModel/eddyDissipationDiffusionModel.C b/src/combustionModels/eddyDissipationDiffusionModel/eddyDissipationDiffusionModel.C index fa042bfce0..b8c61234be 100644 --- a/src/combustionModels/eddyDissipationDiffusionModel/eddyDissipationDiffusionModel.C +++ b/src/combustionModels/eddyDissipationDiffusionModel/eddyDissipationDiffusionModel.C @@ -77,25 +77,16 @@ template Foam::tmp eddyDissipationDiffusionModel::rtDiff() const { - tmp tdelta + auto tdelta = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "tdelta", - this->mesh().time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - this->mesh(), - dimensionedScalar(dimLength, Zero), - fvPatchFieldBase::zeroGradientType() - ) + "tdelta", + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimLength, Zero), + fvPatchFieldBase::zeroGradientType() ); + auto& delta = tdelta.ref(); - volScalarField& delta = tdelta.ref(); delta.ref() = cbrt(this->mesh().V()); delta.correctBoundaryConditions(); diff --git a/src/combustionModels/laminar/laminar.C b/src/combustionModels/laminar/laminar.C index 50f5681643..feb5889bb5 100644 --- a/src/combustionModels/laminar/laminar.C +++ b/src/combustionModels/laminar/laminar.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -123,9 +123,8 @@ template Foam::tmp Foam::combustionModels::laminar::R(volScalarField& Y) const { - tmp tSu(new fvScalarMatrix(Y, dimMass/dimTime)); - - fvScalarMatrix& Su = tSu.ref(); + auto tSu = tmp::New(Y, dimMass/dimTime); + auto& Su = tSu.ref(); if (this->active()) { @@ -143,22 +142,12 @@ template Foam::tmp Foam::combustionModels::laminar::Qdot() const { - tmp tQdot + auto tQdot = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->thermo().phasePropertyName(typeName + ":Qdot"), - this->mesh().time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) - ) + this->thermo().phaseScopedName(typeName, "Qdot"), + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) ); if (this->active()) diff --git a/src/combustionModels/noCombustion/noCombustion.C b/src/combustionModels/noCombustion/noCombustion.C index e123b2f2dd..7bbeafa7dc 100644 --- a/src/combustionModels/noCombustion/noCombustion.C +++ b/src/combustionModels/noCombustion/noCombustion.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -65,12 +65,7 @@ Foam::combustionModels::noCombustion::R volScalarField& Y ) const { - tmp tSu - ( - new fvScalarMatrix(Y, dimMass/dimTime) - ); - - return tSu; + return tmp::New(Y, dimMass/dimTime); } @@ -78,17 +73,10 @@ template Foam::tmp Foam::combustionModels::noCombustion::Qdot() const { - return tmp::New + return volScalarField::New ( - IOobject - ( - this->thermo().phasePropertyName(typeName + ":Qdot"), - this->mesh().time().timeName(), - this->mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + this->thermo().phaseScopedName(typeName, "Qdot"), + IOobject::NO_REGISTER, this->mesh(), dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) ); diff --git a/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C b/src/dynamicFaMesh/interfaceTrackingFvMesh/interfaceTrackingFvMesh.C index ef431b1d9e..4197ef6bac 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()) + if (pointsIO.typeHeaderOk()) { 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 2c6eb27b36..43f12a7cd7 100644 --- a/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C +++ b/src/dynamicMesh/layerAdditionRemoval/addCellLayer.C @@ -47,8 +47,8 @@ Foam::tmp Foam::layerAdditionRemoval::extrusionDir() const const pointField& points = mesh.points(); const labelList& mp = masterFaceLayer.meshPoints(); - tmp textrusionDir(new vectorField(mp.size())); - vectorField& extrusionDir = textrusionDir.ref(); + auto textrusionDir = tmp::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 dbd93a73fb..2026e4e09e 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 tcurPoints(new pointField(points0())); - pointField& curPoints = tcurPoints.ref(); + auto tcurPoints = tmp::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 5b88d28c57..645be3cea2 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/faOptions/faOption/faOptionListTemplates.C b/src/faOptions/faOption/faOptionListTemplates.C index b71f495880..7445acae92 100644 --- a/src/faOptions/faOption/faOptionListTemplates.C +++ b/src/faOptions/faOption/faOptionListTemplates.C @@ -41,8 +41,8 @@ Foam::tmp> Foam::fa::optionList::source { checkApplied(); - tmp> tmtx(new faMatrix(field, ds)); - faMatrix& mtx = tmtx.ref(); + auto tmtx = tmp>::New(field, ds); + auto& mtx = tmtx.ref(); for (fa::option& source : *this) { @@ -132,8 +132,8 @@ Foam::tmp> Foam::fa::optionList::operator() rho.dimensions()*field.dimensions()/dimTime*dimArea ); - tmp> tmtx(new faMatrix(field, ds)); - faMatrix& mtx = tmtx.ref(); + auto tmtx = tmp>::New(field, ds); + auto& mtx = tmtx.ref(); for (fa::option& source : *this) { @@ -184,8 +184,8 @@ Foam::tmp> Foam::fa::optionList::operator() const dimensionSet dsMat(ds*dimArea); - tmp> tmtx(new faMatrix(field, dsMat)); - faMatrix& mtx = tmtx.ref(); + auto tmtx = tmp>::New(field, dsMat); + auto& mtx = tmtx.ref(); for (fa::option& source : *this) { diff --git a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C index 051cd3d7b8..5921e788fc 100644 --- a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C +++ b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C @@ -58,11 +58,12 @@ Foam::fa::jouleHeatingSource::jouleHeatingSource ( IOobject ( - typeName + ":V_" + regionName_, + IOobject::scopedName(typeName, "V_" + regionName_), regionMesh().thisDb().time().timeName(), regionMesh().thisDb(), IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), regionMesh() ), @@ -141,6 +142,11 @@ void Foam::fa::jouleHeatingSource::addSup } // Add the Joule heating contribution + const word sigmaName + ( + IOobject::scopedName(typeName, "sigma_" + regionName_) + ); + areaVectorField gradV("gradV", fac::grad(V_)); if (debug > 1 && mesh().time().writeTime()) @@ -156,20 +162,14 @@ void Foam::fa::jouleHeatingSource::addSup if (anisotropicElectricalConductivity_) { const auto& sigma = - obr.lookupObject - ( - typeName + ":sigma_" + regionName_ - ); + obr.lookupObject(sigmaName); tsource = (h*sigma & gradV) & gradV; } else { const auto& sigma = - obr.lookupObject - ( - typeName + ":sigma_" + regionName_ - ); + obr.lookupObject(sigmaName); tsource = (h*sigma*gradV) & gradV; } diff --git a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C index a59bdc65ac..351b514654 100644 --- a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C +++ b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2023 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,54 +36,52 @@ void Foam::fa::jouleHeatingSource::initialiseSigma autoPtr>& sigmaVsTPtr ) { - typedef GeometricField AreaFieldType; + typedef GeometricField FieldType; auto& obr = regionMesh().thisDb(); + IOobject io + ( + IOobject::scopedName(typeName, "sigma_" + regionName_), + obr.time().timeName(), + obr, + IOobject::NO_READ, + IOobject::AUTO_WRITE, + IOobject::REGISTER + ); + + autoPtr tsigma; + if (dict.found("sigma")) { // Sigma to be defined using a Function1 type sigmaVsTPtr = Function1::New("sigma", dict, &mesh_); - auto tsigma = tmp::New + tsigma.reset ( - IOobject + new FieldType ( - typeName + ":sigma_" + regionName_, - obr.time().timeName(), - obr, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - regionMesh(), - dimensioned(sqr(dimCurrent)/dimPower/dimLength, Zero) + io, + regionMesh(), + Foam::zero{}, // value + sqr(dimCurrent)/dimPower/dimLength + ) ); - regIOobject::store(tsigma.ptr()); - Info<< " Conductivity 'sigma' read from dictionary as f(T)" << nl << endl; } else { // Sigma to be defined by user input - auto tsigma = tmp::New - ( - IOobject - ( - typeName + ":sigma_" + regionName_, - obr.time().timeName(), - obr, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - regionMesh() - ); + io.readOpt(IOobject::MUST_READ); - regIOobject::store(tsigma.ptr()); + tsigma.reset(new FieldType(io, regionMesh())); Info<< " Conductivity 'sigma' read from file" << nl << endl; } + + regIOobject::store(tsigma); } @@ -94,12 +92,15 @@ Foam::fa::jouleHeatingSource::updateSigma const autoPtr>& sigmaVsTPtr ) const { - typedef GeometricField AreaFieldType; + typedef GeometricField FieldType; const auto& obr = regionMesh().thisDb(); auto& sigma = - obr.lookupObjectRef(typeName + ":sigma_" + regionName_); + obr.lookupObjectRef + ( + IOobject::scopedName(typeName, "sigma_" + regionName_) + ); if (!sigmaVsTPtr) { @@ -117,11 +118,11 @@ Foam::fa::jouleHeatingSource::updateSigma // Boundary field - typename AreaFieldType::Boundary& bf = sigma.boundaryFieldRef(); + auto& bf = sigma.boundaryFieldRef(); forAll(bf, patchi) { faPatchField& pf = bf[patchi]; - if (!isA(bf[patchi])) + if (!isA(pf)) { const scalarField& Tbf = T.boundaryField()[patchi]; forAll(pf, facei) diff --git a/src/finiteArea/faMatrices/faMatrix/faMatrix.C b/src/finiteArea/faMatrices/faMatrix/faMatrix.C index 074cc0693a..4d06db262d 100644 --- a/src/finiteArea/faMatrices/faMatrix/faMatrix.C +++ b/src/finiteArea/faMatrices/faMatrix/faMatrix.C @@ -1207,7 +1207,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, B, "+"); - tmp> tC(new faMatrix(A)); + auto tC = tmp>::New(A); tC.ref() += B; return tC; } @@ -1262,7 +1262,7 @@ Foam::tmp> Foam::operator- const faMatrix& A ) { - tmp> tC(new faMatrix(A)); + auto tC = tmp>::New(A); tC.ref().negate(); return tC; } @@ -1288,7 +1288,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, B, "-"); - tmp> tC(new faMatrix(A)); + auto tC = tmp>::New(A); tC.ref() -= B; return tC; } diff --git a/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C b/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C index 87d5ef0e03..600adc3ce0 100644 --- a/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C +++ b/src/finiteArea/faMatrices/faMatrix/faMatrixSolve.C @@ -192,8 +192,8 @@ Foam::SolverPerformance Foam::faMatrix::solve() template Foam::tmp> Foam::faMatrix::residual() const { - tmp> tres(new Field(source_)); - Field& res = tres().ref(); + auto tres = tmp>::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 728fa8e89b..f4d1e26592 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::valueInternalCoeffs const tmp& ) const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::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 8aa6296aa0..70b711375f 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::patchNeighbourField() const const Field& iField = this->primitiveField(); const labelUList& faceCells = cyclicPatch_.faceCells(); - tmp> tpnf(new Field(this->size())); - Field& pnf = tpnf.ref(); + auto tpnf = tmp>::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 e9bd75e3ff..d3e5c31d78 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::snGradTransformDiag() const const vector diagV(diagT.xx(), diagT.yy(), diagT.zz()); - return tmp> + return tmp>::New ( - new Field + this->size(), + transformMask ( - this->size(), - transformMask + pow ( - pow - ( - diagV, - pTraits::rank> - ::type>::zero - ) + diagV, + pTraits + < + typename powProduct::rank>::type + >::zero ) ) ); diff --git a/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/clampedPlate/clampedPlateFaPatchField.H index 828937bb6c..4cb191c158 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> snGrad() const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::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 3b04c3fbbd..b9d26257fb 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::valueInternalCoeffs const tmp& weights ) const { - return tmp> - ( - new Field(Type(pTraits::one)*weights) - ); + return pTraits::one*weights; } diff --git a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H index 96428b68fd..fd1c318d8e 100644 --- a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H +++ b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H @@ -377,10 +377,7 @@ public: const DimensionedField& iF ) const { - return tmp> - ( - new faePatchField(*this, iF) - ); + return tmp>::New(*this, iF); } diff --git a/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.C b/src/finiteArea/finiteArea/divSchemes/faDivScheme/faDivScheme.C index ee05ffe259..6d85dfafd9 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::New } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -divScheme::~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 56f4abc534..47414a9123 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 faMatrix; - +// Forward Declarations +template class faMatrix; class faMesh; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -69,12 +68,12 @@ class divScheme : public refCount { - protected: - // Protected data + // Protected Data const faMesh& mesh_; + tmp> tinterpScheme_; @@ -113,9 +112,23 @@ public: //- Construct from mesh and Istream divScheme(const faMesh& mesh, Istream& is) : - mesh_(mesh), - tinterpScheme_(edgeInterpolationScheme::New(mesh, is)) - {} + mesh_(mesh) + { + if (is.eof()) + { + tinterpScheme_.reset + ( + new linearEdgeInterpolation(mesh) + ); + } + else + { + tinterpScheme_.reset + ( + edgeInterpolationScheme::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 d92add74ee..98e834128f 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(mesh) diff --git a/src/finiteArea/finiteArea/gradSchemes/gaussFaGrad/gaussFaGrad.H b/src/finiteArea/finiteArea/gradSchemes/gaussFaGrad/gaussFaGrad.H index f0348ffdda..59fc08d91d 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(mesh), - tinterpScheme_(nullptr) + gradScheme(mesh) { if (is.eof()) { - tinterpScheme_ = - tmp> - ( - new linearEdgeInterpolation(mesh) - ); + tinterpScheme_.reset + ( + new linearEdgeInterpolation(mesh) + ); } else { - tinterpScheme_ = - tmp> - ( - edgeInterpolationScheme::New(mesh, is) - ); + tinterpScheme_.reset + ( + edgeInterpolationScheme::New(mesh, is) + ); } } diff --git a/src/finiteArea/finiteArea/laplacianSchemes/faLaplacianScheme/faLaplacianScheme.H b/src/finiteArea/finiteArea/laplacianSchemes/faLaplacianScheme/faLaplacianScheme.H index 01a1e34787..009d2a8001 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 faMatrix; - +// Forward Declarations +template class faMatrix; class faMesh; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -70,12 +69,12 @@ class laplacianScheme : public refCount { - protected: - // Protected data + // Protected Data const faMesh& mesh_; + tmp> tinterpGammaScheme_; tmp> 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> + tinterpGammaScheme_.reset ( new linearEdgeInterpolation(mesh) ); - tlnGradScheme_ = tmp> + tlnGradScheme_.reset ( new correctedLnGrad(mesh) ); } else { - tinterpGammaScheme_ = tmp> + tinterpGammaScheme_.reset ( edgeInterpolationScheme::New(mesh, is) ); - tlnGradScheme_ = tmp> + tlnGradScheme_.reset ( lnGradScheme::New(mesh, is) ); @@ -218,11 +215,11 @@ public: \ namespace Foam \ { \ - namespace fa \ - { \ - laplacianScheme::addIstreamConstructorToTable> \ - add##SS##Type##IstreamConstructorToTable_; \ - } \ + namespace fa \ + { \ + laplacianScheme::addIstreamConstructorToTable> \ + add##SS##Type##IstreamConstructorToTable_; \ + } \ } diff --git a/src/finiteArea/finiteArea/laplacianSchemes/gaussFaLaplacianScheme/gaussFaLaplacianScheme.H b/src/finiteArea/finiteArea/laplacianSchemes/gaussFaLaplacianScheme/gaussFaLaplacianScheme.H index fac32562cc..7da2395700 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(mesh) diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C index c3b4084131..a66957b9ec 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZoneList.C @@ -188,18 +188,13 @@ Foam::tmp Foam::MRFZoneList::DDt const volVectorField& U ) const { - auto tacceleration = - tmp::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::MRFZoneList::relative return rphi; } - else - { - return tmp(tphi, true); - } + + return tmp(tphi, true); } @@ -289,10 +282,8 @@ Foam::MRFZoneList::relative return rphi; } - else - { - return tmp>(tphi, true); - } + + return tmp>(tphi, true); } @@ -316,10 +307,8 @@ Foam::MRFZoneList::relative return rphi; } - else - { - return tmp>(tphi, true); - } + + return tmp>(tphi, true); } @@ -378,10 +367,8 @@ Foam::tmp Foam::MRFZoneList::absolute return rphi; } - else - { - return tmp(tphi, true); - } + + return tmp(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 683f2a9c66..58b002be2d 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::SRF::SRFModel::Fcoriolis() const { - return tmp + 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::SRF::SRFModel::Fcentrifugal() const { - return tmp + 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 tfld = + return vectorField + ( omega_.value() ^ ( (positions - origin_.value()) - axis_*(axis_ & (positions - origin_.value())) - ); - - return tfld(); + ) + ); } @@ -186,18 +173,11 @@ Foam::tmp Foam::SRF::SRFModel::U() const volVectorField::Boundary::localConsistency = 0; tmp relPos(mesh_.C() - origin_); - tmp 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::SRF::SRFModel::Uabs() const { tmp Usrf = U(); - tmp 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 8112e1c689..201ecb634d 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C @@ -42,8 +42,8 @@ Foam::tmp> Foam::fv::optionList::source { checkApplied(); - tmp> tmtx(new fvMatrix(field, ds)); - fvMatrix& mtx = tmtx.ref(); + auto tmtx = tmp>::New(field, ds); + auto& mtx = tmtx.ref(); for (fv::option& source : *this) { @@ -129,8 +129,8 @@ Foam::tmp> Foam::fv::optionList::operator() rho.dimensions()*field.dimensions()/dimTime*dimVolume ); - tmp> tmtx(new fvMatrix(field, ds)); - fvMatrix& mtx = tmtx.ref(); + auto tmtx = tmp>::New(field, ds); + auto& mtx = tmtx.ref(); for (fv::option& source : *this) { @@ -198,8 +198,8 @@ Foam::tmp> Foam::fv::optionList::operator() /dimTime*dimVolume ); - tmp> tmtx(new fvMatrix(field, ds)); - fvMatrix& mtx = tmtx.ref(); + auto tmtx = tmp>::New(field, ds); + auto& mtx = tmtx.ref(); for (fv::option& source : *this) { diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.C b/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.C index a341b20543..7b37201c35 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.C +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptions.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -102,7 +102,7 @@ Foam::fv::options::options Foam::fv::options& Foam::fv::options::New(const fvMesh& mesh) { - options* ptr = mesh.thisDb().getObjectPtr(typeName); + auto* ptr = mesh.thisDb().getObjectPtr(typeName); if (!ptr) { diff --git a/src/finiteVolume/cfdTools/general/levelSet/levelSet.C b/src/finiteVolume/cfdTools/general/levelSet/levelSet.C index 4e800b71a0..2dcea81c81 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> tResult + auto tResult = DimensionedField::New ( - new DimensionedField - ( - IOobject - ( - "levelSetFraction", - mesh.time().timeName(), - mesh - ), - mesh, - dimensionedScalar(dimless, Zero) - ) + "levelSetFraction", + IOobject::NO_REGISTER, + mesh, + dimensionedScalar(dimless, Zero) ); - DimensionedField& result = tResult.ref(); + auto& result = tResult.ref(); forAll(result, cI) { @@ -113,8 +106,8 @@ Foam::tmp Foam::levelSetFraction const bool above ) { - tmp tResult(new scalarField(patch.size(), Zero)); - scalarField& result = tResult.ref(); + auto tResult = tmp::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 f5e154f93b..17b8e935ac 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::levelSetAverage const DimensionedField& negativeP ) { - tmp> tResult + auto tresult = DimensionedField::New ( - new DimensionedField - ( - IOobject - ( - positiveC.name() + ":levelSetAverage", - mesh.time().timeName(), - mesh - ), - mesh, - dimensioned(positiveC.dimensions(), Zero) - ) + IOobject::scopedName(positiveC.name(), "levelSetAverage"), + mesh, + Foam::zero{}, // value + positiveC.dimensions() ); - DimensionedField& result = tResult.ref(); + auto& result = tresult.ref(); forAll(result, cI) { @@ -114,7 +107,7 @@ Foam::tmp> Foam::levelSetAverage result[cI] = r/v; } - return tResult; + return tresult; } @@ -132,8 +125,8 @@ Foam::tmp> Foam::levelSetAverage { typedef typename outerProduct::type sumType; - tmp> tResult(new Field(patch.size(), Zero)); - Field& result = tResult.ref(); + auto tResult = tmp>::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 2ac51692d2..5fbe22d284 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 283e46f9ae..eb4ea67311 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::porosityModel::porosityModel::force { transformModelData(); - tmp tforce(new vectorField(U.size(), Zero)); + auto tforce = tmp::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 dd3731399d..8a567b7150 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::valueInternalCoeffs const tmp& ) const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::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 65f532974f..e7aad92d1a 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::valueInternalCoeffs const tmp& ) const { - return tmp> - ( - new Field(this->size(), pTraits::one) - ); + return tmp>::New(this->size(), pTraits::one); } @@ -126,10 +123,7 @@ Foam::zeroGradientFvPatchField::valueBoundaryCoeffs const tmp& ) const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } @@ -137,10 +131,7 @@ template Foam::tmp> Foam::zeroGradientFvPatchField::gradientInternalCoeffs() const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } @@ -148,10 +139,7 @@ template Foam::tmp> Foam::zeroGradientFvPatchField::gradientBoundaryCoeffs() const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::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 0d6dac5c15..487bdb8dff 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::patchNeighbourField() const const labelUList& nbrFaceCells = cyclicPatch().cyclicPatch().neighbPatch().faceCells(); - tmp> tpnf(new Field(this->size())); - Field& pnf = tpnf.ref(); + auto tpnf = tmp>::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 7c139b2f9f..d784d09aff 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C @@ -903,7 +903,8 @@ Foam::cyclicACMIFvPatchField::coeffs matrix.lduMeshAssembly().cellBoundMap()[mat][index].size() ); - Field mapCoeffs(nSubFaces, Zero); + auto tmapCoeffs = tmp>::New(nSubFaces, Zero); + auto& mapCoeffs = tmapCoeffs.ref(); const scalarListList& srcWeight = cyclicACMIPatch_.cyclicACMIPatch().AMI().srcWeights(); @@ -928,7 +929,7 @@ Foam::cyclicACMIFvPatchField::coeffs } } - return tmp>(new Field(mapCoeffs)); + return tmapCoeffs; } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/symmetryPlane/symmetryPlaneFvPatchField.C index 53851b7e00..b83f6c80a9 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::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> + return tmp>::New ( - new Field + this->size(), + transformMask ( - this->size(), - transformMask + //pow::rank>(diag) + pow ( - //pow::rank>(diag) - pow - ( - diag, - pTraits::rank> - ::type>::zero - ) + diag, + pTraits + < + typename powProduct::rank>::type + >::zero ) ) ); diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/wedge/wedgeFvPatchField.C index 8d63c8a5d8..e3fd64d58d 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::snGradTransformDiag() const const vector diagV(diagT.xx(), diagT.yy(), diagT.zz()); - return tmp> + return tmp>::New ( - new Field + this->size(), + transformMask ( - this->size(), - transformMask + pow ( - pow - ( - diagV, - pTraits::rank> - ::type>::zero - ) + diagV, + pTraits + < + typename powProduct::rank>::type + >::zero ) ) ); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedPatchFieldBase.C index 117913ff8e..786ab2511b 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::mappedPatchFieldBase::mappedInternalField() const { // Swap to obtain full local values of neighbour internal field - tmp> tnbrIntFld(new Field()); - Field& nbrIntFld = tnbrIntFld.ref(); + auto tnbrIntFld = tmp>::New(); + auto& nbrIntFld = tnbrIntFld.ref(); if (mapper_.sameWorld()) { @@ -855,8 +855,8 @@ Foam::tmp Foam::mappedPatchFieldBase::mappedWeightField() const { // Swap to obtain full local values of neighbour internal field - tmp tnbrKDelta(new scalarField()); - scalarField& nbrKDelta = tnbrKDelta.ref(); + auto tnbrKDelta = tmp::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 e681852103..f457b1d07d 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::valueInternalCoeffs const tmp& ) const { - return tmp> - ( - new Field(this->size(), Zero) - ); + return tmp>::New(this->size(), Foam::zero{}); } diff --git a/src/finiteVolume/finiteVolume/divSchemes/divScheme/divScheme.H b/src/finiteVolume/finiteVolume/divSchemes/divScheme/divScheme.H index 3cf30c8e4d..61b4707f07 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> tinterpScheme_; @@ -120,8 +120,23 @@ public: divScheme(const fvMesh& mesh, Istream& is) : mesh_(mesh), - tinterpScheme_(surfaceInterpolationScheme::New(mesh, is)) - {} + tinterpScheme_(nullptr) + { + if (is.eof()) + { + tinterpScheme_.reset + ( + new linear(mesh) + ); + } + else + { + tinterpScheme_.reset + ( + surfaceInterpolationScheme::New(mesh, is) + ); + } + } // Selectors diff --git a/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H index a5ceacf97a..3b4b306f61 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> - ( - new linear(mesh) - ); + tinterpScheme_.reset + ( + new linear(mesh) + ); } else { - tinterpScheme_ = - tmp> - ( - surfaceInterpolationScheme::New(mesh, is) - ); + tinterpScheme_.reset + ( + surfaceInterpolationScheme::New(mesh, is) + ); } } diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C b/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C index 8e032da8cc..8de5e717cf 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::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 fe1eba2077..ab8b82a211 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 fvMatrix; - +// Forward Declarations +template class fvMatrix; class fvMesh; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -72,19 +71,16 @@ class laplacianScheme : public refCount { - protected: - // Protected data + // Protected Data const fvMesh& mesh_; tmp> tinterpGammaScheme_; tmp> 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::New(mesh, is) - ); + if (is.eof()) + { + tinterpGammaScheme_.reset(new linear(mesh)); + tsnGradScheme_.reset(new correctedSnGrad(mesh)); + } + else + { + tinterpGammaScheme_.reset + ( + surfaceInterpolationScheme::New(mesh, is) + ); - tsnGradScheme_ = tmp> - ( - snGradScheme::New(mesh, is) - ); + tsnGradScheme_.reset + ( + snGradScheme::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 d0732bf124..ef0efdb299 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianScheme.C +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/relaxedNonOrthoGaussLaplacianScheme/relaxedNonOrthoGaussLaplacianScheme.C @@ -192,7 +192,7 @@ relaxedNonOrthoGaussLaplacianScheme::fvmLaplacian const word corrName(tfaceFluxCorrection().name()); - tmp trelaxedCorrection(new SType(tfaceFluxCorrection())); + auto trelaxedCorrection = tmp::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 7aa0027ec9..ce32fd20fb 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 tfaceFluxCorrection(gammaMagSf*tCorr); \ \ - tmp trelaxedCorrection(new SType(tfaceFluxCorrection())); \ + auto trelaxedCorrection = tmp::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 0b01812677..0506e7dc1a 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/relaxedSnGrad/relaxedSnGrad.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/relaxedSnGrad/relaxedSnGrad.C @@ -61,7 +61,7 @@ Foam::fv::relaxedSnGrad::correction } // Return under/over-relaxed explicit correction field - tmp trelaxedCorrection(new SurfFieldType(tcorrection())); + auto trelaxedCorrection = tmp::New(tcorrection()); SurfFieldType& oldCorrection = obr.lookupObjectRef(oldFieldName); diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index 716a2b1896..bf2ab42635 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -2078,7 +2078,7 @@ Foam::tmp> Foam::operator== ) { checkMethod(A, su, "=="); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += su.mesh().V()*su.field(); return tC; } @@ -2091,7 +2091,7 @@ Foam::tmp> Foam::operator== ) { checkMethod(A, tsu(), "=="); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += tsu().mesh().V()*tsu().field(); tsu.clear(); return tC; @@ -2105,7 +2105,7 @@ Foam::tmp> Foam::operator== ) { checkMethod(A, tsu(), "=="); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); return tC; @@ -2160,7 +2160,7 @@ Foam::tmp> Foam::operator== ) { checkMethod(A, su, "=="); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += A.psi().mesh().V()*su.value(); return tC; } @@ -2206,7 +2206,7 @@ Foam::tmp> Foam::operator- const fvMatrix& A ) { - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().negate(); return tC; } @@ -2231,7 +2231,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, B, "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref() += B; return tC; } @@ -2284,7 +2284,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, su, "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= su.mesh().V()*su.field(); return tC; } @@ -2297,7 +2297,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, tsu(), "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= tsu().mesh().V()*tsu().field(); tsu.clear(); return tC; @@ -2311,7 +2311,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, tsu(), "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); return tC; @@ -2366,7 +2366,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, su, "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= su.mesh().V()*su.field(); return tC; } @@ -2379,7 +2379,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, tsu(), "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= tsu().mesh().V()*tsu().field(); tsu.clear(); return tC; @@ -2393,7 +2393,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, tsu(), "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); return tC; @@ -2449,7 +2449,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, B, "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref() -= B; return tC; } @@ -2503,7 +2503,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, su, "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += su.mesh().V()*su.field(); return tC; } @@ -2516,7 +2516,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, tsu(), "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += tsu().mesh().V()*tsu().field(); tsu.clear(); return tC; @@ -2530,7 +2530,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, tsu(), "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); return tC; @@ -2585,7 +2585,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, su, "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().negate(); tC.ref().source() -= su.mesh().V()*su.field(); return tC; @@ -2599,7 +2599,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, tsu(), "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().negate(); tC.ref().source() -= tsu().mesh().V()*tsu().field(); tsu.clear(); @@ -2614,7 +2614,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, tsu(), "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().negate(); tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField(); tsu.clear(); @@ -2673,7 +2673,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, su, "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= su.value()*A.psi().mesh().V(); return tC; } @@ -2699,7 +2699,7 @@ Foam::tmp> Foam::operator+ ) { checkMethod(A, su, "+"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() -= su.value()*A.psi().mesh().V(); return tC; } @@ -2725,7 +2725,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, su, "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().source() += su.value()*tC().psi().mesh().V(); return tC; } @@ -2751,7 +2751,7 @@ Foam::tmp> Foam::operator- ) { checkMethod(A, su, "-"); - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref().negate(); tC.ref().source() -= su.value()*A.psi().mesh().V(); return tC; @@ -2779,7 +2779,7 @@ Foam::tmp> Foam::operator* const fvMatrix& A ) { - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref() *= dsf; return tC; } @@ -2791,7 +2791,7 @@ Foam::tmp> Foam::operator* const fvMatrix& A ) { - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref() *= tdsf; return tC; } @@ -2803,7 +2803,7 @@ Foam::tmp> Foam::operator* const fvMatrix& A ) { - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref() *= tvsf; return tC; } @@ -2851,7 +2851,7 @@ Foam::tmp> Foam::operator* const fvMatrix& A ) { - tmp> tC(new fvMatrix(A)); + auto tC = tmp>::New(A); tC.ref() *= ds; return tC; } diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C index 8fbd115003..000306e352 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C @@ -363,8 +363,8 @@ Foam::SolverPerformance Foam::fvMatrix::solve() template Foam::tmp> Foam::fvMatrix::residual() const { - tmp> tres(new Field(source_)); - Field& res = tres.ref(); + auto tres = tmp>::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 8476a24df4..6cfef0e944 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 tcc(new pointField(mesh_.nCells(), Zero)); - pointField& cc = tcc.ref(); + auto tcc = tmp::New(mesh_.nCells(), Zero); + auto& cc = tcc.ref(); Field cellWeights(mesh_.nCells(), Zero); @@ -382,8 +382,8 @@ Foam::averageNeighbourFvGeometryScheme::averageCentres const labelList& nei = mesh_.faceNeighbour(); - tmp tnewFc(new pointField(faceCentres)); - pointField& newFc = tnewFc.ref(); + auto tnewFc = tmp::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 e7afa733b1..4b34dc5e27 100644 --- a/src/finiteVolume/fvMesh/fvMeshGeometry.C +++ b/src/finiteVolume/fvMesh/fvMeshGeometry.C @@ -376,25 +376,22 @@ Foam::tmp Foam::fvMesh::delta() const { DebugInFunction << "Calculating face deltas" << endl; - tmp tdelta + auto tdelta = tmp::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::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 a8eccd2c9f..af2cb8a4ed 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::cyclicFvPatch::delta() const const vectorField patchD(coupledFvPatch::delta()); const vectorField nbrPatchD(neighbFvPatch().coupledFvPatch::delta()); - tmp tpdv(new vectorField(patchD.size())); - vectorField& pdv = tpdv.ref(); + auto tpdv = tmp::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 5984f960c7..7141a428d3 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 + 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 aed48475eb..a6beca477a 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -161,7 +161,7 @@ Foam::LimitedScheme::limiter ( limiterFieldName, mesh.time().timeName(), - mesh, + mesh.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -170,7 +170,7 @@ Foam::LimitedScheme::limiter dimless ); - mesh.objectRegistry::store(fldptr); + regIOobject::store(fldptr); } auto& limiterField = *fldptr; @@ -184,19 +184,11 @@ Foam::LimitedScheme::limiter } else { - tmp 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 8bfb0360dc..5ad8ee370c 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& ) const { - tmp 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 6ce1aa91e8..f6964af2b4 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 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 edfdf8a992..15d99ffe65 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& fvpff ) { - FieldField* fvspffPtr - ( - new FieldField(fvpff.size()) - ); + auto tresult = tmp>::New(fvpff.size()); + auto& result = tresult.ref(); - forAll(*fvspffPtr, patchi) + forAll(result, patchi) { - fvspffPtr->set + result.set ( patchi, fvsPatchField::NewCalculatedType(fvpff[patchi].patch()).ptr() ); - (*fvspffPtr)[patchi] = fvpff[patchi]; + result[patchi] = fvpff[patchi]; } - return tmp>(fvspffPtr); + return tresult; } diff --git a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C index ed1476717c..fac2318f22 100644 --- a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C +++ b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -232,11 +232,8 @@ Foam::tmp> Foam::volPointInterpolation::flatBoundaryField const fvMesh& mesh = vf.mesh(); const fvBoundaryMesh& bm = mesh.boundary(); - tmp> tboundaryVals - ( - new Field(mesh.nBoundaryFaces()) - ); - Field& boundaryVals = tboundaryVals.ref(); + auto tboundaryVals = tmp>::New(mesh.nBoundaryFaces()); + auto& boundaryVals = tboundaryVals.ref(); forAll(vf.boundaryField(), patchi) { @@ -570,8 +567,8 @@ Foam::volPointInterpolation::interpolate if (!pfPtr) { solution::cachePrintMessage("Calculating and caching", name, vf); - pfPtr = interpolate(vf, name, false).ptr(); + pfPtr = interpolate(vf, name, false).ptr(); regIOobject::store(pfPtr); } else diff --git a/src/functionObjects/field/CourantNo/CourantNo.C b/src/functionObjects/field/CourantNo/CourantNo.C index 98aeb51a9c..198fbfaa24 100644 --- a/src/functionObjects/field/CourantNo/CourantNo.C +++ b/src/functionObjects/field/CourantNo/CourantNo.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -88,7 +88,7 @@ bool Foam::functionObjects::CourantNo::calc() ( resultName_, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -97,7 +97,7 @@ bool Foam::functionObjects::CourantNo::calc() dimensionedScalar(dimless, Zero), fvPatchFieldBase::zeroGradientType() ); - mesh_.objectRegistry::store(resultPtr); + regIOobject::store(resultPtr); } auto& Co = *resultPtr; diff --git a/src/functionObjects/field/PecletNo/PecletNo.C b/src/functionObjects/field/PecletNo/PecletNo.C index 4550954207..8ef656db1d 100644 --- a/src/functionObjects/field/PecletNo/PecletNo.C +++ b/src/functionObjects/field/PecletNo/PecletNo.C @@ -79,16 +79,10 @@ bool Foam::functionObjects::PecletNo::calc() const dictionary& model = mesh_.lookupObject("transportProperties"); - nuEff = tmp::New + nuEff = volScalarField::New ( - IOobject - ( - "nuEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "nuEff", + IOobject::NO_REGISTER, mesh_, dimensionedScalar("nu", dimViscosity, model) ); diff --git a/src/functionObjects/field/columnAverage/columnAverageTemplates.C b/src/functionObjects/field/columnAverage/columnAverageTemplates.C index 6a6b537500..2bba02a3dc 100644 --- a/src/functionObjects/field/columnAverage/columnAverageTemplates.C +++ b/src/functionObjects/field/columnAverage/columnAverageTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,14 +57,14 @@ bool Foam::functionObjects::columnAverage::columnAverageField ( resultName, fld.mesh().time().timeName(), - fld.mesh(), + fld.db(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER ), fld ); - obr_.objectRegistry::store(resPtr); + regIOobject::store(resPtr); } fieldType& res = *resPtr; diff --git a/src/functionObjects/field/expressions/fvExpressionField.C b/src/functionObjects/field/expressions/fvExpressionField.C index 7b3444f6f8..3ab2ae93d4 100644 --- a/src/functionObjects/field/expressions/fvExpressionField.C +++ b/src/functionObjects/field/expressions/fvExpressionField.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021-2022 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -137,7 +137,7 @@ bool Foam::functionObjects::fvExpressionField::loadAndStore(const IOobject& io) Log << " Reading " << io.name() << " (" << FieldType::typeName << ')' << endl; - mesh_.objectRegistry::store(new FieldType(io, mesh_)); + regIOobject::store(new FieldType(io, mesh_)); return true; } diff --git a/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C b/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C index 3829d78322..c8e2c76cb5 100644 --- a/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C +++ b/src/functionObjects/field/extractEulerianParticles/extractEulerianParticles/extractEulerianParticles.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -531,9 +531,10 @@ bool Foam::functionObjects::extractEulerianParticles::execute() const volScalarField& alpha = mesh_.lookupObject(alphaName_); - const surfaceScalarField alphaf + auto talphaf = surfaceScalarField::New ( - typeName + ":alphaf", + IOobject::scopedName(typeName, "alphaf"), + IOobject::NO_REGISTER, fvc::interpolate(alpha) ); @@ -546,7 +547,7 @@ bool Foam::functionObjects::extractEulerianParticles::execute() // Set the blocked faces, i.e. where alpha > alpha threshold value boolList blockedFaces(fz.size(), false); - setBlockedFaces(alphaf, fz, blockedFaces); + setBlockedFaces(talphaf(), fz, blockedFaces); // Split the faceZone according to the blockedFaces // - Returns a list of (disconnected) region index per face zone face @@ -567,7 +568,7 @@ bool Foam::functionObjects::extractEulerianParticles::execute() // Process latest region information tmp tphi = phiU(); - accumulateParticleInfo(alphaf, tphi(), regionFaceIDs, fz); + accumulateParticleInfo(talphaf(), tphi(), regionFaceIDs, fz); Log << " Collected particles : " << nCollectedParticles_ << nl << " Collected volume : " << collectedVolume_ << nl diff --git a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeff.C b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeff.C index 5c33fcdc62..9c0925c306 100644 --- a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeff.C +++ b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeff.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2022 OpenCFD Ltd. + Copyright (C) 2017-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,6 +71,7 @@ Foam::functionObjects::heatTransferCoeff::heatTransferCoeff { read(dict); + // scopedName? setResultName(typeName, "htc:" + htcModelPtr_->type()); auto* heatTransferCoeffPtr = @@ -80,7 +81,7 @@ Foam::functionObjects::heatTransferCoeff::heatTransferCoeff ( resultName_, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -89,7 +90,7 @@ Foam::functionObjects::heatTransferCoeff::heatTransferCoeff dimensionedScalar(dimPower/dimArea/dimTemperature, Zero) ); - mesh_.objectRegistry::store(heatTransferCoeffPtr); + regIOobject::store(heatTransferCoeffPtr); } diff --git a/src/functionObjects/field/heatTransferCoeff/multiphaseInterHtcModel/multiphaseInterHtcModel.C b/src/functionObjects/field/heatTransferCoeff/multiphaseInterHtcModel/multiphaseInterHtcModel.C index 206827e72a..c1b17947c3 100644 --- a/src/functionObjects/field/heatTransferCoeff/multiphaseInterHtcModel/multiphaseInterHtcModel.C +++ b/src/functionObjects/field/heatTransferCoeff/multiphaseInterHtcModel/multiphaseInterHtcModel.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022-2023 OpenCFD Ltd. + Copyright (C) 2022-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -127,6 +127,7 @@ Foam::functionObjects::multiphaseInterHtcModel::multiphaseInterHtcModel { read(dict); + // scopedName? setResultName(typeName, "htc:" + htcModelPtr_->type()); auto* htcPtr = @@ -136,7 +137,7 @@ Foam::functionObjects::multiphaseInterHtcModel::multiphaseInterHtcModel ( resultName_, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -145,7 +146,7 @@ Foam::functionObjects::multiphaseInterHtcModel::multiphaseInterHtcModel dimensionedScalar(dimPower/dimArea/dimTemperature, Zero) ); - mesh_.objectRegistry::store(htcPtr); + regIOobject::store(htcPtr); } diff --git a/src/functionObjects/field/heatTransferCoeff/reactingEulerHtcModel/reactingEulerHtcModel.C b/src/functionObjects/field/heatTransferCoeff/reactingEulerHtcModel/reactingEulerHtcModel.C index fa8108e9b3..f9d403f776 100644 --- a/src/functionObjects/field/heatTransferCoeff/reactingEulerHtcModel/reactingEulerHtcModel.C +++ b/src/functionObjects/field/heatTransferCoeff/reactingEulerHtcModel/reactingEulerHtcModel.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -145,7 +145,7 @@ Foam::functionObjects::reactingEulerHtcModel::reactingEulerHtcModel ( resultName_, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -154,7 +154,7 @@ Foam::functionObjects::reactingEulerHtcModel::reactingEulerHtcModel dimensionedScalar(dimPower/dimArea/dimTemperature, Zero) ); - mesh_.objectRegistry::store(htcPtr); + regIOobject::store(htcPtr); } diff --git a/src/functionObjects/field/histogram/histogramModels/histogramModel/histogramModel.C b/src/functionObjects/field/histogram/histogramModels/histogramModel/histogramModel.C index 790f5c2348..95feae0b32 100644 --- a/src/functionObjects/field/histogram/histogramModels/histogramModel/histogramModel.C +++ b/src/functionObjects/field/histogram/histogramModels/histogramModel/histogramModel.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,14 +66,14 @@ Foam::volScalarField& Foam::histogramModel::getOrReadField ( fieldName, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::AUTO_WRITE, IOobject::REGISTER ), mesh_ ); - mesh_.objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/functionObjects/field/limitFields/limitFieldsTemplates.C b/src/functionObjects/field/limitFields/limitFieldsTemplates.C index 0b20a6cbe2..25ab497be0 100644 --- a/src/functionObjects/field/limitFields/limitFieldsTemplates.C +++ b/src/functionObjects/field/limitFields/limitFieldsTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -49,22 +49,36 @@ bool Foam::functionObjects::limitFields::limitField(const word& fieldName) if (withBounds_ & limitType::CLAMP_MIN) { - volScalarField mField(typeName + ":mag" + field.name(), mag(field)); + auto tmField = volScalarField::New + ( + IOobject::scopedName(typeName, "mag" + field.name()), + IOobject::NO_REGISTER, + mag(field) + ); + auto& mField = tmField.ref(); + Log << " min(|" << gMin(mField) << "|)"; //field.normalise(); field /= mag(field) + eps; mField.clamp_min(min_); - field *= mField; + field *= tmField; } if (withBounds_ & limitType::CLAMP_MAX) { - volScalarField mField(typeName + ":mag" + field.name(), mag(field)); + auto tmField = volScalarField::New + ( + IOobject::scopedName(typeName, "mag" + field.name()), + IOobject::NO_REGISTER, + mag(field) + ); + auto& mField = tmField.ref(); + Log << " max(|" << gMax(mField) << "|)"; //field.normalise(); field /= mag(field) + eps; mField.clamp_max(max_); - field *= mField; + field *= tmField; } return true; diff --git a/src/functionObjects/field/momentum/momentum.C b/src/functionObjects/field/momentum/momentum.C index 04a3f131ae..ed24a5837b 100644 --- a/src/functionObjects/field/momentum/momentum.C +++ b/src/functionObjects/field/momentum/momentum.C @@ -446,14 +446,14 @@ bool Foam::functionObjects::momentum::read(const dictionary& dict) { Info<< " Momentum fields will be written" << endl; - mesh_.objectRegistry::store + regIOobject::store ( newField("momentum", dimVelocity*dimMass) ); if (hasCsys_) { - mesh_.objectRegistry::store + regIOobject::store ( newField("angularMomentum", dimVelocity*dimMass) ); @@ -466,7 +466,7 @@ bool Foam::functionObjects::momentum::read(const dictionary& dict) { Info<< " Angular velocity will be written" << endl; - mesh_.objectRegistry::store + regIOobject::store ( newField("angularVelocity", dimVelocity) ); diff --git a/src/functionObjects/field/momentumError/momentumError.C b/src/functionObjects/field/momentumError/momentumError.C index 6bbc1068fc..fa467510e3 100644 --- a/src/functionObjects/field/momentumError/momentumError.C +++ b/src/functionObjects/field/momentumError/momentumError.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -154,53 +154,54 @@ Foam::functionObjects::momentumError::momentumError phi.dimensions()*dimVelocity/dimVolume ); - - volVectorField* momentPtr = nullptr; - - word momName(scopedName("momentError")); - if (zoneSubSetPtr_) { const fvMesh& subMesh = zoneSubSetPtr_->subsetter().subMesh(); // momentErrorMap - momentPtr = new volVectorField + volVectorField* fldPtr = new volVectorField ( IOobject ( scopedName("momentErrorMap"), subMesh.time().timeName(), - subMesh, + subMesh.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER ), subMesh, - dimensionedVector(momDims) + dimensionedVector(momDims, Zero) ); - subMesh.objectRegistry::store(momentPtr); + regIOobject::store(fldPtr); - momName = scopedName("momentErrorZone"); } - momentPtr = new volVectorField + const word momName = + ( + zoneSubSetPtr_ + ? scopedName("momentErrorZone") + : scopedName("momentError") + ); + + volVectorField* fldPtr = new volVectorField ( IOobject ( momName, time_.timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER ), mesh_, - dimensionedVector(momDims) + dimensionedVector(momDims, Zero) ); - mesh_.objectRegistry::store(momentPtr); + regIOobject::store(fldPtr); } diff --git a/src/functionObjects/field/pressure/pressure.C b/src/functionObjects/field/pressure/pressure.C index be7d849a2f..712557669c 100644 --- a/src/functionObjects/field/pressure/pressure.C +++ b/src/functionObjects/field/pressure/pressure.C @@ -131,17 +131,10 @@ Foam::tmp Foam::functionObjects::pressure::rhoScale { if (p.dimensions() == dimPressure) { - return tmp::New + return volScalarField::New ( - IOobject - ( - "rhoScale", - p.mesh().time().timeName(), - p.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "rhoScale", + IOobject::NO_REGISTER, p, fvPatchFieldBase::calculatedType() ); @@ -236,21 +229,14 @@ Foam::tmp Foam::functionObjects::pressure::calcPressure ) const { // Initialise to the pressure reference level - auto tresult = - tmp::New - ( - IOobject - ( - scopedName("p"), - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ - ), - mesh_, - dimensionedScalar("p", dimPressure, pRef_) - ); - - volScalarField& result = tresult.ref(); + auto tresult = volScalarField::New + ( + scopedName("p"), + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar("p", dimPressure, pRef_) + ); + auto& result = tresult.ref(); addHydrostaticContribution(p, result); @@ -304,7 +290,7 @@ Foam::tmp Foam::functionObjects::pressure::coeff if (mode_ & COEFF) { tmp tpCoeff(tp.ptr()); - volScalarField& pCoeff = tpCoeff.ref(); + auto& pCoeff = tpCoeff.ref(); pCoeff -= dimensionedScalar("pInf", dimPressure, pInf_); @@ -325,21 +311,16 @@ Foam::tmp Foam::functionObjects::pressure::coeff bool Foam::functionObjects::pressure::calc() { - if (foundObject(fieldName_)) - { - const volScalarField& p = lookupObject(fieldName_); + const auto* pptr = cfindObject(fieldName_); - auto tp = tmp::New + if (pptr) + { + const auto& p = *pptr; + + auto tp = volScalarField::New ( - IOobject - ( - resultName_, - p.mesh().time().timeName(), - p.mesh(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::REGISTER - ), + resultName_, + IOobject::REGISTER, coeff(calcPressure(p, rhoScale(p))) ); diff --git a/src/functionObjects/field/proudmanAcousticPower/proudmanAcousticPower.C b/src/functionObjects/field/proudmanAcousticPower/proudmanAcousticPower.C index 0718ae315f..4a002caeb2 100644 --- a/src/functionObjects/field/proudmanAcousticPower/proudmanAcousticPower.C +++ b/src/functionObjects/field/proudmanAcousticPower/proudmanAcousticPower.C @@ -87,18 +87,13 @@ Foam::functionObjects::proudmanAcousticPower::a() const return sqrt(thermo.gamma()*thermo.p()/thermo.rho()); } - return - tmp::New - ( - IOobject - ( - scopedName("a"), - mesh_.time().timeName(), - mesh_ - ), - mesh_, - aRef_ - ); + return volScalarField::New + ( + scopedName("a"), + IOobject::NO_REGISTER, + mesh_, + aRef_ + ); } diff --git a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C index a0bc517f95..4429bb803b 100644 --- a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C +++ b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C @@ -80,20 +80,14 @@ calculateSpeciesRR const basicChemistryModel& basicChemistry ) { - auto RRt = tmp>::New + auto tRR = volScalarField::Internal::New ( - IOobject - ( - "RR", - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "RR", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimMass/dimVolume/dimTime, Zero) ); - auto& RR = RRt.ref(); + auto& RR = tRR.ref(); scalar dt = time_.deltaTValue(); diff --git a/src/functionObjects/field/readFields/readFieldsTemplates.C b/src/functionObjects/field/readFields/readFieldsTemplates.C index 2ce668755f..5cf6018bdd 100644 --- a/src/functionObjects/field/readFields/readFieldsTemplates.C +++ b/src/functionObjects/field/readFields/readFieldsTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2020 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,7 +42,7 @@ bool Foam::functionObjects::readFields::loadAndStore(const IOobject& io) Log << " Reading " << io.name() << " (" << io.headerClassName() << ')' << endl; - mesh_.objectRegistry::store(new FieldType(io, mesh_)); + regIOobject::store(new FieldType(io, mesh_)); return true; } diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index a15639fe34..c5e86068c6 100644 --- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -449,7 +449,8 @@ bool Foam::functionObjects::regionSizeDistribution::write() mesh_.time().timeName(), mesh_, IOobjectOption::MUST_READ, - IOobjectOption::NO_WRITE + IOobjectOption::NO_WRITE, + IOobjectOption::NO_REGISTER ), mesh_ ) @@ -535,18 +536,11 @@ bool Foam::functionObjects::regionSizeDistribution::write() { volScalarField region ( - IOobject - ( - "region", - mesh_.time().timeName(), - mesh_, - IOobjectOption::NO_READ, - IOobjectOption::NO_WRITE, - IOobjectOption::NO_REGISTER - ), + mesh_.newIOobject("region"), mesh_, dimensionedScalar(dimless, Zero) ); + Info<< " Dumping region as volScalarField to " << region.name() << endl; diff --git a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C index fb86bca1ef..947545c828 100644 --- a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C +++ b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModel.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,17 +45,10 @@ namespace Foam Foam::tmp Foam::resolutionIndexModel::V() const { - auto tV = tmp::New + auto tV = volScalarField::New ( - IOobject - ( - "V", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "V", + IOobject::NO_REGISTER, mesh_, dimVolume, fvPatchFieldBase::zeroGradientType() @@ -98,7 +91,7 @@ bool Foam::resolutionIndexModel::read(const dictionary& dict) ( resultName_, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::LAZY_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -108,7 +101,7 @@ bool Foam::resolutionIndexModel::read(const dictionary& dict) fvPatchFieldBase::zeroGradientType() ); - mesh_.objectRegistry::store(indexPtr); + regIOobject::store(indexPtr); } return true; diff --git a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModelTemplates.C b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModelTemplates.C index cdbe29b3d6..641e9ce1ef 100644 --- a/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModelTemplates.C +++ b/src/functionObjects/field/resolutionIndex/resolutionIndexModels/resolutionIndexModel/resolutionIndexModelTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2022 OpenCFD Ltd. + Copyright (C) 2022-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,14 +46,14 @@ GeoFieldType& Foam::resolutionIndexModel::getOrReadField ( fieldName, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::AUTO_WRITE, IOobject::REGISTER ), mesh_ ); - mesh_.objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/functionObjects/field/setFlow/setFlow.C b/src/functionObjects/field/setFlow/setFlow.C index e2e165e7df..dd26dccb60 100644 --- a/src/functionObjects/field/setFlow/setFlow.C +++ b/src/functionObjects/field/setFlow/setFlow.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -240,7 +240,7 @@ bool Foam::functionObjects::setFlow::execute() const volVectorField& C = mesh_.C(); const volVectorField d ( - typeName + ":d", + IOobject::scopedName(typeName, "d"), C - dimensionedVector("origin", dimLength, origin_) ); const scalarField x(d.component(vector::X)); @@ -286,7 +286,7 @@ bool Foam::functionObjects::setFlow::execute() const volVectorField d ( - typeName + ":d", + IOobject::scopedName(typeName, "d"), C - dimensionedVector("origin", dimLength, origin_) ); const scalarField x(d.component(vector::X)); @@ -350,7 +350,7 @@ bool Foam::functionObjects::setFlow::execute() const volVectorField d ( - typeName + ":d", + IOobject::scopedName(typeName, "d"), C - dimensionedVector("origin", dimLength, origin_) ); const scalarField x(d.component(vector::X)); diff --git a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C index ef07ad51de..27a2371d19 100644 --- a/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C +++ b/src/functionObjects/field/stabilityBlendingFactor/stabilityBlendingFactor.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2023 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -65,7 +65,7 @@ Foam::functionObjects::stabilityBlendingFactor::indicator() ( "blendedIndicator" + fieldName_, time_.timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -75,7 +75,7 @@ Foam::functionObjects::stabilityBlendingFactor::indicator() fvPatchFieldBase::zeroGradientType() ); - mesh_.objectRegistry::store(fldPtr); + regIOobject::store(fldPtr); } return *fldPtr; @@ -321,16 +321,10 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first) << exit(FatalError); } - auto tmagGradCC = tmp::New + auto tmagGradCC = volScalarField::New ( - IOobject - ( - "magGradCC", - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "magGradCC", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimless, Zero), fvPatchFieldBase::zeroGradientType() @@ -340,20 +334,16 @@ bool Foam::functionObjects::stabilityBlendingFactor::init(bool first) for (direction i=0; i::New + auto CoPtr = volScalarField::New ( - IOobject - ( - "Co", - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "Co", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimless, Zero), fvPatchFieldBase::zeroGradientType() ); - auto& Co = CoPtr.ref(); Co.primitiveFieldRef() = @@ -533,17 +516,10 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor read(dict); setResultName(typeName, ""); - auto faceBlendedPtr = tmp::New + auto faceBlendedPtr = surfaceScalarField::New ( - IOobject - ( - resultName_, - time_.timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::REGISTER - ), + resultName_, + IOobject::REGISTER, mesh_, dimensionedScalar(dimless, Zero) ); @@ -558,7 +534,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor ( nonOrthogonalityName_, mesh_.time().constant(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -567,7 +543,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor if (fieldHeader.typeHeaderOk(true, true, false)) { auto* vfPtr = new volScalarField(fieldHeader, mesh_); - mesh_.objectRegistry::store(vfPtr); + regIOobject::store(vfPtr); } else { @@ -588,7 +564,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor ( faceWeightName_, mesh_.time().constant(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -597,7 +573,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor if (fieldHeader.typeHeaderOk(true, true, false)) { auto* vfPtr = new volScalarField(fieldHeader, mesh_); - mesh_.objectRegistry::store(vfPtr); + regIOobject::store(vfPtr); } else { @@ -616,7 +592,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor ( skewnessName_, mesh_.time().constant(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -625,7 +601,7 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor if (fieldHeader.typeHeaderOk(true, true, false)) { auto* vfPtr = new volScalarField(fieldHeader, mesh_); - mesh_.objectRegistry::store(vfPtr); + regIOobject::store(vfPtr); } else { diff --git a/src/functionObjects/field/surfaceDistance/surfaceDistance.C b/src/functionObjects/field/surfaceDistance/surfaceDistance.C index f7ad43ebc2..d3362a971d 100644 --- a/src/functionObjects/field/surfaceDistance/surfaceDistance.C +++ b/src/functionObjects/field/surfaceDistance/surfaceDistance.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2022 OpenCFD Ltd. + Copyright (C) 2019-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,7 +61,7 @@ Foam::functionObjects::surfaceDistance::surfaceDistance ( "surfaceDistance", mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -71,7 +71,7 @@ Foam::functionObjects::surfaceDistance::surfaceDistance ) ); - mesh_.objectRegistry::store(distPtr); + regIOobject::store(distPtr); } diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C index e30d45d522..a2a8ba5efc 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C @@ -77,9 +77,10 @@ Foam::functionObjects::turbulenceFields::nuTilda { const dimensionedScalar omega0(dimless/dimTime, SMALL); - return tmp::New + return volScalarField::New ( "nuTilda.tmp", + IOobject::NO_REGISTER, model.k()/(model.omega() + omega0) ); } @@ -96,9 +97,10 @@ Foam::functionObjects::turbulenceFields::L const scalar Cmu = 0.09; const dimensionedScalar eps0(sqr(dimVelocity)/dimTime, SMALL); - return tmp::New + return volScalarField::New ( "L.tmp", + IOobject::NO_REGISTER, pow(Cmu, 0.75)*pow(model.k(), 1.5)/(model.epsilon() + eps0) ); } @@ -116,9 +118,10 @@ Foam::functionObjects::turbulenceFields::I const volScalarField uPrime(sqrt((2.0/3.0)*model.k())); const dimensionedScalar U0(dimVelocity, SMALL); - return tmp::New + return volScalarField::New ( "I.tmp", + IOobject::NO_REGISTER, uPrime/max(max(uPrime, mag(model.U())), U0) ); } diff --git a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C index a97ed64ed0..3235b4cbc5 100644 --- a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C +++ b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 OpenFOAM Foundation - Copyright (C) 2016-2023 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -120,7 +120,7 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux ( scopedName(typeName), mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobjectOption::NO_READ, IOobjectOption::NO_WRITE, IOobjectOption::REGISTER @@ -130,7 +130,7 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux ) ); - mesh_.objectRegistry::store(wallHeatFluxPtr); + regIOobject::store(wallHeatFluxPtr); } diff --git a/src/functionObjects/field/wallShearStress/wallShearStress.C b/src/functionObjects/field/wallShearStress/wallShearStress.C index 83ce52c202..6fd8853dcc 100644 --- a/src/functionObjects/field/wallShearStress/wallShearStress.C +++ b/src/functionObjects/field/wallShearStress/wallShearStress.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation - Copyright (C) 2017-2023 OpenCFD Ltd. + Copyright (C) 2017-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -104,7 +104,7 @@ Foam::functionObjects::wallShearStress::wallShearStress ( scopedName(typeName), mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobjectOption::NO_READ, IOobjectOption::NO_WRITE, IOobjectOption::REGISTER @@ -114,7 +114,7 @@ Foam::functionObjects::wallShearStress::wallShearStress ) ); - mesh_.objectRegistry::store(wallShearStressPtr); + regIOobject::store(wallShearStressPtr); } diff --git a/src/functionObjects/field/yPlus/yPlus.C b/src/functionObjects/field/yPlus/yPlus.C index b175a154bf..f9b5f3a3b5 100644 --- a/src/functionObjects/field/yPlus/yPlus.C +++ b/src/functionObjects/field/yPlus/yPlus.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation - Copyright (C) 2016-2023 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -86,7 +86,7 @@ Foam::functionObjects::yPlus::yPlus ( scopedName(typeName), mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -96,7 +96,7 @@ Foam::functionObjects::yPlus::yPlus ) ); - mesh_.objectRegistry::store(yPlusPtr); + regIOobject::store(yPlusPtr); } diff --git a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C index b749dcf81b..bbad31544f 100644 --- a/src/functionObjects/forces/forceCoeffs/forceCoeffs.C +++ b/src/functionObjects/forces/forceCoeffs/forceCoeffs.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2023 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -63,18 +63,17 @@ void Foam::functionObjects::forceCoeffs::initialise() Foam::volVectorField& Foam::functionObjects::forceCoeffs::forceCoeff() { - auto* coeffPtr = - mesh_.getObjectPtr(scopedName("forceCoeff")); + auto* ptr = mesh_.getObjectPtr(scopedName("forceCoeff")); - if (!coeffPtr) + if (!ptr) { - coeffPtr = new volVectorField + ptr = new volVectorField ( IOobject ( scopedName("forceCoeff"), time_.timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -83,27 +82,26 @@ Foam::volVectorField& Foam::functionObjects::forceCoeffs::forceCoeff() dimensionedVector(dimless, Zero) ); - mesh_.objectRegistry::store(coeffPtr); + regIOobject::store(ptr); } - return *coeffPtr; + return *ptr; } Foam::volVectorField& Foam::functionObjects::forceCoeffs::momentCoeff() { - auto* coeffPtr = - mesh_.getObjectPtr(scopedName("momentCoeff")); + auto* ptr = mesh_.getObjectPtr(scopedName("momentCoeff")); - if (!coeffPtr) + if (!ptr) { - coeffPtr = new volVectorField + ptr = new volVectorField ( IOobject ( scopedName("momentCoeff"), time_.timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -112,10 +110,10 @@ Foam::volVectorField& Foam::functionObjects::forceCoeffs::momentCoeff() dimensionedVector(dimless, Zero) ); - mesh_.objectRegistry::store(coeffPtr); + regIOobject::store(ptr); } - return *coeffPtr; + return *ptr; } diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index b5caaf7b3c..fd7ab2f876 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2023 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -89,17 +89,17 @@ void Foam::functionObjects::forces::setCoordinateSystem Foam::volVectorField& Foam::functionObjects::forces::force() { - auto* forcePtr = mesh_.getObjectPtr(scopedName("force")); + auto* ptr = mesh_.getObjectPtr(scopedName("force")); - if (!forcePtr) + if (!ptr) { - forcePtr = new volVectorField + ptr = new volVectorField ( IOobject ( scopedName("force"), time_.timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -108,26 +108,26 @@ Foam::volVectorField& Foam::functionObjects::forces::force() dimensionedVector(dimForce, Zero) ); - mesh_.objectRegistry::store(forcePtr); + regIOobject::store(ptr); } - return *forcePtr; + return *ptr; } Foam::volVectorField& Foam::functionObjects::forces::moment() { - auto* momentPtr = mesh_.getObjectPtr(scopedName("moment")); + auto* ptr = mesh_.getObjectPtr(scopedName("moment")); - if (!momentPtr) + if (!ptr) { - momentPtr = new volVectorField + ptr = new volVectorField ( IOobject ( scopedName("moment"), time_.timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, IOobject::REGISTER @@ -136,10 +136,10 @@ Foam::volVectorField& Foam::functionObjects::forces::moment() dimensionedVector(dimForce*dimLength, Zero) ); - mesh_.objectRegistry::store(momentPtr); + regIOobject::store(ptr); } - return *momentPtr; + return *ptr; } @@ -311,14 +311,10 @@ Foam::tmp Foam::functionObjects::forces::rho() const { if (rhoName_ == "rhoInf") { - return tmp::New + return volScalarField::New ( - IOobject - ( - "rho", - mesh_.time().timeName(), - mesh_ - ), + "rho", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimDensity, rhoRef_) ); diff --git a/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C b/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C index 9bc7e256f0..1a98fad13c 100644 --- a/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C +++ b/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -182,7 +182,7 @@ Foam::functionObjects::hydrostaticPressure::hydrostaticPressure if (read(dict)) { // Read and store the initial ph_rgh field - volScalarField* ph_rghPtr = + volScalarField* ptr = new volScalarField ( IOobject @@ -197,7 +197,7 @@ Foam::functionObjects::hydrostaticPressure::hydrostaticPressure mesh_ ); - mesh_.objectRegistry::store(ph_rghPtr); + regIOobject::store(ptr); bool reInitialise = dict.getOrDefault("reInitialise", false); diff --git a/src/functionObjects/phaseSystems/sizeDistribution/sizeDistribution.C b/src/functionObjects/phaseSystems/sizeDistribution/sizeDistribution.C index a3d4588ec7..c6038cec9b 100644 --- a/src/functionObjects/phaseSystems/sizeDistribution/sizeDistribution.C +++ b/src/functionObjects/phaseSystems/sizeDistribution/sizeDistribution.C @@ -243,7 +243,7 @@ Foam::functionObjects::sizeDistribution::filterField const scalarField& field ) const { - return tmp(new scalarField(field, cellId_)); + return tmp::New(field, cellId_); } diff --git a/src/functionObjects/solvers/electricPotential/electricPotential.C b/src/functionObjects/solvers/electricPotential/electricPotential.C index 6a83baee67..ff931d8583 100644 --- a/src/functionObjects/solvers/electricPotential/electricPotential.C +++ b/src/functionObjects/solvers/electricPotential/electricPotential.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2021-2023 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,14 +59,14 @@ Foam::volScalarField& Foam::functionObjects::electricPotential::getOrReadField ( fieldName, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::REGISTER ), mesh_ ); - mesh_.objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; @@ -78,12 +78,7 @@ Foam::functionObjects::electricPotential::sigma() const { const IOobject sigmaIO ( - IOobject::scopedName(typeName, "sigma"), - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER + mesh_.thisDb().newIOobject(IOobject::scopedName(typeName, "sigma")) ); if (phases_.size()) @@ -125,12 +120,7 @@ Foam::functionObjects::electricPotential::epsilonm() const const IOobject epsilonrIO ( - IOobject::scopedName(typeName, "epsilonr"), - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER + mesh_.thisDb().newIOobject(IOobject::scopedName(typeName, "epsilonr")) ); if (phases_.size()) @@ -241,13 +231,14 @@ Foam::functionObjects::electricPotential::electricPotential ( Ename_, mesh_.time().timeName(), - mesh_, + mesh_.thisDb(), IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ), -fvc::grad(eV) ); - mesh_.objectRegistry::store(ptr); + regIOobject::store(ptr); } } } @@ -408,17 +399,10 @@ bool Foam::functionObjects::electricPotential::write() // Write the current density field tmp tsigma = this->sigma(); - auto eJ = tmp::New + auto eJ = volVectorField::New ( - IOobject - ( - IOobject::scopedName(typeName, "J"), - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName(typeName, "J"), + IOobject::NO_REGISTER, -tsigma*fvc::grad(eV), fvPatchFieldBase::calculatedType() ); @@ -431,17 +415,10 @@ bool Foam::functionObjects::electricPotential::write() // Write the free-charge density field tmp tepsilonm = this->epsilonm(); - auto erho = tmp::New + auto erho = volScalarField::New ( - IOobject - ( - IOobject::scopedName(typeName, "rho"), - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName(typeName, "rho"), + IOobject::NO_REGISTER, fvc::div(tepsilonm*(-fvc::grad(eV))), fvPatchFieldBase::calculatedType() ); diff --git a/src/functionObjects/solvers/energyTransport/energyTransport.C b/src/functionObjects/solvers/energyTransport/energyTransport.C index ea5b022f11..2a0ac81eba 100644 --- a/src/functionObjects/solvers/energyTransport/energyTransport.C +++ b/src/functionObjects/solvers/energyTransport/energyTransport.C @@ -93,9 +93,10 @@ Foam::functionObjects::energyTransport::kappaEff() const if (turbPtr) { - return tmp + return volScalarField::New ( - new volScalarField + "kappaEff", + IOobject::NO_REGISTER, ( kappa() + Cp()*turbPtr->nut()*rho()/Prt_ ) @@ -113,17 +114,10 @@ Foam::functionObjects::energyTransport::kappaEff() const Foam::tmp Foam::functionObjects::energyTransport::rho() const { - auto trho = tmp::New + auto trho = volScalarField::New ( - IOobject - ( - "trho", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "trho", + IOobject::NO_REGISTER, mesh_, rho_ ); @@ -150,17 +144,10 @@ Foam::functionObjects::energyTransport::Cp() const return tCp; } - return tmp::New + return volScalarField::New ( - IOobject - ( - "tCp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "tCp", + IOobject::NO_REGISTER, mesh_, Cp_ ); @@ -181,22 +168,16 @@ Foam::functionObjects::energyTransport::kappa() const return tkappa; } - return tmp::New + return volScalarField::New ( - IOobject - ( - "tkappa", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "tkappa", + IOobject::NO_REGISTER, mesh_, kappa_ ); } + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::energyTransport::energyTransport @@ -404,16 +385,10 @@ bool Foam::functionObjects::energyTransport::execute() const surfaceScalarField CpPhi(rhoCp*phi); - auto trhoCp = tmp::New + auto trhoCp = volScalarField::New ( - IOobject - ( - "trhoCp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "trhoCp", + IOobject::NO_REGISTER, mesh_, rhoCp ); diff --git a/src/functionObjects/solvers/scalarTransport/scalarTransport.C b/src/functionObjects/solvers/scalarTransport/scalarTransport.C index ec36978276..f418519024 100644 --- a/src/functionObjects/solvers/scalarTransport/scalarTransport.C +++ b/src/functionObjects/solvers/scalarTransport/scalarTransport.C @@ -96,16 +96,10 @@ Foam::tmp Foam::functionObjects::scalarTransport::D if (constantD_) { - return tmp::New + return volScalarField::New ( - IOobject - ( - Dname, - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), + Dname, + IOobject::NO_REGISTER, mesh_, dimensionedScalar(Dname, phi.dimensions()/dimLength, D_) ); @@ -129,9 +123,10 @@ Foam::tmp Foam::functionObjects::scalarTransport::D if (turb) { - return tmp::New + return volScalarField::New ( Dname, + IOobject::NO_REGISTER, alphaD_ * turb->nu() + alphaDt_ * turb->nut() ); } @@ -147,25 +142,20 @@ Foam::tmp Foam::functionObjects::scalarTransport::D if (turb) { - return tmp::New + return volScalarField::New ( Dname, + IOobject::NO_REGISTER, alphaD_ * turb->mu() + alphaDt_ * turb->mut() ); } } - return tmp::New + return volScalarField::New ( - IOobject - ( - Dname, - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), + Dname, + IOobject::NO_REGISTER, mesh_, dimensionedScalar(phi.dimensions()/dimLength, Zero) ); diff --git a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C index 16314968ad..3db5770d17 100644 --- a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C @@ -664,8 +664,8 @@ Foam::tmp Foam::pairPatchAgglomeration::agglomerateOneLevel { const label nFineFaces = patch.size(); - tmp tcoarseCellMap(new labelField(nFineFaces, -1)); - labelField& coarseCellMap = tcoarseCellMap.ref(); + auto tcoarseCellMap = tmp::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 c0656e0516..541cc4882b 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 tcurPoints(new pointField(fvMesh_.points())); - pointField& curPoints = tcurPoints.ref(); + auto tcurPoints = tmp::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 68d95d1f98..9fd45f1149 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 tcurPoints(new pointField(fvMesh_.points())); + auto tcurPoints = tmp::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 0d6c19e100..f886e65d23 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 tUd + auto tUd = volVectorField::New ( - new volVectorField + "Ud", + IOobject::NO_REGISTER, + fvMesh_, + dimensionedVector(dimLength, Zero), + cellMotionBoundaryTypes ( - IOobject - ( - "Ud", - fvMesh_.time().timeName(), - fvMesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - fvMesh_, - dimensionedVector(dimLength, Zero), - cellMotionBoundaryTypes - ( - 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 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/fvOptions/constraints/general/mapFieldConstraint/MapFieldConstraint.C b/src/fvOptions/constraints/general/mapFieldConstraint/MapFieldConstraint.C index 1d18b8960b..6aeb9d82ed 100644 --- a/src/fvOptions/constraints/general/mapFieldConstraint/MapFieldConstraint.C +++ b/src/fvOptions/constraints/general/mapFieldConstraint/MapFieldConstraint.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,30 +34,23 @@ License namespace Foam { -namespace fv -{ + static inline tmp createField ( const fvMesh& mesh, const scalar val ) { - return tmp::New + return volScalarField::New ( - IOobject - ( - polyMesh::defaultRegion, - mesh.time().timeName(), - mesh, - IOobjectOption::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + polyMesh::defaultRegion, + IOobject::NO_REGISTER, mesh, - dimensionedScalar(dimless, val) + val, + dimless ); } -} // End namespace fv + } // End namespace Foam @@ -157,14 +150,14 @@ VolFieldType& Foam::fv::MapFieldConstraint::getOrReadField ( fieldName, thisMesh.time().timeName(), - thisMesh, + thisMesh.thisDb(), IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::REGISTER ), thisMesh ); - thisMesh.objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/fvOptions/corrections/limitTurbulenceViscosity/limitTurbulenceViscosity.C b/src/fvOptions/corrections/limitTurbulenceViscosity/limitTurbulenceViscosity.C index 6c039accce..836a23bf87 100644 --- a/src/fvOptions/corrections/limitTurbulenceViscosity/limitTurbulenceViscosity.C +++ b/src/fvOptions/corrections/limitTurbulenceViscosity/limitTurbulenceViscosity.C @@ -87,19 +87,13 @@ Foam::tmp Foam::fv::limitTurbulenceViscosity::nu() const const auto* dictPtr = mesh_.cfindObject("transportProperties"); if (dictPtr) { - return - tmp::New - ( - IOobject - ( - "nu", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ - ), - mesh_, - dimensionedScalar("nu", dimViscosity, *dictPtr) - ); + return volScalarField::New + ( + "nu", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar("nu", dimViscosity, *dictPtr) + ); } FatalErrorInFunction diff --git a/src/fvOptions/sources/derived/acousticDampingSource/acousticDampingSource.C b/src/fvOptions/sources/derived/acousticDampingSource/acousticDampingSource.C index 898926ef18..3be2df145e 100644 --- a/src/fvOptions/sources/derived/acousticDampingSource/acousticDampingSource.C +++ b/src/fvOptions/sources/derived/acousticDampingSource/acousticDampingSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -87,23 +87,13 @@ Foam::fv::acousticDampingSource::acousticDampingSource fv::cellSetOption(name, modelType, dict, mesh), blendFactor_ ( - volScalarField - ( - IOobject - ( - name_ + ":blend", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - scalar(1), - dimless, - fvPatchFieldBase::zeroGradientType() - ) + mesh_.newIOobject(IOobject::scopedName(name_, "blend")), + mesh_, + scalar(1), + dimless, + fvPatchFieldBase::zeroGradientType() ), - frequency_("frequency", dimless/dimTime, 0), + frequency_("frequency", dimless/dimTime, Zero), x0_(Zero), r1_(0), r2_(0), @@ -122,8 +112,15 @@ void Foam::fv::acousticDampingSource::addSup const label fieldI ) { + auto tcoeff = volScalarField::New + ( + IOobject::scopedName(name_, "coeff"), + IOobject::NO_REGISTER, + w_*frequency_*blendFactor_ + ); + const auto& coeff = tcoeff(); + const volVectorField& U = eqn.psi(); - const volScalarField coeff(name_ + ":coeff", w_*frequency_*blendFactor_); const auto& URef = mesh().lookupObject(URefName_); fvMatrix dampingEqn @@ -141,8 +138,15 @@ void Foam::fv::acousticDampingSource::addSup const label fieldI ) { + auto tcoeff = volScalarField::New + ( + IOobject::scopedName(name_, "coeff"), + IOobject::NO_REGISTER, + w_*frequency_*blendFactor_ + ); + const auto& coeff = tcoeff(); + const volVectorField& U = eqn.psi(); - const volScalarField coeff(name_ + ":coeff", w_*frequency_*blendFactor_); const auto& URef = mesh().lookupObject(URefName_); fvMatrix dampingEqn @@ -161,8 +165,15 @@ void Foam::fv::acousticDampingSource::addSup const label fieldI ) { + auto tcoeff = volScalarField::New + ( + IOobject::scopedName(name_, "coeff"), + IOobject::NO_REGISTER, + w_*frequency_*blendFactor_ + ); + const auto& coeff = tcoeff(); + const volVectorField& U = eqn.psi(); - const volScalarField coeff(name_ + ":coeff", w_*frequency_*blendFactor_); const auto& URef = mesh().lookupObject(URefName_); fvMatrix dampingEqn diff --git a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C index d436078a18..c2d6ea05c1 100644 --- a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C +++ b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C @@ -148,7 +148,8 @@ void Foam::fv::directionalPressureGradientExplicitSource::writeProps "uniform", mesh_, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::NO_REGISTER ) ); propsDict.add("gradient", gradP); @@ -463,23 +464,18 @@ void Foam::fv::directionalPressureGradientExplicitSource::addSup const label fieldI ) { - DimensionedField Su + auto tSu = DimensionedField::New ( - IOobject - ( - name_ + fieldNames_[fieldI] + "Sup", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + name_ + fieldNames_[fieldI] + "Sup", + IOobject::NO_REGISTER, mesh_, dimensionedVector(eqn.dimensions()/dimVolume, Zero) ); + auto& Su = tSu.ref(); UIndirectList(Su, cells_) = gradP0_ + dGradP_ + gradPporous_; - eqn += Su; + eqn += tSu; } @@ -506,14 +502,7 @@ void Foam::fv::directionalPressureGradientExplicitSource::constrain ( new volScalarField ( - IOobject - ( - name_ + ":invA", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + mesh_.newIOobject(IOobject::scopedName(name_, "invA")), 1.0/eqn.A() ) ); diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C index f6f41c11a0..6053fb1ca4 100644 --- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,8 +44,6 @@ namespace fv } } -const Foam::word Foam::fv::jouleHeatingSource::sigmaName(typeName + ":sigma"); - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -55,17 +53,10 @@ Foam::fv::jouleHeatingSource::transformSigma const volVectorField& sigmaLocal ) const { - auto tsigma = tmp::New + auto tsigma = volSymmTensorField::New ( - IOobject - ( - sigmaName, - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + IOobject::scopedName(typeName, "sigma"), + IOobject::NO_REGISTER, mesh_, dimensionedSymmTensor(sigmaLocal.dimensions(), Zero), fvPatchFieldBase::zeroGradientType() @@ -115,11 +106,12 @@ Foam::fv::jouleHeatingSource::jouleHeatingSource ( IOobject ( - typeName + ":V", + IOobject::scopedName(typeName, "V"), mesh.time().timeName(), mesh, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh ), @@ -182,6 +174,10 @@ void Foam::fv::jouleHeatingSource::addSup } // Add the Joule heating contribution + const word sigmaName + ( + IOobject::scopedName(typeName, "sigma") + ); const volVectorField gradV(fvc::grad(V_)); if (anisotropicElectricalConductivity_) diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H index d748dcdab8..76cd3ea4c1 100644 --- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -179,9 +179,6 @@ class jouleHeatingSource { // Private Data - //- Name of electrical conductivity field - static const word sigmaName; - //- Name of temperature field word TName_; diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C index 95cb6a05b9..2b7fbb0ed1 100644 --- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,52 +34,50 @@ void Foam::fv::jouleHeatingSource::initialiseSigma autoPtr>& sigmaVsTPtr ) { - typedef GeometricField VolFieldType; + typedef GeometricField FieldType; + + IOobject io + ( + IOobject::scopedName(typeName, "sigma"), + mesh_.time().timeName(), + mesh_.thisDb(), + IOobject::NO_READ, + IOobject::AUTO_WRITE, + IOobject::REGISTER + ); + + autoPtr tsigma; if (dict.found("sigma")) { // Sigma to be defined using a Function1 type sigmaVsTPtr = Function1::New("sigma", dict, &mesh_); - auto tsigma = tmp::New + tsigma.reset ( - IOobject + new FieldType ( - typeName + ":sigma", - mesh_.time().timeName(), + io, mesh_, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh_, - dimensioned(sqr(dimCurrent)/dimPower/dimLength, Zero) + Foam::zero{}, // value + sqr(dimCurrent)/dimPower/dimLength + ) ); - mesh_.objectRegistry::store(tsigma.ptr()); - Info<< " Conductivity 'sigma' read from dictionary as f(T)" << nl << endl; } else { // Sigma to be defined by user input - auto tsigma = tmp::New - ( - IOobject - ( - typeName + ":sigma", - mesh_.time().timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ); + io.readOpt(IOobject::MUST_READ); - mesh_.objectRegistry::store(tsigma.ptr()); + tsigma.reset(new FieldType(io, mesh_)); Info<< " Conductivity 'sigma' read from file" << nl << endl; } + + regIOobject::store(tsigma); } @@ -90,9 +88,12 @@ Foam::fv::jouleHeatingSource::updateSigma const autoPtr>& sigmaVsTPtr ) const { - typedef GeometricField VolFieldType; + typedef GeometricField FieldType; - auto& sigma = mesh_.lookupObjectRef(typeName + ":sigma"); + auto& sigma = mesh_.lookupObjectRef + ( + IOobject::scopedName(typeName, "sigma") + ); if (!sigmaVsTPtr) { @@ -110,7 +111,7 @@ Foam::fv::jouleHeatingSource::updateSigma // Boundary field - typename VolFieldType::Boundary& bf = sigma.boundaryFieldRef(); + auto& bf = sigma.boundaryFieldRef(); forAll(bf, patchi) { fvPatchField& pf = bf[patchi]; diff --git a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C index 909d57f395..6d05236326 100644 --- a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C +++ b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -63,7 +63,8 @@ void Foam::fv::meanVelocityForce::writeProps "uniform", mesh_, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::NO_REGISTER ) ); propsDict.add("gradient", gradP); @@ -192,25 +193,20 @@ void Foam::fv::meanVelocityForce::addSup const label fieldi ) { - volVectorField::Internal Su + auto tSu = volVectorField::Internal::New ( - IOobject - ( - name_ + fieldNames_[fieldi] + "Sup", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + name_ + fieldNames_[fieldi] + "Sup", + IOobject::NO_REGISTER, mesh_, dimensionedVector(eqn.dimensions()/dimVolume, Zero) ); + auto& Su = tSu.ref(); scalar gradP = gradP0_ + dGradP_; UIndirectList(Su, cells_) = flowDir_*gradP; - eqn += Su; + eqn += tSu; } @@ -237,14 +233,7 @@ void Foam::fv::meanVelocityForce::constrain ( new volScalarField ( - IOobject - ( - name_ + ":rA", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + mesh_.newIOobject(IOobject::scopedName(name_, "rA")), 1.0/eqn.A() ) ); diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C index a638b55ae7..f4f9085591 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2022 OpenCFD Ltd. + Copyright (C) 2018-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -238,23 +238,19 @@ void Foam::fv::rotorDiskSource::setFaceArea(vector& axis, const bool correct) if (debug) { - volScalarField area + auto tarea = volScalarField::New ( - IOobject - ( - name_ + ":area", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(name_, "area"), + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimArea, Zero) ); - UIndirectList(area.primitiveField(), cells_) = area_; + auto& area = tarea.ref(); - Info<< type() << ": " << name_ << " writing field " << area.name() - << endl; + UIndirectList(area.primitiveFieldRef(), cells_) = area_; + + Info<< type() << ": " << name_ + << " writing field " << area.name() << endl; area.write(); } @@ -480,17 +476,14 @@ void Foam::fv::rotorDiskSource::addSup const label fieldi ) { - volVectorField force + auto tforce = volVectorField::New ( - IOobject - ( - name_ + ":rotorForce", - mesh_.time().timeName(), - mesh_ - ), + IOobject::scopedName(name_, "rotorForce"), + IOobject::NO_REGISTER, mesh_, dimensionedVector(eqn.dimensions()/dimVolume, Zero) ); + auto& force = tforce.ref(); // Read the reference density for incompressible flow coeffs_.readEntry("rhoRef", rhoRef_); @@ -516,17 +509,14 @@ void Foam::fv::rotorDiskSource::addSup const label fieldi ) { - volVectorField force + auto tforce = volVectorField::New ( - IOobject - ( - name_ + ":rotorForce", - mesh_.time().timeName(), - mesh_ - ), + IOobject::scopedName(name_, "rotorForce"), + IOobject::NO_REGISTER, mesh_, dimensionedVector(eqn.dimensions()/dimVolume, Zero) ); + auto& force = tforce.ref(); const vectorField Uin(inflowVelocity(eqn.psi())); trim_->correct(rho, Uin, force); diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C index 5a050a7053..db93871990 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSourceTemplates.C @@ -178,37 +178,28 @@ void Foam::fv::rotorDiskSource::writeField const bool writeNow ) const { - typedef GeometricField FieldType; - if (mesh_.time().writeTime() || writeNow) { - auto tfield = tmp::New + if (cells_.size() != values.size()) + { + FatalErrorInFunction + << "Size mismatch. Number of cells " + << cells_.size() << " != number of values " + << values.size() << nl + << abort(FatalError); + } + + auto tfield = GeometricField::New ( - IOobject - ( - name, - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + name, + IOobject::NO_REGISTER, mesh_, dimensioned(dimless, Zero) ); auto& field = tfield.ref().primitiveFieldRef(); - if (cells_.size() != values.size()) - { - FatalErrorInFunction - << abort(FatalError); - } - - forAll(cells_, i) - { - const label celli = cells_[i]; - field[celli] = values[i]; - } + UIndirectList(field, cells_) = values; tfield().write(); } diff --git a/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C b/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C index 6f891187c9..f7d853c817 100644 --- a/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C +++ b/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2017 OpenFOAM Foundation - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -78,16 +78,9 @@ Foam::fv::solidificationMeltingSource::Cp() const { const scalar CpRef = coeffs_.get("CpRef"); - return tmp::New + return volScalarField::New ( - IOobject - ( - name_ + ":Cp", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(name_, "Cp"), mesh_, dimensionedScalar ( @@ -184,11 +177,12 @@ Foam::fv::solidificationMeltingSource::solidificationMeltingSource ( IOobject ( - name_ + ":alpha1", + IOobject::scopedName(name_, "alpha1"), mesh.time().timeName(), mesh, IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh, dimensionedScalar(dimless, Zero), diff --git a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C index ac2d5b980b..4d8491fed2 100644 --- a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C +++ b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C @@ -47,16 +47,10 @@ namespace fv Foam::tmp Foam::fv::viscousDissipation::rho() const { - auto trho = tmp::New + auto trho = volScalarField::New ( - IOobject - ( - "trho", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "trho", + IOobject::NO_REGISTER, mesh_, rho_ ); @@ -177,16 +171,10 @@ void Foam::fv::viscousDissipation::addSup const word gradUName("grad(" + UName_ + ')'); - auto tgradU = tmp::New + auto tgradU = GradFieldType::New ( - IOobject - ( - "gradU", - mesh_.time().timeName(), - mesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), + "gradU", + IOobject::NO_REGISTER, mesh_, dimensionedTensor(inv(dimTime), Zero) ); diff --git a/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C b/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C index c8830ae3d7..6e3585e68a 100644 --- a/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C +++ b/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C @@ -336,6 +336,7 @@ void Foam::fv::SemiImplicitSource::addSup tsu = DimensionedField::New ( name_ + fieldName + "Su", + IOobject::NO_REGISTER, mesh_, dimensioned(SuDims, Zero) ); @@ -375,6 +376,7 @@ void Foam::fv::SemiImplicitSource::addSup tsu = DimensionedField::New ( name_ + fieldName + "Su", + IOobject::NO_REGISTER, mesh_, dimensioned(SuDims, Zero) ); @@ -462,6 +464,7 @@ void Foam::fv::SemiImplicitSource::addSup tsp = DimensionedField::New ( name_ + fieldName + "Sp", + IOobject::NO_REGISTER, mesh_, dimensioned(SpDims, Zero) ); @@ -501,6 +504,7 @@ void Foam::fv::SemiImplicitSource::addSup tsp = DimensionedField::New ( name_ + fieldName + "Sp", + IOobject::NO_REGISTER, mesh_, dimensioned(SpDims, Zero) ); diff --git a/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C b/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C index 4e00e9b225..65da636ee8 100644 --- a/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C +++ b/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -93,16 +93,16 @@ void Foam::fv::interRegionExplicitPorositySource::initialise() << abort(FatalError); } - porosityPtr_.reset - ( + porosityPtr_.reset(nullptr); + + porosityPtr_ = porosityModel::New ( name_, nbrMesh, coeffs_, zoneName - ).ptr() - ), + ); firstIter_ = false; } @@ -146,19 +146,14 @@ void Foam::fv::interRegionExplicitPorositySource::addSup const volVectorField& U = eqn.psi(); - volVectorField UNbr + auto tUNbr = volVectorField::New ( - IOobject - ( - name_ + ":UNbr", - nbrMesh.time().timeName(), - nbrMesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(name_, "UNbr"), + IOobject::NO_REGISTER, nbrMesh, dimensionedVector(U.dimensions(), Zero) ); + auto& UNbr = tUNbr.ref(); // Map local velocity onto neighbour region meshInterp().mapSrcToTgt @@ -177,7 +172,7 @@ void Foam::fv::interRegionExplicitPorositySource::addSup scalarField& Udiag = porosityEqn.diag(); vectorField& Usource = porosityEqn.source(); - Udiag.setSize(eqn.diag().size(), 0.0); + Udiag.setSize(eqn.diag().size(), Zero); Usource.setSize(eqn.source().size(), Zero); meshInterp().mapTgtToSrc(nbrEqn.diag(), plusEqOp(), Udiag); @@ -200,19 +195,14 @@ void Foam::fv::interRegionExplicitPorositySource::addSup const volVectorField& U = eqn.psi(); - volVectorField UNbr + auto tUNbr = volVectorField::New ( - IOobject - ( - name_ + ":UNbr", - nbrMesh.time().timeName(), - nbrMesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(name_, "UNbr"), + IOobject::NO_REGISTER, nbrMesh, dimensionedVector(U.dimensions(), Zero) ); + auto& UNbr = tUNbr.ref(); // Map local velocity onto neighbour region meshInterp().mapSrcToTgt @@ -224,33 +214,23 @@ void Foam::fv::interRegionExplicitPorositySource::addSup fvMatrix nbrEqn(UNbr, eqn.dimensions()); - volScalarField rhoNbr + auto trhoNbr = volScalarField::New ( - IOobject - ( - "rho:UNbr", - nbrMesh.time().timeName(), - nbrMesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName("rho", "UNbr"), + IOobject::NO_REGISTER, nbrMesh, dimensionedScalar(dimDensity, Zero) ); + auto& rhoNbr = trhoNbr.ref(); - volScalarField muNbr + auto tmuNbr = volScalarField::New ( - IOobject - ( - "mu:UNbr", - nbrMesh.time().timeName(), - nbrMesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName("mu", "UNbr"), + IOobject::NO_REGISTER, nbrMesh, dimensionedScalar(dimViscosity, Zero) ); + auto& muNbr = tmuNbr.ref(); const auto& mu = mesh_.lookupObject(muName_); @@ -277,7 +257,7 @@ void Foam::fv::interRegionExplicitPorositySource::addSup scalarField& Udiag = porosityEqn.diag(); vectorField& Usource = porosityEqn.source(); - Udiag.setSize(eqn.diag().size(), 0.0); + Udiag.setSize(eqn.diag().size(), Zero); Usource.setSize(eqn.source().size(), Zero); meshInterp().mapTgtToSrc(nbrEqn.diag(), plusEqOp(), Udiag); diff --git a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C index a02de47f9c..f64021f05d 100644 --- a/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C +++ b/src/lagrangian/DSMC/clouds/Templates/DSMCCloud/DSMCCloud.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -473,8 +473,9 @@ Foam::DSMCCloud::DSMCCloud cloudName + "Properties", mesh_.time().constant(), mesh_, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE + IOobject::READ_MODIFIED, + IOobject::NO_WRITE, + IOobject::REGISTER ) ), typeIdList_(particleProperties_.lookup("typeIdList")), @@ -488,7 +489,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -496,7 +498,7 @@ Foam::DSMCCloud::DSMCCloud ( IOobject ( - this->name() + ":collisionSelectionRemainder", + IOobject::scopedName(this->name(), "collisionSelectionRemainder"), mesh_.time().timeName(), mesh_ ), @@ -511,7 +513,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -523,7 +526,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -535,7 +539,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -547,7 +552,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -559,7 +565,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -571,7 +578,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -583,7 +591,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -595,7 +604,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -607,7 +617,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -621,7 +632,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -633,7 +645,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_ ), @@ -698,8 +711,9 @@ Foam::DSMCCloud::DSMCCloud cloudName + "Properties", mesh_.time().constant(), mesh_, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE + IOobject::READ_MODIFIED, + IOobject::NO_WRITE, + IOobject::REGISTER ) ), typeIdList_(particleProperties_.lookup("typeIdList")), @@ -713,7 +727,8 @@ Foam::DSMCCloud::DSMCCloud mesh_.time().timeName(), mesh_, IOobject::NO_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimensionSet(0, 3, -1, 0, 0), Zero), @@ -723,7 +738,7 @@ Foam::DSMCCloud::DSMCCloud ( IOobject ( - this->name() + ":collisionSelectionRemainder", + IOobject::scopedName(this->name(), "collisionSelectionRemainder"), mesh_.time().timeName(), mesh_ ), diff --git a/src/lagrangian/coalCombustion/coalCloudList/coalCloudListI.H b/src/lagrangian/coalCombustion/coalCloudList/coalCloudListI.H index c4385d7dc2..21e4a2ad42 100644 --- a/src/lagrangian/coalCombustion/coalCloudList/coalCloudListI.H +++ b/src/lagrangian/coalCombustion/coalCloudList/coalCloudListI.H @@ -32,24 +32,14 @@ License Foam::tmp> Foam::coalCloudList::UTrans() const { - tmp tfld + auto tfld = volVectorField::Internal::New ( - new volVectorField::Internal - ( - IOobject - ( - "UTransEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedVector(dimMass*dimVelocity, Zero) - ) + "UTransEff", + IOobject::NO_REGISTER, + mesh_, + dimensionedVector(dimMass*dimVelocity, Zero) ); - - volVectorField::Internal& fld = tfld.ref(); + auto& fld = tfld.ref(); forAll(*this, i) { @@ -65,8 +55,8 @@ Foam::tmp Foam::coalCloudList::SU volVectorField& U ) const { - tmp tfvm(new fvVectorMatrix(U, dimForce)); - fvVectorMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(U, dimForce); + auto& fvm = tfvm.ref(); forAll(*this, i) { @@ -80,24 +70,14 @@ Foam::tmp Foam::coalCloudList::SU Foam::tmp> Foam::coalCloudList::hsTrans() const { - tmp tfld + auto tfld = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - "hsTransEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar(dimEnergy, Zero) - ) + "hsTransEff", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimEnergy, Zero) ); - - volScalarField::Internal& fld = tfld.ref(); + auto& fld = tfld.ref(); forAll(*this, i) { @@ -113,8 +93,8 @@ Foam::tmp Foam::coalCloudList::Sh volScalarField& hs ) const { - tmp tfvm(new fvScalarMatrix(hs, dimEnergy/dimTime)); - fvScalarMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(hs, dimEnergy/dimTime); + auto& fvm = tfvm.ref(); forAll(*this, i) { @@ -131,8 +111,8 @@ Foam::tmp Foam::coalCloudList::SYi volScalarField& Yi ) const { - tmp tfvm(new fvScalarMatrix(Yi, dimMass/dimTime)); - fvScalarMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(Yi, dimMass/dimTime); + auto& fvm = tfvm.ref(); forAll(*this, i) { @@ -146,24 +126,14 @@ Foam::tmp Foam::coalCloudList::SYi Foam::tmp> Foam::coalCloudList::rhoTrans() const { - tmp tfld + auto tfld = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - "rhoTransEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar(dimMass, Zero) - ) + "rhoTransEff", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimMass, Zero) ); - - volScalarField::Internal& fld = tfld.ref(); + auto& fld = tfld.ref(); forAll(*this, i) { @@ -177,29 +147,17 @@ Foam::coalCloudList::rhoTrans() const } - - Foam::tmp> Foam::coalCloudList::Srho() const { - tmp tfld + auto tfld = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - "rhoTransEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar(dimDensity/dimTime, Zero) - ) + "rhoTransEff", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimDensity/dimTime, Zero) ); - - volScalarField::Internal& fld = tfld.ref(); + auto& fld = tfld.ref(); forAll(*this, i) { @@ -216,24 +174,14 @@ Foam::coalCloudList::Srho const label i ) const { - tmp tfld + auto tfld = volScalarField::Internal::New ( - new volScalarField::Internal - ( - IOobject - ( - "rhoTransEff", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar(dimDensity/dimTime, Zero) - ) + "rhoTransEff", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimDensity/dimTime, Zero) ); - - volScalarField::Internal& fld = tfld.ref(); + auto& fld = tfld.ref(); forAll(*this, j) { @@ -249,8 +197,8 @@ Foam::tmp Foam::coalCloudList::Srho volScalarField& rho ) const { - tmp tfvm(new fvScalarMatrix(rho, dimMass/dimTime)); - fvScalarMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(rho, dimMass/dimTime); + auto& fvm = tfvm.ref(); forAll(*this, i) { diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index f6b57014b4..776d3af811 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -360,8 +360,9 @@ Foam::KinematicCloud::KinematicCloud cloudName + "Properties", mesh_.time().constant(), mesh_, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE + IOobject::READ_MODIFIED, + IOobject::NO_WRITE, + IOobject::REGISTER ) ), outputProperties_ @@ -373,7 +374,8 @@ Foam::KinematicCloud::KinematicCloud "uniform"/cloud::prefix/cloudName, mesh_, IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::REGISTER ) ), solution_(mesh_, particleProperties_.subDict("solution")), @@ -438,7 +440,8 @@ Foam::KinematicCloud::KinematicCloud this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimMass, Zero) @@ -454,7 +457,8 @@ Foam::KinematicCloud::KinematicCloud this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedVector(dimMass*dimVelocity, Zero) @@ -470,7 +474,8 @@ Foam::KinematicCloud::KinematicCloud this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh_, dimensionedScalar(dimMass, Zero) @@ -571,7 +576,7 @@ Foam::KinematicCloud::KinematicCloud ( IOobject ( - name + ":UCoeff", + IOobject::scopedName(this->name(), "UCoeff"), this->db().time().timeName(), this->db(), IOobject::NO_READ, diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H index 3ade1a4de5..5651acab61 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H @@ -515,24 +515,15 @@ Foam::KinematicCloud::Srhok() const return rhokTrans()/this->db().time().deltaT()/this->mesh().V(); } - return - tmp::New + return tmp::New + ( + this->newIOobject(IOobject::scopedName(this->name(), "rhokTrans")), + this->mesh(), + dimensionedScalar ( - IOobject - ( - IOobject::scopedName(this->name(), "rhokTrans"), - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar - ( - rhokTrans().dimensions()/dimTime/dimVolume, Zero - ) - ); + rhokTrans().dimensions()/dimTime/dimVolume, Zero + ) + ); } @@ -571,8 +562,8 @@ const } else { - tmp tfvm(new fvVectorMatrix(U, dim)); - fvVectorMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(U, dim); + auto& fvm = tfvm.ref(); fvm.source() = -UTrans()/(this->db().time().deltaT()); @@ -588,26 +579,15 @@ template inline const Foam::tmp Foam::KinematicCloud::vDotSweep() const { - tmp tvDotSweep + auto tvDotSweep = tmp::New ( - new volScalarField - ( - IOobject - ( - IOobject::scopedName(this->name(), "vDotSweep"), - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless/dimTime, Zero), - fvPatchFieldBase::extrapolatedCalculatedType() - ) + this->newIOobject(IOobject::scopedName(this->name(), "vDotSweep")), + mesh_, + dimensionedScalar(dimless/dimTime, Zero), + fvPatchFieldBase::extrapolatedCalculatedType() ); + auto& vDotSweep = tvDotSweep.ref(); - volScalarField& vDotSweep = tvDotSweep.ref(); for (const parcelType& p : *this) { const label celli = p.cell(); @@ -626,26 +606,15 @@ template inline const Foam::tmp Foam::KinematicCloud::theta() const { - tmp ttheta + auto ttheta = tmp::New ( - new volScalarField - ( - IOobject - ( - IOobject::scopedName(this->name(), "theta"), - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless, Zero), - fvPatchFieldBase::extrapolatedCalculatedType() - ) + this->newIOobject(IOobject::scopedName(this->name(), "theta")), + mesh_, + dimensionedScalar(dimless, Zero), + fvPatchFieldBase::extrapolatedCalculatedType() ); + auto& theta = ttheta.ref(); - volScalarField& theta = ttheta.ref(); for (const parcelType& p : *this) { const label celli = p.cell(); @@ -664,22 +633,11 @@ template inline const Foam::tmp Foam::KinematicCloud::alpha() const { - tmp talpha + auto talpha = tmp::New ( - new volScalarField - ( - IOobject - ( - IOobject::scopedName(this->name(), "alpha"), - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless, Zero) - ) + this->newIOobject(IOobject::scopedName(this->name(), "alpha")), + mesh_, + dimensionedScalar(dimless, Zero) ); scalarField& alpha = talpha.ref().primitiveFieldRef(); @@ -700,22 +658,11 @@ template inline const Foam::tmp Foam::KinematicCloud::rhoEff() const { - tmp trhoEff + auto trhoEff = tmp::New ( - new volScalarField - ( - IOobject - ( - IOobject::scopedName(this->name(), "rhoEff"), - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimDensity, Zero) - ) + this->newIOobject(IOobject::scopedName(this->name(), "rhoEff")), + mesh_, + dimensionedScalar(dimDensity, Zero) ); scalarField& rhoEff = trhoEff.ref().primitiveFieldRef(); diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C index 1062223379..8c85ff362b 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C @@ -120,7 +120,15 @@ Foam::ReactingCloud::ReactingCloud // Set storage for mass source fields and initialise to zero forAll(rhoTrans_, i) { - const word& specieName = thermo.carrier().species()[i]; + const word fieldName + ( + IOobject::scopedName + ( + this->name(), + "rhoTrans_" + thermo.carrier().species()[i] + ) + ); + rhoTrans_.set ( i, @@ -128,11 +136,12 @@ Foam::ReactingCloud::ReactingCloud ( IOobject ( - this->name() + ":rhoTrans_" + specieName, + fieldName, this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimMass, Zero) @@ -164,7 +173,15 @@ Foam::ReactingCloud::ReactingCloud { forAll(c.rhoTrans_, i) { - const word& specieName = this->thermo().carrier().species()[i]; + const word fieldName + ( + IOobject::scopedName + ( + this->name(), + "rhoTrans_" + this->thermo().carrier().species()[i] + ) + ); + rhoTrans_.set ( i, @@ -172,7 +189,7 @@ Foam::ReactingCloud::ReactingCloud ( IOobject ( - this->name() + ":rhoTrans_" + specieName, + fieldName, this->db().time().timeName(), this->db(), IOobject::NO_READ, diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudI.H b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudI.H index 8f357987e5..91d816ee5f 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudI.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -144,25 +145,14 @@ inline Foam::tmp Foam::ReactingCloud::SYi { if (this->solution().semiImplicit("Yi")) { - tmp trhoTrans + auto trhoTrans = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->name() + ":rhoTrans", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimMass/dimTime/dimVolume, Zero) - ) + IOobject::scopedName(this->name(), "rhoTrans"), + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimMass/dimTime/dimVolume, Zero) ); - - volScalarField& sourceField = trhoTrans.ref(); + auto& sourceField = trhoTrans.ref(); sourceField.primitiveFieldRef() = rhoTrans_[i]/(this->db().time().deltaTValue()*this->mesh().V()); @@ -175,8 +165,8 @@ inline Foam::tmp Foam::ReactingCloud::SYi } else { - tmp tfvm(new fvScalarMatrix(Yi, dimMass/dimTime)); - fvScalarMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(Yi, dimMass/dimTime); + auto& fvm = tfvm.ref(); fvm.source() = -rhoTrans_[i]/this->db().time().deltaTValue(); @@ -192,30 +182,20 @@ template inline Foam::tmp> Foam::ReactingCloud::Srho(const label i) const { - tmp tRhoi + auto tRhoi = volScalarField::Internal::New ( - new volScalarField::Internal + IOobject::scopedName(this->name(), "rhoTrans"), + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar ( - IOobject - ( - this->name() + ":rhoTrans", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar - ( - rhoTrans_[0].dimensions()/dimTime/dimVolume, Zero - ) + rhoTrans_[0].dimensions()/dimTime/dimVolume, Zero ) ); + scalarField& rhoi = tRhoi.ref(); if (this->solution().coupled()) { - scalarField& rhoi = tRhoi.ref(); rhoi = rhoTrans_[i]/(this->db().time().deltaTValue()*this->mesh().V()); } @@ -227,30 +207,20 @@ template inline Foam::tmp> Foam::ReactingCloud::Srho() const { - tmp trhoTrans + auto trhoTrans = volScalarField::Internal::New ( - new volScalarField::Internal + IOobject::scopedName(this->name(), "rhoTrans"), + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar ( - IOobject - ( - this->name() + ":rhoTrans", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar - ( - rhoTrans_[0].dimensions()/dimTime/dimVolume, Zero - ) + rhoTrans_[0].dimensions()/dimTime/dimVolume, Zero ) ); + scalarField& sourceField = trhoTrans.ref(); if (this->solution().coupled()) { - scalarField& sourceField = trhoTrans.ref(); forAll(rhoTrans_, i) { sourceField += rhoTrans_[i]; @@ -269,29 +239,17 @@ Foam::ReactingCloud::Srho(volScalarField& rho) const { if (this->solution().coupled()) { - tmp trhoTrans + auto trhoTrans = volScalarField::New ( - new volScalarField - ( - IOobject - ( - this->name() + ":rhoTrans", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimMass/dimTime/dimVolume, Zero) - ) + IOobject::scopedName(this->name(), "rhoTrans"), + IOobject::NO_REGISTER, + this->mesh(), + dimensionedScalar(dimMass/dimTime/dimVolume, Zero) ); - scalarField& sourceField = trhoTrans.ref(); if (this->solution().semiImplicit("rho")) { - forAll(rhoTrans_, i) { sourceField += rhoTrans_[i]; @@ -302,8 +260,8 @@ Foam::ReactingCloud::Srho(volScalarField& rho) const } else { - tmp tfvm(new fvScalarMatrix(rho, dimMass/dimTime)); - fvScalarMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(rho, dimMass/dimTime); + auto& fvm = tfvm.ref(); forAll(rhoTrans_, i) { diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C index 9f232d96c2..1d7e1f1ea0 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -64,11 +64,12 @@ void Foam::ThermoCloud::setModels() ( IOobject ( - this->name() + ":radAreaP", + IOobject::scopedName(this->name(), "radAreaP"), this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimArea, Zero) @@ -81,11 +82,12 @@ void Foam::ThermoCloud::setModels() ( IOobject ( - this->name() + ":radT4", + IOobject::scopedName(this->name(), "radT4"), this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(pow4(dimTemperature), Zero) @@ -98,11 +100,12 @@ void Foam::ThermoCloud::setModels() ( IOobject ( - this->name() + ":radAreaPT4", + IOobject::scopedName(this->name(), "radAreaPT4"), this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(sqr(dimLength)*pow4(dimTemperature), Zero) @@ -164,11 +167,12 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":hsTrans", + IOobject::scopedName(this->name(), "hsTrans"), this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimEnergy, Zero) @@ -180,11 +184,12 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":hsCoeff", + IOobject::scopedName(this->name(), "hsCoeff"), this->db().time().timeName(), this->db(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh(), dimensionedScalar(dimEnergy/dimTemperature, Zero) @@ -235,7 +240,7 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":hsTrans", + IOobject::scopedName(this->name(), "hsTrans"), this->db().time().timeName(), this->db(), IOobject::NO_READ, @@ -251,7 +256,7 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":hsCoeff", + IOobject::scopedName(this->name(), "hsCoeff"), this->db().time().timeName(), this->db(), IOobject::NO_READ, @@ -270,7 +275,7 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":radAreaP", + IOobject::scopedName(this->name(), "radAreaP"), this->db().time().timeName(), this->db(), IOobject::NO_READ, @@ -287,7 +292,7 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":radT4", + IOobject::scopedName(this->name(), "radT4"), this->db().time().timeName(), this->db(), IOobject::NO_READ, @@ -304,7 +309,7 @@ Foam::ThermoCloud::ThermoCloud ( IOobject ( - this->name() + ":radAreaPT4", + IOobject::scopedName(this->name(), "radAreaPT4"), this->db().time().timeName(), this->db(), IOobject::NO_READ, diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H index 9899a5f0c5..55b8d00234 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019-2022 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -260,8 +260,8 @@ Foam::ThermoCloud::Sh(volScalarField& hs) const } else { - tmp tfvm(new fvScalarMatrix(hs, dimEnergy/dimTime)); - fvScalarMatrix& fvm = tfvm.ref(); + auto tfvm = tmp::New(hs, dimEnergy/dimTime); + auto& fvm = tfvm.ref(); fvm.source() = -hsTrans()/(this->db().time().deltaT()); @@ -276,22 +276,14 @@ Foam::ThermoCloud::Sh(volScalarField& hs) const template inline Foam::tmp Foam::ThermoCloud::Ep() const { - tmp tEp + auto tEp = tmp::New ( - new volScalarField + this->newIOobject ( - IOobject - ( - this->name() + ":radiation:Ep", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) - ) + IOobject::scopedName(this->name(), "radiation", "Ep") + ), + this->mesh(), + dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); if (radiation_) @@ -312,22 +304,14 @@ inline Foam::tmp Foam::ThermoCloud::Ep() const template inline Foam::tmp Foam::ThermoCloud::ap() const { - tmp tap + auto tap = tmp::New ( - new volScalarField + this->newIOobject ( - IOobject - ( - this->name() + ":radiation:ap", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimless/dimLength, Zero) - ) + IOobject::scopedName(this->name(), "radiation", "ap") + ), + this->mesh(), + dimensionedScalar(dimless/dimLength, Zero) ); if (radiation_) @@ -349,22 +333,14 @@ template inline Foam::tmp Foam::ThermoCloud::sigmap() const { - tmp tsigmap + auto tsigmap = tmp::New ( - new volScalarField + this->newIOobject ( - IOobject - ( - this->name() + ":radiation:sigmap", - this->db().time().timeName(), - this->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - this->mesh(), - dimensionedScalar(dimless/dimLength, Zero) - ) + IOobject::scopedName(this->name(), "radiation", "sigmap") + ), + this->mesh(), + dimensionedScalar(dimless/dimLength, Zero) ); if (radiation_) diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelTrackingDataI.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelTrackingDataI.H index 6587b5ecb3..fab7a36e2a 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelTrackingDataI.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelTrackingDataI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -73,7 +73,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":volumeAverage", + IOobject::scopedName(cloud.name(), "volumeAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -87,7 +87,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":radiusAverage", + IOobject::scopedName(cloud.name(), "radiusAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -101,7 +101,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":rhoAverage", + IOobject::scopedName(cloud.name(), "rhoAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -115,7 +115,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":uAverage", + IOobject::scopedName(cloud.name(), "uAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -129,7 +129,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":uSqrAverage", + IOobject::scopedName(cloud.name(), "uSqrAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -143,7 +143,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":frequencyAverage", + IOobject::scopedName(cloud.name(), "frequencyAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -157,7 +157,7 @@ inline Foam::KinematicParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":massAverage", + IOobject::scopedName(cloud.name(), "massAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -287,7 +287,7 @@ updateAverages ( IOobject ( - cloud.name() + ":weightAverage", + IOobject::scopedName(cloud.name(), "weightAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -366,4 +366,5 @@ updateAverages frequencyAverage_->average(weightAverage); } + // ************************************************************************* // diff --git a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelTrackingDataI.H b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelTrackingDataI.H index 3b96e305fa..e9721f1a50 100644 --- a/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelTrackingDataI.H +++ b/src/lagrangian/intermediate/parcels/Templates/MPPICParcel/MPPICParcelTrackingDataI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -45,7 +45,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":volumeAverage", + IOobject::scopedName(cloud.name(), "volumeAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -59,7 +59,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":radiusAverage", + IOobject::scopedName(cloud.name(), "radiusAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -73,7 +73,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":rhoAverage", + IOobject::scopedName(cloud.name(), "rhoAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -87,7 +87,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":uAverage", + IOobject::scopedName(cloud.name(), "uAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -101,7 +101,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":uSqrAverage", + IOobject::scopedName(cloud.name(), "uSqrAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -115,7 +115,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":frequencyAverage", + IOobject::scopedName(cloud.name(), "frequencyAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -129,7 +129,7 @@ inline Foam::MPPICParcel::trackingData::trackingData ( IOobject ( - cloud.name() + ":massAverage", + IOobject::scopedName(cloud.name(), "massAverage"), cloud.db().time().timeName(), cloud.mesh() ), @@ -164,7 +164,7 @@ inline void Foam::MPPICParcel::trackingData::updateAverages ( IOobject ( - cloud.name() + ":weightAverage", + IOobject::scopedName(cloud.name(), "weightAverage"), cloud.db().time().timeName(), cloud.mesh() ), diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchCollisionDensity/PatchCollisionDensity.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchCollisionDensity/PatchCollisionDensity.C index e98f9adc3f..170fd968c2 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchCollisionDensity/PatchCollisionDensity.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchCollisionDensity/PatchCollisionDensity.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2018 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,36 +39,42 @@ void Foam::PatchCollisionDensity::write() { const scalarField z(this->owner().mesh().nCells(), Zero); - volScalarField - ( - IOobject + { + volScalarField ( - this->owner().name() + ":collisionDensity", - this->owner().mesh().time().timeName(), - this->owner().mesh() - ), - this->owner().mesh(), - dimless/dimArea, - z, - collisionDensity_ - ) - .write(); + this->owner().mesh().newIOobject + ( + IOobject::scopedName + ( + this->owner().name(), + "collisionDensity" + ) + ), + this->owner().mesh(), + dimless/dimArea, + z, + collisionDensity_ + ).write(); + } - volScalarField - ( - IOobject + { + volScalarField ( - this->owner().name() + ":collisionDensityRate", - this->owner().mesh().time().timeName(), - this->owner().mesh() - ), - this->owner().mesh(), - dimless/dimArea/dimTime, - z, - (collisionDensity_ - collisionDensity0_) - /(this->owner().mesh().time().value() - time0_) - ) - .write(); + this->owner().mesh().newIOobject + ( + IOobject::scopedName + ( + this->owner().name(), + "collisionDensityRate" + ) + ), + this->owner().mesh(), + dimless/dimArea/dimTime, + z, + (collisionDensity_ - collisionDensity0_) + /(this->owner().mesh().time().value() - time0_) + ).write(); + } collisionDensity0_ == collisionDensity_; time0_ = this->owner().mesh().time().value(); @@ -106,11 +112,11 @@ Foam::PatchCollisionDensity::PatchCollisionDensity IOobject io ( - this->owner().name() + ":collisionDensity", - this->owner().mesh().time().timeName(), - this->owner().mesh(), - IOobject::MUST_READ, - IOobject::NO_WRITE + this->owner().mesh().newIOobject + ( + IOobject::scopedName(this->owner().name(), "collisionDensity"), + IOobject::MUST_READ + ) ); if (io.typeHeaderOk()) diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchInteractionFields/PatchInteractionFields.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchInteractionFields/PatchInteractionFields.C index 83ed949ad7..687a6662bb 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchInteractionFields/PatchInteractionFields.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/PatchInteractionFields/PatchInteractionFields.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,7 +50,7 @@ void Foam::PatchInteractionFields::clearOrReset { if (fieldPtr) { - fieldPtr->primitiveFieldRef() = 0.0; + fieldPtr->primitiveFieldRef() = scalar(0); } else { @@ -62,11 +62,17 @@ void Foam::PatchInteractionFields::clearOrReset ( IOobject ( - this->owner().name() + ":" + this->modelName() + ":" + fieldName, + IOobject::scopedName + ( + this->owner().name(), + this->modelName(), + fieldName + ), mesh.time().timeName(), mesh, IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE + IOobject::NO_WRITE, + IOobject::NO_REGISTER ), mesh, dimensionedScalar(dims, Zero) diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Coulomb/CoulombForce.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Coulomb/CoulombForce.C index 36e4b0da60..97a9c55fc6 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Coulomb/CoulombForce.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/Coulomb/CoulombForce.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2023 OpenCFD Ltd. + Copyright (C) 2023-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,13 +46,14 @@ Foam::volVectorField& Foam::CoulombForce::getOrReadField ( fieldName, this->mesh().time().timeName(), - this->mesh(), + this->mesh().thisDb(), IOobject::MUST_READ, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), this->mesh() ); - this->mesh().objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C index 6bf4fd64df..440103171a 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C @@ -75,9 +75,9 @@ Foam::LocalInteraction::LocalInteraction if (writeFields_) { Info<< " Interaction fields will be written to " - << this->owner().name() << ":massEscape" + << IOobject::scopedName(this->owner().name(), "massEscape") << " and " - << this->owner().name() << ":massStick" << endl; + << IOobject::scopedName(this->owner().name(), "massStick") << endl; (void)massEscape(); (void)massStick(); @@ -164,11 +164,12 @@ Foam::volScalarField& Foam::LocalInteraction::massEscape() ( IOobject ( - this->owner().name() + ":massEscape", + IOobject::scopedName(this->owner().name(), "massEscape"), mesh.time().timeName(), - mesh, + mesh.thisDb(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh, dimensionedScalar(dimMass, Zero) @@ -193,11 +194,12 @@ Foam::volScalarField& Foam::LocalInteraction::massStick() ( IOobject ( - this->owner().name() + ":massStick", + IOobject::scopedName(this->owner().name(), "massStick"), mesh.time().timeName(), - mesh, + mesh.thisDb(), IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE + IOobject::AUTO_WRITE, + IOobject::REGISTER ), mesh, dimensionedScalar(dimMass, Zero) diff --git a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/AveragingMethod/AveragingMethod.C b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/AveragingMethod/AveragingMethod.C index 08f575bdce..6b4f324d42 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/AveragingMethod/AveragingMethod.C +++ b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/AveragingMethod/AveragingMethod.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -146,50 +146,41 @@ bool Foam::AveragingMethod::write(const bool writeOnProc) const Field pointVolume(mesh_.nPoints(), Zero); // output fields - GeometricField cellValue + auto tcellValue = GeometricField::New ( - IOobject - ( - this->name() + ":cellValue", - this->time().timeName(), - mesh_ - ), + IOobject::scopedName(this->name(), "cellValue"), + IOobject::NO_REGISTER, mesh_, dimensioned(dimless, Zero) ); - GeometricField cellGrad + auto& cellValue = tcellValue.ref(); + + auto tcellGrad = GeometricField::New ( - IOobject - ( - this->name() + ":cellGrad", - this->time().timeName(), - mesh_ - ), + IOobject::scopedName(this->name(), "cellGrad"), + IOobject::NO_REGISTER, mesh_, dimensioned(dimless, Zero) ); - GeometricField pointValue + auto& cellGrad = tcellGrad.ref(); + + auto tpointValue = GeometricField::New ( - IOobject - ( - this->name() + ":pointValue", - this->time().timeName(), - mesh_ - ), + IOobject::scopedName(this->name(), "pointValue"), + IOobject::NO_REGISTER, pointMesh_, dimensioned(dimless, Zero) ); - GeometricField pointGrad + auto& pointValue = tpointValue.ref(); + + auto tpointGrad = GeometricField::New ( - IOobject - ( - this->name() + ":pointGrad", - this->time().timeName(), - mesh_ - ), + IOobject::scopedName(this->name(), "pointGrad"), + IOobject::NO_REGISTER, pointMesh_, dimensioned(dimless, Zero) ); + auto& pointGrad = tpointGrad.ref(); // Barycentric coordinates of the tet vertices const FixedList diff --git a/src/lagrangian/intermediate/submodels/MPPIC/DampingModels/Relaxation/Relaxation.C b/src/lagrangian/intermediate/submodels/MPPIC/DampingModels/Relaxation/Relaxation.C index c70614da6e..a44015eed7 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/DampingModels/Relaxation/Relaxation.C +++ b/src/lagrangian/intermediate/submodels/MPPIC/DampingModels/Relaxation/Relaxation.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -72,30 +73,30 @@ void Foam::DampingModels::Relaxation::cacheFields(const bool store) const fvMesh& mesh = this->owner().mesh(); const word& cloudName = this->owner().name(); - const AveragingMethod& volumeAverage = + const auto& volumeAverage = mesh.lookupObject> ( - cloudName + ":volumeAverage" + IOobject::scopedName(cloudName, "volumeAverage") ); - const AveragingMethod& radiusAverage = + const auto& radiusAverage = mesh.lookupObject> ( - cloudName + ":radiusAverage" + IOobject::scopedName(cloudName, "radiusAverage") ); - const AveragingMethod& uAverage = + const auto& uAverage = mesh.lookupObject> ( - cloudName + ":uAverage" + IOobject::scopedName(cloudName, "uAverage") ); - const AveragingMethod& uSqrAverage = + const auto& uSqrAverage = mesh.lookupObject> ( - cloudName + ":uSqrAverage" + IOobject::scopedName(cloudName, "uSqrAverage") ); - const AveragingMethod& frequencyAverage = + const auto& frequencyAverage = mesh.lookupObject> ( - cloudName + ":frequencyAverage" + IOobject::scopedName(cloudName, "frequencyAverage") ); uAverage_ = &uAverage; @@ -106,7 +107,7 @@ void Foam::DampingModels::Relaxation::cacheFields(const bool store) ( IOobject ( - cloudName + ":oneByTimeScaleAverage", + IOobject::scopedName(cloudName, "oneByTimeScaleAverage"), this->owner().db().time().timeName(), mesh ), diff --git a/src/lagrangian/intermediate/submodels/MPPIC/IsotropyModels/Stochastic/Stochastic.C b/src/lagrangian/intermediate/submodels/MPPIC/IsotropyModels/Stochastic/Stochastic.C index 593fa3057a..545ab63f48 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/IsotropyModels/Stochastic/Stochastic.C +++ b/src/lagrangian/intermediate/submodels/MPPIC/IsotropyModels/Stochastic/Stochastic.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -105,35 +105,35 @@ void Foam::IsotropyModels::Stochastic::calculate() const scalar oneBySqrtThree = sqrt(1.0/3.0); - const AveragingMethod& volumeAverage = + const auto& volumeAverage = mesh.lookupObject> ( - this->owner().name() + ":volumeAverage" + IOobject::scopedName(this->owner().name(), "volumeAverage") ); - const AveragingMethod& radiusAverage = + const auto& radiusAverage = mesh.lookupObject> ( - this->owner().name() + ":radiusAverage" + IOobject::scopedName(this->owner().name(), "radiusAverage") ); - const AveragingMethod& uAverage = + const auto& uAverage = mesh.lookupObject> ( - this->owner().name() + ":uAverage" + IOobject::scopedName(this->owner().name(), "uAverage") ); - const AveragingMethod& uSqrAverage = + const auto& uSqrAverage = mesh.lookupObject> ( - this->owner().name() + ":uSqrAverage" + IOobject::scopedName(this->owner().name(), "uSqrAverage") ); - const AveragingMethod& frequencyAverage = + const auto& frequencyAverage = mesh.lookupObject> ( - this->owner().name() + ":frequencyAverage" + IOobject::scopedName(this->owner().name(), "frequencyAverage") ); - const AveragingMethod& massAverage = + const auto& massAverage = mesh.lookupObject> ( - this->owner().name() + ":massAverage" + IOobject::scopedName(this->owner().name(), "massAverage") ); // calculate time scales and pdf exponent @@ -143,7 +143,7 @@ void Foam::IsotropyModels::Stochastic::calculate() ( IOobject ( - this->owner().name() + ":exponentAverage", + IOobject::scopedName(this->owner().name(), "exponentAverage"), this->owner().db().time().timeName(), mesh ), @@ -191,7 +191,7 @@ void Foam::IsotropyModels::Stochastic::calculate() ( IOobject ( - this->owner().name() + ":uTildeAverage", + IOobject::scopedName(this->owner().name(), "uTildeAverage"), this->owner().db().time().timeName(), mesh ), @@ -213,7 +213,7 @@ void Foam::IsotropyModels::Stochastic::calculate() ( IOobject ( - this->owner().name() + ":uTildeSqrAverage", + IOobject::scopedName(this->owner().name(), "uTildeSqrAverage"), this->owner().db().time().timeName(), mesh ), diff --git a/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Explicit/Explicit.C b/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Explicit/Explicit.C index 49ea02277d..7170622fa8 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Explicit/Explicit.C +++ b/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Explicit/Explicit.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -83,25 +83,25 @@ void Foam::PackingModels::Explicit::cacheFields(const bool store) const fvMesh& mesh = this->owner().mesh(); const word& cloudName = this->owner().name(); - const AveragingMethod& volumeAverage = + const auto& volumeAverage = mesh.lookupObject> ( - cloudName + ":volumeAverage" + IOobject::scopedName(cloudName, "volumeAverage") ); - const AveragingMethod& rhoAverage = + const auto& rhoAverage = mesh.lookupObject> ( - cloudName + ":rhoAverage" + IOobject::scopedName(cloudName, "rhoAverage") ); - const AveragingMethod& uAverage = + const auto& uAverage = mesh.lookupObject> ( - cloudName + ":uAverage" + IOobject::scopedName(cloudName, "uAverage") ); - const AveragingMethod& uSqrAverage = + const auto& uSqrAverage = mesh.lookupObject> ( - cloudName + ":uSqrAverage" + IOobject::scopedName(cloudName, "uSqrAverage") ); volumeAverage_ = &volumeAverage; @@ -113,7 +113,7 @@ void Foam::PackingModels::Explicit::cacheFields(const bool store) ( IOobject ( - cloudName + ":stressAverage", + IOobject::scopedName(cloudName, "stressAverage"), this->owner().db().time().timeName(), mesh ), diff --git a/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Implicit/Implicit.C b/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Implicit/Implicit.C index c811306bc4..822fb7fc06 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Implicit/Implicit.C +++ b/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Implicit/Implicit.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2017 OpenFOAM Foundation + Copyright (C) 2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,7 +49,7 @@ Foam::PackingModels::Implicit::Implicit ( IOobject ( - this->owner().name() + ":alpha", + IOobject::scopedName(this->owner().name(), "alpha"), this->owner().db().time().timeName(), this->owner().mesh(), IOobject::NO_READ, @@ -112,20 +113,20 @@ void Foam::PackingModels::Implicit::cacheFields(const bool store) const dimensionedVector& g = this->owner().g(); const volScalarField& rhoc = this->owner().rho(); - const AveragingMethod& rhoAverage = + const auto& rhoAverage = mesh.lookupObject> ( - cloudName + ":rhoAverage" + IOobject::scopedName(cloudName, "rhoAverage") ); - const AveragingMethod& uAverage = + const auto& uAverage = mesh.lookupObject> ( - cloudName + ":uAverage" + IOobject::scopedName(cloudName, "uAverage") ); - const AveragingMethod& uSqrAverage = + const auto& uSqrAverage = mesh.lookupObject> ( - cloudName + ":uSqrAverage" + IOobject::scopedName(cloudName, "uSqrAverage") ); mesh.setFluxRequired(alpha_.name()); @@ -138,20 +139,15 @@ void Foam::PackingModels::Implicit::cacheFields(const bool store) alpha_.correctBoundaryConditions(); // average density - volScalarField rho + auto trho = volScalarField::New ( - IOobject - ( - cloudName + ":rho", - this->owner().db().time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(cloudName, "rho"), mesh, dimensionedScalar(dimDensity, Zero), fvPatchFieldBase::zeroGradientType() ); + auto& rho = trho.ref(); + rho.primitiveFieldRef() = max(rhoAverage.primitiveField(), rhoMin_); rho.correctBoundaryConditions(); @@ -159,20 +155,14 @@ void Foam::PackingModels::Implicit::cacheFields(const bool store) // ~~~~~~~~~~~~ // stress derivative wrt volume fraction - volScalarField tauPrime + auto ttauPrime = volScalarField::New ( - IOobject - ( - cloudName + ":tauPrime", - this->owner().db().time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(cloudName, "tauPrime"), mesh, dimensionedScalar(dimPressure, Zero), fvPatchFieldBase::zeroGradientType() ); + auto& tauPrime = ttauPrime.ref(); tauPrime.primitiveFieldRef() = this->particleStressModel_->dTaudTheta @@ -191,27 +181,24 @@ void Foam::PackingModels::Implicit::cacheFields(const bool store) tmp phiGByA; if (applyGravity_) - ( - phiGByA = tmp + { + phiGByA = surfaceScalarField::New ( - new surfaceScalarField - ( - "phiGByA", - deltaT*(g & mesh.Sf())*fvc::interpolate(1.0 - rhoc/rho) - ) - ) - ); + "phiGByA", + IOobject::NO_REGISTER, + deltaT*(g & mesh.Sf())*fvc::interpolate(1.0 - rhoc/rho) + ); + } // Implicit solution for the volume fraction // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - surfaceScalarField - tauPrimeByRhoAf - ( - "tauPrimeByRhoAf", - fvc::interpolate(deltaT*tauPrime/rho) - ); + surfaceScalarField tauPrimeByRhoAf + ( + "tauPrimeByRhoAf", + fvc::interpolate(deltaT*tauPrime/rho) + ); fvScalarMatrix alphaEqn ( @@ -232,38 +219,32 @@ void Foam::PackingModels::Implicit::cacheFields(const bool store) // ~~~~~~~~~~~~~~~~~ // correction volumetric flux - phiCorrect_ = tmp + phiCorrect_ = surfaceScalarField::New ( - new surfaceScalarField - ( - cloudName + ":phiCorrect", - alphaEqn.flux()/fvc::interpolate(alpha_) - ) + IOobject::scopedName(cloudName, "phiCorrect"), + IOobject::NO_REGISTER, + alphaEqn.flux()/fvc::interpolate(alpha_) ); // limit the correction flux if (applyLimiting_) { - volVectorField U + auto tU = volVectorField::New ( - IOobject - ( - cloudName + ":U", - this->owner().db().time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), + IOobject::scopedName(cloudName, "U"), + IOobject::NO_REGISTER, mesh, dimensionedVector(dimVelocity, Zero), fvPatchFieldBase::zeroGradientType() ); + auto& U = tU.ref(); + U.primitiveFieldRef() = uAverage.primitiveField(); U.correctBoundaryConditions(); surfaceScalarField phi ( - cloudName + ":phi", + IOobject::scopedName(cloudName, "phi"), linearInterpolate(U) & mesh.Sf() ); @@ -303,14 +284,11 @@ void Foam::PackingModels::Implicit::cacheFields(const bool store) } // correction velocity - uCorrect_ = tmp + uCorrect_ = volVectorField::New ( - new volVectorField - ( - cloudName + ":uCorrect", - fvc::reconstruct(phiCorrect_()) - ) - + IOobject::scopedName(cloudName, "uCorrect"), + IOobject::NO_REGISTER, + fvc::reconstruct(phiCorrect_()) ); uCorrect_->correctBoundaryConditions(); diff --git a/src/lagrangian/intermediate/submodels/MPPIC/ParticleStressModels/ParticleStressModel/ParticleStressModel.C b/src/lagrangian/intermediate/submodels/MPPIC/ParticleStressModels/ParticleStressModel/ParticleStressModel.C index 77db614098..8170bc9c82 100644 --- a/src/lagrangian/intermediate/submodels/MPPIC/ParticleStressModels/ParticleStressModel/ParticleStressModel.C +++ b/src/lagrangian/intermediate/submodels/MPPIC/ParticleStressModels/ParticleStressModel/ParticleStressModel.C @@ -107,17 +107,15 @@ Foam::ParticleStressModel::tau const FieldField& uRms ) const { - tmp> value - ( - new FieldField(alpha.size()) - ); + auto tvalue = tmp>::New(alpha.size()); + auto& value = tvalue.ref(); forAll(alpha, i) { - value->set(i, tau(alpha[i], rho[i], uRms[i])); + value.set(i, tau(alpha[i], rho[i], uRms[i])); } - return value; + return tvalue; } diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C index 4dc91ac10e..5b25c69154 100644 --- a/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C +++ b/src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C @@ -72,29 +72,19 @@ Foam::radiation::cloudAbsorptionEmission::~cloudAbsorptionEmission() Foam::tmp Foam::radiation::cloudAbsorptionEmission::aDisp(const label) const { - tmp ta + auto ta = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "a", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless/dimLength, Zero) - ) + "a", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimless/dimLength, Zero) ); - forAll(cloudNames_, i) + for (const word& cldName : cloudNames_) { const thermoCloud& tc ( - mesh_.objectRegistry::lookupObject(cloudNames_[i]) + mesh_.objectRegistry::lookupObject(cldName) ); ta.ref() += tc.ap(); @@ -107,17 +97,10 @@ Foam::radiation::cloudAbsorptionEmission::aDisp(const label) const Foam::tmp Foam::radiation::cloudAbsorptionEmission::eDisp(const label bandI) const { - return tmp::New + return volScalarField::New ( - IOobject - ( - "e", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), + "e", + IOobject::NO_REGISTER, mesh_, dimensionedScalar(dimless/dimLength, Zero) ); @@ -127,29 +110,19 @@ Foam::radiation::cloudAbsorptionEmission::eDisp(const label bandI) const Foam::tmp Foam::radiation::cloudAbsorptionEmission::EDisp(const label bandI) const { - tmp tE + auto tE = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "E", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) - ) + "E", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero) ); - forAll(cloudNames_, i) + for (const word& cldName : cloudNames_) { const thermoCloud& tc ( - mesh_.objectRegistry::lookupObject(cloudNames_[i]) + mesh_.objectRegistry::lookupObject(cldName) ); tE.ref() += tc.Ep(); diff --git a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C index 1a530c91fd..8696d74e95 100644 --- a/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C +++ b/src/lagrangian/intermediate/submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C @@ -72,30 +72,18 @@ Foam::radiation::cloudScatter::~cloudScatter() Foam::tmp Foam::radiation::cloudScatter::sigmaEff() const { - tmp tsigma + auto tsigma = volScalarField::New ( - new volScalarField - ( - IOobject - ( - "sigma", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE, - IOobject::NO_REGISTER - ), - mesh_, - dimensionedScalar(dimless/dimLength, Zero) - ) + "sigma", + IOobject::NO_REGISTER, + mesh_, + dimensionedScalar(dimless/dimLength, Zero) ); - forAll(cloudNames_, i) + for (const word& cloudName : cloudNames_) { - const thermoCloud& tc - ( - mesh_.objectRegistry::lookupObject(cloudNames_[i]) - ); + const auto& tc = + mesh_.objectRegistry::lookupObject(cloudName); tsigma.ref() += tc.sigmap(); } diff --git a/src/lumpedPointMotion/pointPatchFields/lumpedPointDisplacementPointPatchVectorField.C b/src/lumpedPointMotion/pointPatchFields/lumpedPointDisplacementPointPatchVectorField.C index 6a6814fc6f..b10fe98d72 100644 --- a/src/lumpedPointMotion/pointPatchFields/lumpedPointDisplacementPointPatchVectorField.C +++ b/src/lumpedPointMotion/pointPatchFields/lumpedPointDisplacementPointPatchVectorField.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -191,7 +191,7 @@ Foam::lumpedPointDisplacementPointPatchVectorField::movement() const // Create and register with this patch as the owner ptr = lumpedPointIOMovement::New(obr, this->patch().index()).ptr(); - objectRegistry::store(ptr); + regIOobject::store(ptr); } return *ptr; diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C index 2f857a3d56..072e39dfeb 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C @@ -113,8 +113,8 @@ Foam::tmp Foam::snappyLayerDriver::avgPointData const scalarField& pointFld ) { - tmp tfaceFld(new scalarField(pp.size(), Zero)); - scalarField& faceFld = tfaceFld.ref(); + auto tfaceFld = tmp::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 9667c05783..b38620a13f 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C @@ -257,8 +257,8 @@ Foam::tmp Foam::snappySnapDriver::smoothInternalDisplacement // Add coupled contributions weightedPosition::syncPoints(mesh, sumLocation); - tmp tdisplacement(new pointField(mesh.nPoints(), Zero)); - pointField& displacement = tdisplacement.ref(); + auto tdisplacement = tmp::New(mesh.nPoints(), Zero); + auto& displacement = tdisplacement.ref(); label nAdapted = 0; @@ -490,8 +490,8 @@ Foam::tmp Foam::snappySnapDriver::smoothPatchDisplacement // Displacement to calculate. - tmp tpatchDisp(new pointField(meshPoints.size(), Zero)); - pointField& patchDisp = tpatchDisp.ref(); + auto tpatchDisp = tmp::New(meshPoints.size(), Zero); + auto& patchDisp = tpatchDisp.ref(); forAll(pointFaces, i) { @@ -571,8 +571,8 @@ Foam::tmp Foam::snappySnapDriver::smoothPatchDisplacement // const labelListList& pointEdges = pp.pointEdges(); // const edgeList& edges = pp.edges(); // -// tmp tavg(new pointField(pointEdges.size(), Zero)); -// pointField& avg = tavg(); +// auto tavg = tmp::New(pointEdges.size(), Zero); +// auto& avg = tavg.ref(); // // forAll(pointEdges, verti) // { @@ -658,8 +658,8 @@ Foam::tmp Foam::snappySnapDriver::edgePatchDist ); // Copy edge values into scalarField - tmp tedgeDist(new scalarField(mesh.nEdges())); - scalarField& edgeDist = tedgeDist.ref(); + auto tedgeDist = tmp::New(mesh.nEdges()); + auto& edgeDist = tedgeDist.ref(); forAll(allEdgeInfo, edgei) { @@ -1057,7 +1057,7 @@ Foam::tmp Foam::snappySnapDriver::avgCellCentres // Add coupled contributions weightedPosition::syncPoints(mesh, pp.meshPoints(), avgBoundary); - tmp tavgBoundary(new pointField(avgBoundary.size())); + auto tavgBoundary = tmp::New(avgBoundary.size()); weightedPosition::getPoints(avgBoundary, tavgBoundary.ref()); return tavgBoundary; @@ -1073,8 +1073,8 @@ Foam::tmp Foam::snappySnapDriver::avgCellCentres // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // (Ripped from snappyLayerDriver) // -// tmp tedgeLen(new scalarField(pp.nPoints())); -// scalarField& edgeLen = tedgeLen(); +// auto tedgeLen = tmp::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 2ee6a6c4c3..fc5f7df520 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::cellQuality::nonOrthogonality() const { - tmp tresult - ( - new scalarField - ( - mesh_.nCells(), 0.0 - ) - ); - - scalarField& result = tresult.ref(); + auto tresult = tmp::New(mesh_.nCells(), Zero); + auto& result = tresult.ref(); scalarField sumArea(mesh_.nCells(), Zero); @@ -103,14 +96,8 @@ Foam::tmp Foam::cellQuality::nonOrthogonality() const Foam::tmp Foam::cellQuality::skewness() const { - tmp tresult - ( - new scalarField - ( - mesh_.nCells(), 0.0 - ) - ); - scalarField& result = tresult.ref(); + auto tresult = tmp::New(mesh_.nCells(), Zero); + auto& result = tresult.ref(); scalarField sumArea(mesh_.nCells(), Zero); @@ -182,15 +169,8 @@ Foam::tmp Foam::cellQuality::skewness() const Foam::tmp Foam::cellQuality::faceNonOrthogonality() const { - tmp tresult - ( - new scalarField - ( - mesh_.nFaces(), 0.0 - ) - ); - scalarField& result = tresult.ref(); - + auto tresult = tmp::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::cellQuality::faceNonOrthogonality() const Foam::tmp Foam::cellQuality::faceSkewness() const { - tmp tresult - ( - new scalarField - ( - mesh_.nFaces(), 0.0 - ) - ); - scalarField& result = tresult.ref(); - + auto tresult = tmp::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 fbb851e4b3..6458779c7f 100644 --- a/src/meshTools/edgeMesh/edgeMeshTools/edgeMeshFeatureProximity.C +++ b/src/meshTools/edgeMesh/edgeMeshTools/edgeMeshFeatureProximity.C @@ -143,8 +143,8 @@ Foam::tmp Foam::edgeMeshTools::featureProximity const scalar searchDistance ) { - tmp tfld(new scalarField(surf.size(), searchDistance)); - scalarField& featureProximity = tfld.ref(); + auto tfld = tmp::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/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C index 924afa2b5a..7b6ce7e3ca 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2023 OpenCFD Ltd. + Copyright (C) 2018-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -300,7 +300,7 @@ bool Foam::mappedPatchBase::constructIOField ), Foam::zero{} ); - objectRegistry::store(fldPtr); + regIOobject::store(fldPtr); } fldPtr->transfer @@ -340,7 +340,7 @@ void Foam::mappedPatchBase::storeField ), Foam::zero{} ); - objectRegistry::store(fldPtr); + regIOobject::store(fldPtr); } *fldPtr = values; diff --git a/src/meshTools/matrices/lduMatrix/preconditioners/distributedDILUPreconditioner/processorColour.C b/src/meshTools/matrices/lduMatrix/preconditioners/distributedDILUPreconditioner/processorColour.C index 92298e2091..b655785b1d 100644 --- a/src/meshTools/matrices/lduMatrix/preconditioners/distributedDILUPreconditioner/processorColour.C +++ b/src/meshTools/matrices/lduMatrix/preconditioners/distributedDILUPreconditioner/processorColour.C @@ -340,23 +340,21 @@ Foam::processorColour::processorColour(const lduMesh& mesh) const Foam::processorColour& Foam::processorColour::New(const lduMesh& mesh) { - const processorColour* ptr = - mesh.thisDb().objectRegistry::template cfindObject + auto* ptr = + mesh.thisDb().objectRegistry::template getObjectPtr ( processorColour::typeName ); - if (ptr) + if (!ptr) { - return *ptr; + ptr = new processorColour(mesh); + + //regIOobject::store(static_cast*>(ptr)); + regIOobject::store(ptr); } - processorColour* objectPtr = new processorColour(mesh); - - //regIOobject::store(static_cast*>(objectPtr)); - regIOobject::store(objectPtr); - - return *objectPtr; + return *ptr; } diff --git a/src/meshTools/momentOfInertia/momentOfInertia.C b/src/meshTools/momentOfInertia/momentOfInertia.C index 3ea48e8472..ffb296a3a0 100644 --- a/src/meshTools/momentOfInertia/momentOfInertia.C +++ b/src/meshTools/momentOfInertia/momentOfInertia.C @@ -354,9 +354,8 @@ Foam::tmp Foam::momentOfInertia::meshInertia const polyMesh& mesh ) { - tmp tTf = tmp(new tensorField(mesh.nCells())); - - tensorField& tf = tTf.ref(); + auto tTf = tmp::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 c47ee9e62f..b9add2217b 100644 --- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceCloseness.C +++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceCloseness.C @@ -103,8 +103,8 @@ Foam::triSurfaceTools::writeCloseness { Pair> tpair ( - tmp(new scalarField(surf.size(), GREAT)), - tmp(new scalarField(surf.size(), GREAT)) + tmp::New(surf.size(), GREAT), + tmp::New(surf.size(), GREAT) ); Info<< "Extracting internal and external closeness of surface." << endl; diff --git a/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.C b/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.C index 9a3bb69b9f..2adc5016f8 100644 --- a/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.C +++ b/src/optimisation/adjointOptimisation/adjoint/ATCModel/ATCModel/ATCModel.C @@ -229,25 +229,16 @@ tmp ATCModel::createLimiter const labelList& zeroCells = zeroType->getZeroATCcells(); const label nSmooth = dict.getOrDefault