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.
This commit is contained in:
Henry Weller
2016-02-26 17:31:28 +00:00
parent f4ba71ddd0
commit cd852be3da
169 changed files with 511 additions and 477 deletions

View File

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

View File

@ -1,5 +1,5 @@
{
volScalarField& rDeltaT = trDeltaT();
volScalarField& rDeltaT = trDeltaT.ref();
scalar rDeltaTSmoothingCoeff
(

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
{
volScalarField& rDeltaT = trDeltaT();
volScalarField& rDeltaT = trDeltaT.ref();
const dictionary& pimpleDict = pimple.dict();

View File

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

View File

@ -1,8 +1,8 @@
{
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;

View File

@ -1,7 +1,7 @@
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;

View File

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

View File

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