ENH: use tmp field factory methods [8] (#2723)

- src/combustion
This commit is contained in:
Mark Olesen
2024-01-23 11:00:05 +01:00
parent 51f150d84c
commit 7bf0aaf99c
8 changed files with 82 additions and 190 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2019-2020,2023 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -59,11 +59,12 @@ Foam::combustionModels::EDC<ReactionThermo>::EDC
( (
IOobject IOobject
( (
this->thermo().phasePropertyName(typeName + ":kappa"), this->thermo().phaseScopedName(typeName, "kappa"),
this->mesh().time().timeName(), this->mesh().time().timeName(),
this->mesh(), this->mesh(),
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE,
IOobject::REGISTER
), ),
this->mesh(), this->mesh(),
dimensionedScalar(dimless, Zero) dimensionedScalar(dimless, Zero)
@ -86,23 +87,23 @@ void Foam::combustionModels::EDC<ReactionThermo>::correct()
if (this->active()) if (this->active())
{ {
tmp<volScalarField> tepsilon(this->turbulence().epsilon()); tmp<volScalarField> tepsilon(this->turbulence().epsilon());
const volScalarField& epsilon = tepsilon(); const auto& epsilon = tepsilon();
tmp<volScalarField> tmu(this->turbulence().mu()); tmp<volScalarField> tmu(this->turbulence().mu());
const volScalarField& mu = tmu(); const auto& mu = tmu();
tmp<volScalarField> tk(this->turbulence().k()); tmp<volScalarField> tk(this->turbulence().k());
const volScalarField& k = tk(); const auto& k = tk();
tmp<volScalarField> trho(this->rho()); tmp<volScalarField> trho(this->rho());
const volScalarField& rho = trho(); const auto& rho = trho();
scalarField tauStar(epsilon.size(), Zero); scalarField tauStar(epsilon.size(), Zero);
if (version_ == EDCversions::v2016) if (version_ == EDCversions::v2016)
{ {
tmp<volScalarField> ttc(this->chemistryPtr_->tc()); tmp<volScalarField> ttc(this->chemistryPtr_->tc());
const volScalarField& tc = ttc(); const auto& tc = ttc();
forAll(tauStar, i) forAll(tauStar, i)
{ {
@ -199,22 +200,12 @@ template<class ReactionThermo>
Foam::tmp<Foam::volScalarField> Foam::tmp<Foam::volScalarField>
Foam::combustionModels::EDC<ReactionThermo>::Qdot() const Foam::combustionModels::EDC<ReactionThermo>::Qdot() const
{ {
tmp<volScalarField> tQdot auto tQdot = volScalarField::New
( (
new volScalarField this->thermo().phaseScopedName(typeName, "Qdot"),
( IOobject::NO_REGISTER,
IOobject this->mesh(),
( dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero)
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)
)
); );
if (this->active()) if (this->active())

View File

@ -72,7 +72,8 @@ FSD<ReactionThermo, ThermoType>::FSD
this->mesh().time().timeName(), this->mesh().time().timeName(),
this->mesh(), this->mesh(),
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE,
IOobject::REGISTER
), ),
this->mesh(), this->mesh(),
dimensionedScalar(dimless, Zero) dimensionedScalar(dimless, Zero)
@ -149,43 +150,23 @@ void FSD<ReactionThermo, ThermoType>::calculateSourceNorm()
s.value()*YFuelFuelStream_.value() + YO2OxiStream_.value() s.value()*YFuelFuelStream_.value() + YO2OxiStream_.value()
); );
tmp<volScalarField> tPc auto tPc = volScalarField::New
( (
new volScalarField this->thermo().phasePropertyName("Pc"),
( IOobject::NO_REGISTER,
IOobject U.mesh(),
( dimensionedScalar(dimless, Zero)
this->thermo().phasePropertyName("Pc"),
U.time().timeName(),
U.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
U.mesh(),
dimensionedScalar(dimless, Zero)
)
); );
auto& pc = tPc.ref();
volScalarField& pc = tPc.ref(); auto tomegaFuel = volScalarField::New
tmp<volScalarField> tomegaFuel
( (
new volScalarField this->thermo().phasePropertyName("omegaFuelBar"),
( IOobject::NO_REGISTER,
IOobject U.mesh(),
( dimensionedScalar(omegaFuel.dimensions(), Zero)
this->thermo().phasePropertyName("omegaFuelBar"),
U.time().timeName(),
U.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
U.mesh(),
dimensionedScalar(omegaFuel.dimensions(), Zero)
)
); );
auto& omegaFuelBar = tomegaFuel.ref();
volScalarField& omegaFuelBar = tomegaFuel.ref();
// Calculation of the mixture fraction variance (ftVar) // Calculation of the mixture fraction variance (ftVar)
const compressible::LESModel& lesModel = const compressible::LESModel& lesModel =
@ -294,24 +275,14 @@ void FSD<ReactionThermo, ThermoType>::calculateSourceNorm()
} }
} }
tmp<volScalarField> tproducts auto tproducts = volScalarField::New
( (
new volScalarField this->thermo().phasePropertyName("products"),
( IOobject::NO_REGISTER,
IOobject U.mesh(),
( dimensionedScalar(dimless, Zero)
this->thermo().phasePropertyName("products"),
U.time().timeName(),
U.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
U.mesh(),
dimensionedScalar(dimless, Zero)
)
); );
auto& products = tproducts.ref();
volScalarField& products = tproducts.ref();
forAll(productsIndex, j) forAll(productsIndex, j)
{ {

View File

@ -82,24 +82,14 @@ Foam::tmp<Foam::volScalarField> Foam::consumptionSpeed::omega0Sigma
const volScalarField& sigma const volScalarField& sigma
) )
{ {
tmp<volScalarField> tomega0 auto tomega0 = volScalarField::New
( (
new volScalarField "omega0",
( IOobject::NO_REGISTER,
IOobject sigma.mesh(),
( dimensionedScalar(dimensionSet(1, -2, -1, 0, 0, 0, 0), Zero)
"omega0",
sigma.time().timeName(),
sigma.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
sigma.mesh(),
dimensionedScalar(dimensionSet(1, -2, -1, 0, 0, 0, 0), Zero)
)
); );
auto& omega0 = tomega0.ref();
volScalarField& omega0 = tomega0.ref();
volScalarField::Internal& iomega0 = omega0; volScalarField::Internal& iomega0 = omega0;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019,2023 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -45,11 +45,12 @@ Foam::combustionModels::PaSR<ReactionThermo>::PaSR
( (
IOobject IOobject
( (
thermo.phasePropertyName(typeName + ":kappa"), thermo.phaseScopedName(typeName, "kappa"),
this->mesh().time().timeName(), this->mesh().time().timeName(),
this->mesh(), this->mesh(),
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE,
IOobject::REGISTER
), ),
this->mesh(), this->mesh(),
dimensionedScalar(dimless, Zero) dimensionedScalar(dimless, Zero)
@ -74,16 +75,16 @@ void Foam::combustionModels::PaSR<ReactionThermo>::correct()
laminar<ReactionThermo>::correct(); laminar<ReactionThermo>::correct();
tmp<volScalarField> tepsilon(this->turbulence().epsilon()); tmp<volScalarField> tepsilon(this->turbulence().epsilon());
const scalarField& epsilon = tepsilon(); const auto& epsilon = tepsilon();
tmp<volScalarField> tmuEff(this->turbulence().muEff()); tmp<volScalarField> tmuEff(this->turbulence().muEff());
const scalarField& muEff = tmuEff(); const auto& muEff = tmuEff();
tmp<volScalarField> ttc(this->tc()); tmp<volScalarField> ttc(this->tc());
const scalarField& tc = ttc(); const auto& tc = ttc();
tmp<volScalarField> trho(this->rho()); tmp<volScalarField> trho(this->rho());
const scalarField& rho = trho(); const auto& rho = trho();
forAll(epsilon, i) forAll(epsilon, i)
{ {
@ -118,13 +119,11 @@ template<class ReactionThermo>
Foam::tmp<Foam::volScalarField> Foam::tmp<Foam::volScalarField>
Foam::combustionModels::PaSR<ReactionThermo>::Qdot() const Foam::combustionModels::PaSR<ReactionThermo>::Qdot() const
{ {
return tmp<volScalarField> return volScalarField::New
( (
new volScalarField this->thermo().phaseScopedName(typeName, "Qdot"),
( IOobject::NO_REGISTER,
this->thermo().phasePropertyName(typeName + ":Qdot"), kappa_*laminar<ReactionThermo>::Qdot()
kappa_*laminar<ReactionThermo>::Qdot()
)
); );
} }

View File

@ -60,15 +60,7 @@ diffusionMulticomponent<ReactionThermo, ThermoType>::init()
k, k,
new volScalarField new volScalarField
( (
IOobject this->mesh_.newIOobject("Rijk" + Foam::name(k)),
(
"Rijk" + Foam::name(k),
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
this->mesh_, this->mesh_,
dimensionedScalar(dimMass/dimTime/dimVolume, Zero), dimensionedScalar(dimMass/dimTime/dimVolume, Zero),
fvPatchFieldBase::zeroGradientType() fvPatchFieldBase::zeroGradientType()
@ -198,15 +190,7 @@ diffusionMulticomponent<ReactionThermo, ThermoType>::correct()
k, k,
new volScalarField new volScalarField
( (
IOobject this->mesh_.newIOobject("Rijl" + Foam::name(k)),
(
"Rijl" + Foam::name(k),
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
this->mesh_, this->mesh_,
dimensionedScalar(dimMass/dimTime/dimVolume, Zero), dimensionedScalar(dimMass/dimTime/dimVolume, Zero),
fvPatchFieldBase::zeroGradientType() fvPatchFieldBase::zeroGradientType()
@ -374,9 +358,8 @@ Foam::combustionModels::diffusionMulticomponent<ReactionThermo, ThermoType>::R
volScalarField& Y volScalarField& Y
) const ) const
{ {
tmp<fvScalarMatrix> tSu(new fvScalarMatrix(Y, dimMass/dimTime)); auto tSu = tmp<fvScalarMatrix>::New(Y, dimMass/dimTime);
auto& Su = tSu.ref();
fvScalarMatrix& Su = tSu.ref();
if (this->active()) if (this->active())
{ {
@ -395,23 +378,13 @@ Foam::tmp<Foam::volScalarField>
Foam::combustionModels:: Foam::combustionModels::
diffusionMulticomponent<ReactionThermo, ThermoType>::Qdot() const diffusionMulticomponent<ReactionThermo, ThermoType>::Qdot() const
{ {
tmp<volScalarField> tQdot auto tQdot = volScalarField::New
( (
new volScalarField "Qdot",
( IOobject::NO_REGISTER,
IOobject this->mesh(),
( dimensionedScalar(dimEnergy/dimTime/dimVolume, Zero),
"Qdot", fvPatchFieldBase::zeroGradientType()
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
this->mesh(),
dimensionedScalar(dimEnergy/dimTime/dimVolume, Zero),
fvPatchFieldBase::zeroGradientType()
)
); );
if (this->active()) if (this->active())

View File

@ -77,25 +77,16 @@ template<class ReactionThermo, class ThermoType>
Foam::tmp<Foam::volScalarField> Foam::tmp<Foam::volScalarField>
eddyDissipationDiffusionModel<ReactionThermo, ThermoType>::rtDiff() const eddyDissipationDiffusionModel<ReactionThermo, ThermoType>::rtDiff() const
{ {
tmp<volScalarField> tdelta auto tdelta = volScalarField::New
( (
new volScalarField "tdelta",
( IOobject::NO_REGISTER,
IOobject this->mesh(),
( dimensionedScalar(dimLength, Zero),
"tdelta", fvPatchFieldBase::zeroGradientType()
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
this->mesh(),
dimensionedScalar(dimLength, Zero),
fvPatchFieldBase::zeroGradientType()
)
); );
auto& delta = tdelta.ref();
volScalarField& delta = tdelta.ref();
delta.ref() = cbrt(this->mesh().V()); delta.ref() = cbrt(this->mesh().V());
delta.correctBoundaryConditions(); delta.correctBoundaryConditions();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -123,9 +123,8 @@ template<class ReactionThermo>
Foam::tmp<Foam::fvScalarMatrix> Foam::tmp<Foam::fvScalarMatrix>
Foam::combustionModels::laminar<ReactionThermo>::R(volScalarField& Y) const Foam::combustionModels::laminar<ReactionThermo>::R(volScalarField& Y) const
{ {
tmp<fvScalarMatrix> tSu(new fvScalarMatrix(Y, dimMass/dimTime)); auto tSu = tmp<fvScalarMatrix>::New(Y, dimMass/dimTime);
auto& Su = tSu.ref();
fvScalarMatrix& Su = tSu.ref();
if (this->active()) if (this->active())
{ {
@ -143,22 +142,12 @@ template<class ReactionThermo>
Foam::tmp<Foam::volScalarField> Foam::tmp<Foam::volScalarField>
Foam::combustionModels::laminar<ReactionThermo>::Qdot() const Foam::combustionModels::laminar<ReactionThermo>::Qdot() const
{ {
tmp<volScalarField> tQdot auto tQdot = volScalarField::New
( (
new volScalarField this->thermo().phaseScopedName(typeName, "Qdot"),
( IOobject::NO_REGISTER,
IOobject this->mesh(),
( dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero)
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)
)
); );
if (this->active()) if (this->active())

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -65,12 +65,7 @@ Foam::combustionModels::noCombustion<ReactionThermo>::R
volScalarField& Y volScalarField& Y
) const ) const
{ {
tmp<fvScalarMatrix> tSu return tmp<fvScalarMatrix>::New(Y, dimMass/dimTime);
(
new fvScalarMatrix(Y, dimMass/dimTime)
);
return tSu;
} }
@ -78,17 +73,10 @@ template<class ReactionThermo>
Foam::tmp<Foam::volScalarField> Foam::tmp<Foam::volScalarField>
Foam::combustionModels::noCombustion<ReactionThermo>::Qdot() const Foam::combustionModels::noCombustion<ReactionThermo>::Qdot() const
{ {
return tmp<volScalarField>::New return volScalarField::New
( (
IOobject this->thermo().phaseScopedName(typeName, "Qdot"),
( IOobject::NO_REGISTER,
this->thermo().phasePropertyName(typeName + ":Qdot"),
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
this->mesh(), this->mesh(),
dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero) dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero)
); );