From 017bebbdc7e48d50cf003c9a71926bd5faa4c31d Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 23 Jan 2024 11:00:05 +0100 Subject: [PATCH] ENH: use tmp field factory methods [8] (#2723) - src/combustion --- src/combustionModels/EDC/EDC.C | 37 ++++------ src/combustionModels/FSD/FSD.C | 69 ++++++------------- .../consumptionSpeed/consumptionSpeed.C | 22 ++---- src/combustionModels/PaSR/PaSR.C | 25 ++++--- .../diffusionMulticomponent.C | 47 +++---------- .../eddyDissipationDiffusionModel.C | 23 ++----- src/combustionModels/laminar/laminar.C | 27 +++----- .../noCombustion/noCombustion.C | 22 ++---- 8 files changed, 82 insertions(+), 190 deletions(-) diff --git a/src/combustionModels/EDC/EDC.C b/src/combustionModels/EDC/EDC.C index 3e55ba9ce1c..90fc7e26051 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<ReactionThermo>::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<ReactionThermo>::correct() if (this->active()) { tmp<volScalarField> tepsilon(this->turbulence().epsilon()); - const volScalarField& epsilon = tepsilon(); + const auto& epsilon = tepsilon(); tmp<volScalarField> tmu(this->turbulence().mu()); - const volScalarField& mu = tmu(); + const auto& mu = tmu(); tmp<volScalarField> tk(this->turbulence().k()); - const volScalarField& k = tk(); + const auto& k = tk(); tmp<volScalarField> trho(this->rho()); - const volScalarField& rho = trho(); + const auto& rho = trho(); scalarField tauStar(epsilon.size(), Zero); if (version_ == EDCversions::v2016) { tmp<volScalarField> ttc(this->chemistryPtr_->tc()); - const volScalarField& tc = ttc(); + const auto& tc = ttc(); forAll(tauStar, i) { @@ -199,22 +200,12 @@ template<class ReactionThermo> Foam::tmp<Foam::volScalarField> Foam::combustionModels::EDC<ReactionThermo>::Qdot() const { - tmp<volScalarField> 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 ef9f1d382dd..03e4b93f686 100644 --- a/src/combustionModels/FSD/FSD.C +++ b/src/combustionModels/FSD/FSD.C @@ -72,7 +72,8 @@ FSD<ReactionThermo, ThermoType>::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<ReactionThermo, ThermoType>::calculateSourceNorm() s.value()*YFuelFuelStream_.value() + YO2OxiStream_.value() ); - tmp<volScalarField> 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<volScalarField> 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<ReactionThermo, ThermoType>::calculateSourceNorm() } } - tmp<volScalarField> 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 2322572550d..808348cd206 100644 --- a/src/combustionModels/FSD/reactionRateFlameAreaModels/consumptionSpeed/consumptionSpeed.C +++ b/src/combustionModels/FSD/reactionRateFlameAreaModels/consumptionSpeed/consumptionSpeed.C @@ -82,24 +82,14 @@ Foam::tmp<Foam::volScalarField> Foam::consumptionSpeed::omega0Sigma const volScalarField& sigma ) { - tmp<volScalarField> 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 63559a0aafe..77c75294fb1 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<ReactionThermo>::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<ReactionThermo>::correct() laminar<ReactionThermo>::correct(); tmp<volScalarField> tepsilon(this->turbulence().epsilon()); - const scalarField& epsilon = tepsilon(); + const auto& epsilon = tepsilon(); tmp<volScalarField> tmuEff(this->turbulence().muEff()); - const scalarField& muEff = tmuEff(); + const auto& muEff = tmuEff(); tmp<volScalarField> ttc(this->tc()); - const scalarField& tc = ttc(); + const auto& tc = ttc(); tmp<volScalarField> trho(this->rho()); - const scalarField& rho = trho(); + const auto& rho = trho(); forAll(epsilon, i) { @@ -118,13 +119,11 @@ template<class ReactionThermo> Foam::tmp<Foam::volScalarField> Foam::combustionModels::PaSR<ReactionThermo>::Qdot() const { - return tmp<volScalarField> + return volScalarField::New ( - new volScalarField - ( - this->thermo().phasePropertyName(typeName + ":Qdot"), - kappa_*laminar<ReactionThermo>::Qdot() - ) + this->thermo().phaseScopedName(typeName, "Qdot"), + IOobject::NO_REGISTER, + kappa_*laminar<ReactionThermo>::Qdot() ); } diff --git a/src/combustionModels/diffusionMulticomponent/diffusionMulticomponent.C b/src/combustionModels/diffusionMulticomponent/diffusionMulticomponent.C index fb5c1556250..7a10ab2a177 100644 --- a/src/combustionModels/diffusionMulticomponent/diffusionMulticomponent.C +++ b/src/combustionModels/diffusionMulticomponent/diffusionMulticomponent.C @@ -60,15 +60,7 @@ diffusionMulticomponent<ReactionThermo, ThermoType>::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<ReactionThermo, ThermoType>::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<ReactionThermo, ThermoType>::R volScalarField& Y ) const { - tmp<fvScalarMatrix> tSu(new fvScalarMatrix(Y, dimMass/dimTime)); - - fvScalarMatrix& Su = tSu.ref(); + auto tSu = tmp<fvScalarMatrix>::New(Y, dimMass/dimTime); + auto& Su = tSu.ref(); if (this->active()) { @@ -395,23 +378,13 @@ Foam::tmp<Foam::volScalarField> Foam::combustionModels:: diffusionMulticomponent<ReactionThermo, ThermoType>::Qdot() const { - tmp<volScalarField> 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 fa042bfce06..b8c61234bee 100644 --- a/src/combustionModels/eddyDissipationDiffusionModel/eddyDissipationDiffusionModel.C +++ b/src/combustionModels/eddyDissipationDiffusionModel/eddyDissipationDiffusionModel.C @@ -77,25 +77,16 @@ template<class ReactionThermo, class ThermoType> Foam::tmp<Foam::volScalarField> eddyDissipationDiffusionModel<ReactionThermo, ThermoType>::rtDiff() const { - tmp<volScalarField> 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 50f56816433..feb5889bb58 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<class ReactionThermo> Foam::tmp<Foam::fvScalarMatrix> Foam::combustionModels::laminar<ReactionThermo>::R(volScalarField& Y) const { - tmp<fvScalarMatrix> tSu(new fvScalarMatrix(Y, dimMass/dimTime)); - - fvScalarMatrix& Su = tSu.ref(); + auto tSu = tmp<fvScalarMatrix>::New(Y, dimMass/dimTime); + auto& Su = tSu.ref(); if (this->active()) { @@ -143,22 +142,12 @@ template<class ReactionThermo> Foam::tmp<Foam::volScalarField> Foam::combustionModels::laminar<ReactionThermo>::Qdot() const { - tmp<volScalarField> 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 e123b2f2dd5..7bbeafa7dcb 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<ReactionThermo>::R volScalarField& Y ) const { - tmp<fvScalarMatrix> tSu - ( - new fvScalarMatrix(Y, dimMass/dimTime) - ); - - return tSu; + return tmp<fvScalarMatrix>::New(Y, dimMass/dimTime); } @@ -78,17 +73,10 @@ template<class ReactionThermo> Foam::tmp<Foam::volScalarField> Foam::combustionModels::noCombustion<ReactionThermo>::Qdot() const { - return tmp<volScalarField>::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) ); -- GitLab