Code adjustments to avoid gcc-13 warnings about dangling references

This commit is contained in:
Mattijs Janssens
2024-01-11 10:08:45 +00:00
committed by Mark OLESEN
parent 89cd584440
commit bb16c493b7
42 changed files with 192 additions and 133 deletions

View File

@ -241,7 +241,8 @@ void Foam::phaseModel::correctInflowOutflow(surfaceScalarField& alphaPhi) const
{
surfaceScalarField::Boundary& alphaPhiBf = alphaPhi.boundaryFieldRef();
const volScalarField::Boundary& alphaBf = boundaryField();
const surfaceScalarField::Boundary& phiBf = phi().boundaryField();
const tmp<surfaceScalarField> tphi(phi());
const auto& phiBf = tphi().boundaryField();
forAll(alphaPhiBf, patchi)
{

View File

@ -355,7 +355,8 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::momentumTransfer()
fvVectorMatrix& eqn = *eqns[phase.name()];
const volVectorField& U = eqn.psi();
const surfaceScalarField& phi = phase.phi();
const tmp<surfaceScalarField> tphi(phase.phi());
const surfaceScalarField& phi = tphi();
eqn -=
Vm
@ -408,7 +409,8 @@ Foam::MomentumTransferPhaseSystem<BasePhaseSystem>::momentumTransferf()
if (!phase.stationary())
{
const volVectorField& U = phase.U();
const tmp<volVectorField> tU(phase.U());
const volVectorField& U = tU();
UgradUs.set
(

View File

@ -85,8 +85,11 @@ Foam::tmp<Foam::volScalarField> Foam::dragModels::segregated::K() const
const volScalarField& alpha1(pair_.phase1());
const volScalarField& alpha2(pair_.phase2());
const volScalarField& rho1(pair_.phase1().rho());
const volScalarField& rho2(pair_.phase2().rho());
const tmp<volScalarField> trho1(pair_.phase1().rho());
const tmp<volScalarField> trho2(pair_.phase2().rho());
const volScalarField& rho1 = trho1();
const volScalarField& rho2 = trho2();
tmp<volScalarField> tnu1(pair_.phase1().nu());
tmp<volScalarField> tnu2(pair_.phase2().nu());

View File

@ -93,7 +93,8 @@ Foam::tmp<Foam::fvScalarMatrix>
Foam::AnisothermalPhaseModel<BasePhaseModel>::heEqn()
{
const volScalarField& alpha = *this;
const volScalarField& rho = this->rho();
const tmp<volScalarField> trho(this->rho());
const volScalarField& rho(trho());
const tmp<volVectorField> tU(this->U());
const volVectorField& U(tU());

View File

@ -283,7 +283,8 @@ Foam::tmp<Foam::fvVectorMatrix>
Foam::MovingPhaseModel<BasePhaseModel>::UEqn()
{
const volScalarField& alpha = *this;
const volScalarField& rho = this->thermo().rho();
const tmp<volScalarField> trho = this->thermo().rho();
const volScalarField& rho = trho();
return
(
@ -303,14 +304,13 @@ Foam::MovingPhaseModel<BasePhaseModel>::UfEqn()
// As the "normal" U-eqn but without the ddt terms
const volScalarField& alpha = *this;
const volScalarField& rho = this->thermo().rho();
return
(
fvm::div(alphaRhoPhi_, U_)
- fvm::Sp(fvc::div(alphaRhoPhi_), U_)
+ fvm::SuSp(- this->continuityErrorSources(), U_)
+ this->fluid().MRF().DDt(alpha*rho, U_)
+ this->fluid().MRF().DDt(alpha*this->thermo().rho(), U_)
+ turbulence_->divDevRhoReff(U_)
);
}

View File

@ -152,7 +152,8 @@ Foam::MultiComponentPhaseModel<BasePhaseModel>::YiEqn(volScalarField& Yi)
{
const volScalarField& alpha = *this;
const surfaceScalarField alphaRhoPhi(this->alphaRhoPhi());
const volScalarField& rho = this->thermo().rho();
const tmp<volScalarField> trho(this->thermo().rho());
const volScalarField& rho = trho();
return
(

View File

@ -207,7 +207,8 @@ void Foam::phaseModel::correctInflowOutflow(surfaceScalarField& alphaPhi) const
{
surfaceScalarField::Boundary& alphaPhiBf = alphaPhi.boundaryFieldRef();
const volScalarField::Boundary& alphaBf = boundaryField();
const surfaceScalarField::Boundary& phiBf = phi()().boundaryField();
const tmp<surfaceScalarField> tphi(phi());
const auto& phiBf = tphi().boundaryField();
forAll(alphaPhiBf, patchi)
{

View File

@ -154,7 +154,8 @@ Foam::diameterModels::nucleationModels::wallBoiling::addToNucleationRate
{
const sizeGroup& fi = popBal_.sizeGroups()[i];
const phaseModel& phase = fi.phase();
const volScalarField& rho = phase.rho();
const tmp<volScalarField> trho(phase.rho());
const volScalarField& rho = trho();
const tmp<volScalarField> talphat(turbulence_.alphat());
const volScalarField::Boundary& alphatBf = talphat().boundaryField();

View File

@ -1273,7 +1273,8 @@ void Foam::diameterModels::populationBalanceModel::solve()
const phaseModel& phase = fi.phase();
const volScalarField& alpha = phase;
const dimensionedScalar& residualAlpha = phase.residualAlpha();
const volScalarField& rho = phase.thermo().rho();
const tmp<volScalarField> trho(phase.thermo().rho());
const volScalarField& rho = trho();
fvScalarMatrix sizeGroupEqn
(

View File

@ -156,7 +156,8 @@ JohnsonJacksonSchaeffer::nu
}
const fvPatchList& patches = phase.mesh().boundary();
const volVectorField& U = phase.U();
const tmp<volVectorField> tU(phase.U());
const volVectorField& U = tU();
volScalarField::Boundary& nufBf = nuf.boundaryFieldRef();

View File

@ -154,7 +154,8 @@ Foam::kineticTheoryModels::frictionalStressModels::Schaeffer::nu
}
const fvPatchList& patches = phase.mesh().boundary();
const volVectorField& U = phase.U();
const tmp<volVectorField> tU(phase.U());
const volVectorField& U = tU();
volScalarField::Boundary& nufBf = nuf.boundaryFieldRef();

View File

@ -266,7 +266,8 @@ Foam::RASModels::kineticTheoryModel::R() const
Foam::tmp<Foam::volScalarField>
Foam::RASModels::kineticTheoryModel::pPrime() const
{
const volScalarField& rho = phase_.rho();
const tmp<volScalarField> trho(phase_.rho());
const volScalarField& rho = trho();
tmp<volScalarField> tpPrime
(
@ -365,11 +366,13 @@ void Foam::RASModels::kineticTheoryModel::correct()
{
// Local references
volScalarField alpha(max(alpha_, scalar(0)));
const volScalarField& rho = phase_.rho();
const tmp<volScalarField> trho(phase_.rho());
const volScalarField& rho = trho();
const surfaceScalarField& alphaRhoPhi = alphaRhoPhi_;
const volVectorField& U = U_;
const volVectorField& Uc_ =
const tmp<volVectorField> tUc =
refCast<const twoPhaseSystem>(phase_.fluid()).otherPhase(phase_).U();
const volVectorField& Uc = tUc();
const scalar sqrtPi = sqrt(constant::mathematical::pi);
dimensionedScalar ThetaSmall("ThetaSmall", Theta_.dimensions(), 1e-6);
@ -421,7 +424,7 @@ void Foam::RASModels::kineticTheoryModel::correct()
volScalarField J2
(
"J2",
0.25*sqr(beta)*da*magSqr(U - Uc_)
0.25*sqr(beta)*da*magSqr(U - Uc)
/(
max(alpha, residualAlpha_)*rho
*sqrtPi*(ThetaSqrt + ThetaSmallSqrt)

View File

@ -136,8 +136,10 @@ void Foam::twoPhaseSystem::solve()
word alphaScheme("div(phi," + alpha1.name() + ')');
word alpharScheme("div(phir," + alpha1.name() + ')');
const surfaceScalarField& phi1 = phase1_.phi();
const surfaceScalarField& phi2 = phase2_.phi();
const tmp<surfaceScalarField> tphi1(phase1_.phi());
const surfaceScalarField& phi1 = tphi1();
const tmp<surfaceScalarField> tphi2(phase2_.phi());
const surfaceScalarField& phi2 = tphi2();
// Construct the dilatation rate source term
tmp<volScalarField::Internal> tdgdt;

View File

@ -154,7 +154,8 @@ Foam::kineticTheoryModels::frictionalStressModels::Schaeffer::nu
}
const fvPatchList& patches = phase.mesh().boundary();
const volVectorField& U = phase.U();
const tmp<volVectorField> tU(phase.U());
const volVectorField& U = tU();
volScalarField::Boundary& nufBf = nuf.boundaryFieldRef();

View File

@ -80,11 +80,12 @@ Foam::diameterModels::IATEsources::turbulentBreakUp::R() const
volScalarField R = tR();
scalar Cti = Cti_.value();
scalar WeCr = WeCr_.value();
const scalar Cti = Cti_.value();
const scalar WeCr = WeCr_.value();
volScalarField Ut(this->Ut());
volScalarField We(this->We());
const volScalarField& d(iate_.d()());
const tmp<volScalarField> td(iate_.d());
const volScalarField& d = td();
forAll(R, celli)
{