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 |
-------------------------------------------------------------------------------
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())

View File

@ -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)
{

View File

@ -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;

View File

@ -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()
);
}

View File

@ -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())

View File

@ -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();

View File

@ -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())

View File

@ -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)
);