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();
surfaceScalarField& phi1 = phase1.phiRef();
const surfaceScalarField& alphaPhi1 = phase1.alphaPhi();
const tmp<surfaceScalarField> talphaPhi1 = phase1.alphaPhi();
const auto& alphaPhi1 = talphaPhi1();
volVectorField& U2 = phase2.URef();
surfaceScalarField& phi2 = phase2.phiRef();
const surfaceScalarField& alphaPhi2 = phase2.alphaPhi();
const tmp<surfaceScalarField> talphaPhi2 = phase2.alphaPhi();
const auto& alphaPhi2 = talphaPhi2();
surfaceScalarField& phi = fluid.phi();

View File

@ -74,8 +74,11 @@ Foam::compressibleInterPhaseTransportModel::compressibleInterPhaseTransportModel
const volScalarField& alpha1(mixture_.alpha1());
const volScalarField& alpha2(mixture_.alpha2());
const volScalarField& rho1 = mixture_.thermo1().rho();
const volScalarField& rho2 = mixture_.thermo2().rho();
const tmp<volScalarField> trho1 = mixture_.thermo1().rho();
const tmp<volScalarField> trho2 = mixture_.thermo2().rho();
const auto& rho1 = trho1();
const auto& rho2 = trho2();
alphaRhoPhi1_ =
(
@ -185,8 +188,8 @@ void Foam::compressibleInterPhaseTransportModel::correctPhasePhi()
{
if (twoPhaseTransport_)
{
const volScalarField& rho1 = mixture_.thermo1().rho();
const volScalarField& rho2 = mixture_.thermo2().rho();
const tmp<volScalarField> rho1 = mixture_.thermo1().rho();
const tmp<volScalarField> rho2 = mixture_.thermo2().rho();
alphaRhoPhi1_.ref() = fvc::interpolate(rho1)*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];
const volScalarField& alpha = phase;
const volScalarField& rho = phase.rho();
const volVectorField& U = phase.U();
const tmp<volScalarField> trho = phase.rho();
const tmp<volVectorField> tU = phase.U();
const auto& rho = trho();
const auto& U = tU();
fvScalarMatrix EEqn
(

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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