COMP: fix dangling references (gcc13+: -Wdangling-reference)

This commit is contained in:
mattijs
2024-06-20 10:30:42 +01:00
committed by Mark Olesen
parent d300fab63a
commit d8d3e34d5c
9 changed files with 47 additions and 26 deletions

View File

@ -8,11 +8,13 @@
volVectorField& U1 = phase1.URef(); volVectorField& U1 = phase1.URef();
surfaceScalarField& phi1 = phase1.phiRef(); surfaceScalarField& phi1 = phase1.phiRef();
const surfaceScalarField& alphaPhi1 = phase1.alphaPhi(); const tmp<surfaceScalarField> talphaPhi1 = phase1.alphaPhi();
const auto& alphaPhi1 = talphaPhi1();
volVectorField& U2 = phase2.URef(); volVectorField& U2 = phase2.URef();
surfaceScalarField& phi2 = phase2.phiRef(); surfaceScalarField& phi2 = phase2.phiRef();
const surfaceScalarField& alphaPhi2 = phase2.alphaPhi(); const tmp<surfaceScalarField> talphaPhi2 = phase2.alphaPhi();
const auto& alphaPhi2 = talphaPhi2();
surfaceScalarField& phi = fluid.phi(); surfaceScalarField& phi = fluid.phi();

View File

@ -74,8 +74,11 @@ Foam::compressibleInterPhaseTransportModel::compressibleInterPhaseTransportModel
const volScalarField& alpha1(mixture_.alpha1()); const volScalarField& alpha1(mixture_.alpha1());
const volScalarField& alpha2(mixture_.alpha2()); const volScalarField& alpha2(mixture_.alpha2());
const volScalarField& rho1 = mixture_.thermo1().rho(); const tmp<volScalarField> trho1 = mixture_.thermo1().rho();
const volScalarField& rho2 = mixture_.thermo2().rho(); const tmp<volScalarField> trho2 = mixture_.thermo2().rho();
const auto& rho1 = trho1();
const auto& rho2 = trho2();
alphaRhoPhi1_ = alphaRhoPhi1_ =
( (
@ -185,8 +188,8 @@ void Foam::compressibleInterPhaseTransportModel::correctPhasePhi()
{ {
if (twoPhaseTransport_) if (twoPhaseTransport_)
{ {
const volScalarField& rho1 = mixture_.thermo1().rho(); const tmp<volScalarField> rho1 = mixture_.thermo1().rho();
const volScalarField& rho2 = mixture_.thermo2().rho(); const tmp<volScalarField> rho2 = mixture_.thermo2().rho();
alphaRhoPhi1_.ref() = fvc::interpolate(rho1)*alphaPhi10_; alphaRhoPhi1_.ref() = fvc::interpolate(rho1)*alphaPhi10_;
alphaRhoPhi2_.ref() = fvc::interpolate(rho2)*(phi_ - alphaPhi10_); alphaRhoPhi2_.ref() = fvc::interpolate(rho2)*(phi_ - alphaPhi10_);

View File

@ -12,8 +12,11 @@ for (int Ecorr=0; Ecorr<nEnergyCorrectors; Ecorr++)
phaseModel& phase = fluid.anisothermalPhases()[anisothermalPhasei]; phaseModel& phase = fluid.anisothermalPhases()[anisothermalPhasei];
const volScalarField& alpha = phase; const volScalarField& alpha = phase;
const volScalarField& rho = phase.rho(); const tmp<volScalarField> trho = phase.rho();
const volVectorField& U = phase.U(); const tmp<volVectorField> tU = phase.U();
const auto& rho = trho();
const auto& U = tU();
fvScalarMatrix EEqn fvScalarMatrix EEqn
( (

View File

@ -11,7 +11,9 @@
UPtrList<volScalarField>& Y = phase.YActiveRef(); UPtrList<volScalarField>& Y = phase.YActiveRef();
const volScalarField& alpha = phase; const volScalarField& alpha = phase;
const volScalarField& rho = phase.rho(); const tmp<volScalarField> trho = phase.rho();
const auto& rho = trho();
forAll(Y, i) forAll(Y, i)
{ {

View File

@ -14,9 +14,11 @@ PtrList<fvVectorMatrix> UEqns(phases.size());
phaseModel& phase = fluid.movingPhases()[movingPhasei]; phaseModel& phase = fluid.movingPhases()[movingPhasei];
const volScalarField& alpha = phase; const volScalarField& alpha = phase;
const volScalarField& rho = phase.rho(); const tmp<volScalarField> trho = phase.rho();
volVectorField& U = phase.URef(); volVectorField& U = phase.URef();
const auto& rho = trho();
UEqns.set UEqns.set
( (
phase.index(), phase.index(),

View File

@ -17,9 +17,11 @@ PtrList<fvVectorMatrix> UEqns(phases.size());
phaseModel& phase = fluid.movingPhases()[movingPhasei]; phaseModel& phase = fluid.movingPhases()[movingPhasei];
const volScalarField& alpha = phase; const volScalarField& alpha = phase;
const volScalarField& rho = phase.rho(); const tmp<volScalarField> trho = phase.rho();
volVectorField& U = phase.URef(); volVectorField& U = phase.URef();
const auto& rho = trho();
UEqns.set UEqns.set
( (
phase.index(), phase.index(),

View File

@ -6,11 +6,13 @@ const volScalarField& alpha2 = phase2;
volVectorField& U1 = phase1.URef(); volVectorField& U1 = phase1.URef();
surfaceScalarField& phi1 = phase1.phiRef(); surfaceScalarField& phi1 = phase1.phiRef();
const surfaceScalarField& alphaPhi1 = phase1.alphaPhi(); const tmp<surfaceScalarField> talphaPhi1 = phase1.alphaPhi();
const auto& alphaPhi1 = talphaPhi1();
volVectorField& U2 = phase2.URef(); volVectorField& U2 = phase2.URef();
surfaceScalarField& phi2 = phase2.phiRef(); surfaceScalarField& phi2 = phase2.phiRef();
const surfaceScalarField& alphaPhi2 = phase2.alphaPhi(); const tmp<surfaceScalarField> talphaPhi2 = phase2.alphaPhi();
const auto& alphaPhi2 = talphaPhi2();
surfaceScalarField& phi = fluid.phi(); surfaceScalarField& phi = fluid.phi();

View File

@ -743,12 +743,12 @@ Foam::label Foam::cellShapeControlMesh::estimateCellCount
cit->vertex(3)->point() cit->vertex(3)->point()
); );
pointFromPoint centre = topoint(CGAL::centroid(tet)); const auto tetCentre = CGAL::centroid(tet);
if if
( (
Pstream::parRun() UPstream::parRun()
&& !decomposition().positionOnThisProcessor(centre) && !decomposition().positionOnThisProcessor(topoint(tetCentre))
) )
{ {
continue; continue;

View File

@ -176,7 +176,7 @@ autoPtr<labelIOList> procAddressing
const objectRegistry& procRegistry, const objectRegistry& procRegistry,
const word& name, const word& name,
const word& instance, const word& instance,
const word& local = fvMesh::meshSubDir const word& local = polyMesh::meshSubDir
) )
{ {
return autoPtr<labelIOList>::New return autoPtr<labelIOList>::New
@ -218,17 +218,22 @@ const labelIOList& procAddressing
PtrList<labelIOList>& procAddressingList PtrList<labelIOList>& procAddressingList
) )
{ {
const fvMesh& procMesh = procMeshList[proci]; const auto& procMesh = procMeshList[proci];
if (!procAddressingList.set(proci)) return procAddressingList.try_emplace
{
procAddressingList.set
( (
proci, proci,
procAddressing(procMesh, name, procMesh.facesInstance()) IOobject
(
name,
procMesh.facesInstance(),
polyMesh::meshSubDir,
procMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
)
); );
}
return procAddressingList[proci];
} }