Commit 78590832 authored by Henry Weller's avatar Henry Weller
Browse files

OpenFOAM: Updated all libraries, solvers and utilities to use the new const-safe tmp

The deprecated non-const tmp functionality is now on the compiler switch
NON_CONST_TMP which can be enabled by adding -DNON_CONST_TMP to EXE_INC
in the Make/options file.  However, it is recommended to upgrade all
code to the new safer tmp by using the '.ref()' member function rather
than the non-const '()' dereference operator when non-const access to
the temporary object is required.

Please report any problems on Mantis.

Henry G. Weller
CFD Direct.
parent 49c54e90
......@@ -70,7 +70,7 @@ Foam::tmp<Foam::volScalarField> Foam::XiGModels::basicSubGrid::G() const
const volScalarField& Lobs = db.lookupObject<volScalarField>("Lobs");
tmp<volScalarField> tGtot = XiGModel_->G();
volScalarField& Gtot = tGtot();
volScalarField& Gtot = tGtot.ref();
const scalarField Cw = pow(Su_.mesh().V(), 2.0/3.0);
scalarField N(Nv.internalField()*Cw);
......
......@@ -113,7 +113,7 @@ Foam::tmp<Foam::volSymmTensorField> Foam::PDRDragModels::basic::Dcu() const
)
);
volSymmTensorField& DragDcu = tDragDcu();
volSymmTensorField& DragDcu = tDragDcu.ref();
if (on_)
{
......@@ -147,7 +147,7 @@ Foam::tmp<Foam::volScalarField> Foam::PDRDragModels::basic::Gk() const
)
);
volScalarField& Gk = tGk();
volScalarField& Gk = tGk.ref();
if (on_)
{
......
......@@ -161,9 +161,9 @@ void PDRkEpsilon::correct()
- fvm::Sp(C2_*betav*rho_*epsilon_/k_, epsilon_)
);
epsEqn().relax();
epsEqn.ref().relax();
epsEqn().boundaryManipulate(epsilon_.boundaryField());
epsEqn.ref().boundaryManipulate(epsilon_.boundaryField());
solve(epsEqn);
bound(epsilon_, epsilonMin_);
......@@ -182,7 +182,7 @@ void PDRkEpsilon::correct()
- fvm::Sp(betav*rho_*epsilon_/k_, k_)
);
kEqn().relax();
kEqn.ref().relax();
solve(kEqn);
bound(k_, kMin_);
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -108,7 +108,7 @@ Foam::tmp<Foam::volScalarField> Foam::XiEqModels::SCOPEXiEq::XiEq() const
dimensionedScalar("XiEq", dimless, 0.0)
)
);
volScalarField& xieq = tXiEq();
volScalarField& xieq = tXiEq.ref();
forAll(xieq, celli)
{
......
......@@ -113,7 +113,7 @@ Foam::XiEqModel::calculateSchelkinEffect(const scalar uPrimeCoef) const
dimensionedScalar("zero", Nv.dimensions(), 0.0)
)
);
volScalarField& N = tN();
volScalarField& N = tN.ref();
N.internalField() = Nv.internalField()*pow(mesh.V(), 2.0/3.0);
volSymmTensorField ns
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -259,7 +259,7 @@ Foam::tmp<Foam::volScalarField> Foam::laminarFlameSpeedModels::SCOPE::Su0pTphi
)
);
volScalarField& Su0 = tSu0();
volScalarField& Su0 = tSu0.ref();
forAll(Su0, celli)
{
......@@ -306,7 +306,7 @@ Foam::tmp<Foam::volScalarField> Foam::laminarFlameSpeedModels::SCOPE::Su0pTphi
)
);
volScalarField& Su0 = tSu0();
volScalarField& Su0 = tSu0.ref();
forAll(Su0, celli)
{
......@@ -358,7 +358,7 @@ Foam::tmp<Foam::volScalarField> Foam::laminarFlameSpeedModels::SCOPE::Ma
)
);
volScalarField& ma = tMa();
volScalarField& ma = tMa.ref();
forAll(ma, celli)
{
......
......@@ -2,7 +2,7 @@
MRF.correctBoundaryVelocity(U);
tmp<fvVectorMatrix> UEqn
tmp<fvVectorMatrix> tUEqn
(
fvm::ddt(rho, U) + fvm::div(phi, U)
+ MRF.DDt(rho, U)
......@@ -10,14 +10,15 @@ tmp<fvVectorMatrix> UEqn
==
fvOptions(rho, U)
);
fvVectorMatrix& UEqn = tUEqn.ref();
UEqn().relax();
UEqn.relax();
fvOptions.constrain(UEqn());
fvOptions.constrain(UEqn);
if (pimple.momentumPredictor())
{
solve(UEqn() == -fvc::grad(p));
solve(UEqn == -fvc::grad(p));
fvOptions.correct(U);
K = 0.5*magSqr(U);
......
......@@ -3,13 +3,13 @@ rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
rho.relax();
volScalarField rAU(1.0/UEqn().A());
volScalarField rAU(1.0/UEqn.A());
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn().H(), U, p));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
if (pimple.nCorrPISO() <= 1)
{
UEqn.clear();
tUEqn.clear();
}
if (pimple.transonic())
......
......@@ -3,13 +3,13 @@ rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
rho.relax();
volScalarField rAU(1.0/UEqn().A());
volScalarField rAtU(1.0/(1.0/rAU - UEqn().H1()));
volVectorField HbyA(constrainHbyA(rAU*UEqn().H(), U, p));
volScalarField rAU(1.0/UEqn.A());
volScalarField rAtU(1.0/(1.0/rAU - UEqn.H1()));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
if (pimple.nCorrPISO() <= 1)
{
UEqn.clear();
tUEqn.clear();
}
if (pimple.transonic())
......
......@@ -5,9 +5,9 @@
// pressure solution - done in 2 parts. Part 1:
thermo.rho() -= psi*p;
volScalarField rAU(1.0/UEqn().A());
volScalarField rAU(1.0/UEqn.A());
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn().H(), U, p));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
if (pimple.transonic())
{
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
{
volScalarField& rDeltaT = trDeltaT();
volScalarField& rDeltaT = trDeltaT.ref();
const dictionary& pimpleDict = pimple.dict();
......
......@@ -22,7 +22,7 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> interpolate
)
);
GeometricField<Type, fvsPatchField, surfaceMesh>& sf = tsf();
GeometricField<Type, fvsPatchField, surfaceMesh>& sf = tsf.ref();
sf.rename(vf.name() + '_' + dir.name());
......
{
volScalarField& rDeltaT = trDeltaT();
volScalarField& rDeltaT = trDeltaT.ref();
scalar rDeltaTSmoothingCoeff
(
......
......@@ -2,7 +2,7 @@
MRF.correctBoundaryVelocity(U);
tmp<fvVectorMatrix> UEqn
tmp<fvVectorMatrix> tUEqn
(
fvm::ddt(rho, U) + fvm::div(phi, U)
+ MRF.DDt(rho, U)
......@@ -10,14 +10,15 @@ tmp<fvVectorMatrix> UEqn
==
fvOptions(rho, U)
);
fvVectorMatrix& UEqn = tUEqn.ref();
UEqn().relax();
UEqn.relax();
fvOptions.constrain(UEqn());
fvOptions.constrain(UEqn);
if (pimple.momentumPredictor())
{
solve(UEqn() == -fvc::grad(p));
solve(UEqn == -fvc::grad(p));
fvOptions.correct(U);
K = 0.5*magSqr(U);
......
......@@ -3,13 +3,13 @@ rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
rho.relax();
volScalarField rAU(1.0/UEqn().A());
volScalarField rAU(1.0/UEqn.A());
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn().H(), U, p));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
if (pimple.nCorrPISO() <= 1)
{
UEqn.clear();
tUEqn.clear();
}
if (pimple.transonic())
......
......@@ -3,13 +3,13 @@ rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
rho.relax();
volScalarField rAU(1.0/UEqn().A());
volScalarField rAtU(1.0/(1.0/rAU - UEqn().H1()));
volVectorField HbyA(constrainHbyA(rAU*UEqn().H(), U, p));
volScalarField rAU(1.0/UEqn.A());
volScalarField rAtU(1.0/(1.0/rAU - UEqn.H1()));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
if (pimple.nCorrPISO() <= 1)
{
UEqn.clear();
tUEqn.clear();
}
if (pimple.transonic())
......
......@@ -3,13 +3,13 @@ rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
rho.relax();
volScalarField rAU(1.0/UEqn().A());
volScalarField rAU(1.0/UEqn.A());
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn().H(), U, p));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
if (pimple.nCorrPISO() <= 1)
{
UEqn.clear();
tUEqn.clear();
}
if (pimple.transonic())
......
{
volScalarField& rDeltaT = trDeltaT();
volScalarField& rDeltaT = trDeltaT.ref();
const dictionary& pimpleDict = pimple.dict();
......
......@@ -2,7 +2,7 @@
MRF.correctBoundaryVelocity(U);
tmp<fvVectorMatrix> UEqn
tmp<fvVectorMatrix> tUEqn
(
fvm::div(phi, U)
+ MRF.DDt(rho, U)
......@@ -10,11 +10,12 @@
==
fvOptions(rho, U)
);
fvVectorMatrix& UEqn = tUEqn.ref();
UEqn().relax();
UEqn.relax();
fvOptions.constrain(UEqn());
fvOptions.constrain(UEqn);
solve(UEqn() == -fvc::grad(p));
solve(UEqn == -fvc::grad(p));
fvOptions.correct(U);
{
volScalarField rAU(1.0/UEqn().A());
volScalarField rAU(1.0/UEqn.A());
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn().H(), U, p));
UEqn.clear();
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
tUEqn.clear();
bool closedVolume = false;
......
volScalarField rAU(1.0/UEqn().A());
volScalarField rAtU(1.0/(1.0/rAU - UEqn().H1()));
volVectorField HbyA(constrainHbyA(rAU*UEqn().H(), U, p));
UEqn.clear();
volScalarField rAU(1.0/UEqn.A());
volScalarField rAtU(1.0/(1.0/rAU - UEqn.H1()));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
tUEqn.clear();
bool closedVolume = false;
......
......@@ -2,7 +2,7 @@
MRF.correctBoundaryVelocity(U);
tmp<fvVectorMatrix> UEqn
tmp<fvVectorMatrix> tUEqn
(
fvm::div(phi, U)
+ MRF.DDt(rho, U)
......@@ -10,8 +10,9 @@
==
fvOptions(rho, U)
);
fvVectorMatrix& UEqn = tUEqn.ref();
UEqn().relax();
UEqn.relax();
// Include the porous media resistance and solve the momentum equation
// either implicit in the tensorial resistance or transport using by
......@@ -22,18 +23,18 @@
if (pressureImplicitPorosity)
{
tmp<volTensorField> tTU = tensor(I)*UEqn().A();
pZones.addResistance(UEqn(), tTU());
tmp<volTensorField> tTU = tensor(I)*UEqn.A();
pZones.addResistance(UEqn, tTU.ref());
trTU = inv(tTU());
trTU().rename("rAU");
trTU.ref().rename("rAU");
fvOptions.constrain(UEqn());
fvOptions.constrain(UEqn);
volVectorField gradp(fvc::grad(p));
for (int UCorr=0; UCorr<nUCorr; UCorr++)
{
U = trTU() & (UEqn().H() - gradp);
U = trTU() & (UEqn.H() - gradp);
}
U.correctBoundaryConditions();
......@@ -41,14 +42,14 @@
}
else
{
pZones.addResistance(UEqn());
pZones.addResistance(UEqn);
fvOptions.constrain(UEqn());
fvOptions.constrain(UEqn);
solve(UEqn() == -fvc::grad(p));
solve(UEqn == -fvc::grad(p));
fvOptions.correct(U);
trAU = 1.0/UEqn().A();
trAU().rename("rAU");
trAU = 1.0/UEqn.A();
trAU.ref().rename("rAU");
}
......@@ -4,15 +4,15 @@
tmp<volVectorField> tHbyA;
if (pressureImplicitPorosity)
{
tHbyA = constrainHbyA(trTU()&UEqn().H(), U, p);
tHbyA = constrainHbyA(trTU()&UEqn.H(), U, p);
}
else
{
tHbyA = constrainHbyA(trAU()*UEqn().H(), U, p);
tHbyA = constrainHbyA(trAU()*UEqn.H(), U, p);
}
volVectorField& HbyA = tHbyA();
volVectorField& HbyA = tHbyA.ref();
UEqn.clear();
tUEqn.clear();
bool closedVolume = false;
......@@ -51,13 +51,15 @@
);
}
tpEqn().setReference(pRefCell, pRefValue);
fvScalarMatrix& pEqn = tpEqn.ref();
tpEqn().solve();
pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();
if (simple.finalNonOrthogonalIter())
{
phi = phiHbyA - tpEqn().flux();
phi = phiHbyA - pEqn.flux();
}
}
......
......@@ -2,7 +2,7 @@
MRF.correctBoundaryVelocity(U);
tmp<fvVectorMatrix> UEqn
tmp<fvVectorMatrix> tUEqn
(
fvm::div(phi, U)
+ MRF.DDt(U)
......@@ -10,16 +10,17 @@
==
fvOptions(U)
);
fvVectorMatrix& UEqn = tUEqn.ref();
UEqn().relax();
UEqn.relax();
fvOptions.constrain(UEqn());
fvOptions.constrain(UEqn);
if (simple.momentumPredictor())
{
solve
(
UEqn()
UEqn
==
fvc::reconstruct
(
......
{
volScalarField rAU("rAU", 1.0/UEqn().A());
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn().H(), U, p_rgh));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh));
UEqn.clear();
tUEqn.clear();
surfaceScalarField phig(-rAUf*ghf*fvc::snGrad(rhok)*mesh.magSf());
......
......@@ -2,7 +2,7 @@
MRF.correctBoundaryVelocity(U);
tmp<fvVectorMatrix> UEqn
tmp<fvVectorMatrix> tUEqn
(
fvm::div(phi, U)
+ MRF.DDt(rho, U)
......@@ -10,16 +10,17 @@
==
fvOptions(rho, U)
);
fvVectorMatrix& UEqn = tUEqn.ref();
UEqn().relax();
UEqn.relax();
fvOptions.constrain(UEqn());
fvOptions.constrain(UEqn);
if (simple.momentumPredictor())
{
solve
(
UEqn()
UEqn
==
fvc::reconstruct
(
......
......@@ -2,10 +2,10 @@
rho = thermo.rho();
rho.relax();
volScalarField rAU("rAU", 1.0/UEqn().A());
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn().H(), U, p_rgh));
UEqn.clear();
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh));
tUEqn.clear();