ENH: use tmp field factory methods [12] (#2723)

- applications
This commit is contained in:
Mark Olesen 2023-10-08 18:35:04 +02:00
parent ec2b1be8c5
commit 8b73d06898
32 changed files with 171 additions and 387 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -93,24 +94,14 @@ Foam::PDRDragModels::basic::~basic()
Foam::tmp<Foam::volSymmTensorField> Foam::PDRDragModels::basic::Dcu() const Foam::tmp<Foam::volSymmTensorField> Foam::PDRDragModels::basic::Dcu() const
{ {
tmp<volSymmTensorField> tDragDcu auto tDragDcu = volSymmTensorField::New
( (
new volSymmTensorField "tDragDcu",
( IOobject::NO_REGISTER,
IOobject U_.mesh(),
( dimensionedSymmTensor(dimMass/dimTime/dimVolume, Zero)
"tDragDcu",
U_.mesh().time().constant(),
U_.mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
U_.mesh(),
dimensionedSymmTensor(dimMass/dimTime/dimVolume, Zero)
)
); );
auto& DragDcu = tDragDcu.ref();
volSymmTensorField& DragDcu = tDragDcu.ref();
if (on_) if (on_)
{ {
@ -127,24 +118,14 @@ Foam::tmp<Foam::volSymmTensorField> Foam::PDRDragModels::basic::Dcu() const
Foam::tmp<Foam::volScalarField> Foam::PDRDragModels::basic::Gk() const Foam::tmp<Foam::volScalarField> Foam::PDRDragModels::basic::Gk() const
{ {
tmp<volScalarField> tGk auto tGk = volScalarField::New
( (
new volScalarField "tGk",
( IOobject::NO_REGISTER,
IOobject U_.mesh(),
( dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero)
"tGk",
U_.mesh().time().constant(),
U_.mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
U_.mesh(),
dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero)
)
); );
auto& Gk = tGk.ref();
volScalarField& Gk = tGk.ref();
if (on_) if (on_)
{ {

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -93,23 +94,14 @@ Foam::tmp<Foam::volScalarField> Foam::XiEqModels::SCOPEXiEq::XiEq() const
volScalarField K(0.157*upBySu/sqrt(Rl)); volScalarField K(0.157*upBySu/sqrt(Rl));
volScalarField Ma(MaModel.Ma()); volScalarField Ma(MaModel.Ma());
tmp<volScalarField> tXiEq auto tXiEq = volScalarField::New
( (
new volScalarField "XiEq",
( IOobject::NO_REGISTER,
IOobject epsilon.mesh(),
( dimensionedScalar(dimless, Zero)
"XiEq",
epsilon.time().timeName(),
epsilon.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
epsilon.mesh(),
dimensionedScalar(dimless, Zero)
)
); );
volScalarField& xieq = tXiEq.ref(); auto& xieq = tXiEq.ref();
forAll(xieq, celli) forAll(xieq, celli)
{ {

View File

@ -78,11 +78,10 @@ bool Foam::XiEqModel::read(const dictionary& XiEqProperties)
void Foam::XiEqModel::writeFields() const void Foam::XiEqModel::writeFields() const
{ {
//***HGW It is not clear why B is written here //***HGW It is not clear why B is written here
if (Su_.mesh().foundObject<volSymmTensorField>("B")) const auto* B = Su_.mesh().cfindObject<volSymmTensorField>("B");
if (B)
{ {
const volSymmTensorField& B = B->write();
Su_.mesh().lookupObject<volSymmTensorField>("B");
B.write();
} }
} }
@ -98,39 +97,26 @@ Foam::XiEqModel::calculateSchelkinEffect(const scalar uPrimeCoef) const
const volSymmTensorField& nsv = const volSymmTensorField& nsv =
mesh.lookupObject<volSymmTensorField>("nsv"); mesh.lookupObject<volSymmTensorField>("nsv");
tmp<volScalarField> tN auto tN = volScalarField::New
( (
new volScalarField "tN",
( IOobject::NO_REGISTER,
IOobject mesh,
( dimensionedScalar(Nv.dimensions(), Zero)
"tN",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
mesh,
dimensionedScalar(Nv.dimensions(), Zero)
)
); );
volScalarField& N = tN.ref(); auto& N = tN.ref();
N.primitiveFieldRef() = Nv.primitiveField()*pow(mesh.V(), 2.0/3.0); N.primitiveFieldRef() = Nv.primitiveField()*pow(mesh.V(), 2.0/3.0);
volSymmTensorField ns auto tns = volSymmTensorField::New
( (
IOobject "tns",
( IOobject::NO_REGISTER,
"tns",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh, mesh,
dimensionedSymmTensor(nsv.dimensions(), Zero) dimensionedSymmTensor(nsv.dimensions(), Zero)
); );
auto& ns = tns.ref();
ns.primitiveFieldRef() = nsv.primitiveField()*pow(mesh.V(), 2.0/3.0); ns.primitiveFieldRef() = nsv.primitiveField()*pow(mesh.V(), 2.0/3.0);
const volVectorField Uhat const volVectorField Uhat

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -255,24 +256,14 @@ Foam::tmp<Foam::volScalarField> Foam::laminarFlameSpeedModels::SCOPE::Su0pTphi
scalar phi scalar phi
) const ) const
{ {
tmp<volScalarField> tSu0 auto tSu0 = volScalarField::New
( (
new volScalarField "Su0",
( IOobject::NO_REGISTER,
IOobject p.mesh(),
( dimensionedScalar(dimVelocity, Zero)
"Su0",
p.time().timeName(),
p.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
p.mesh(),
dimensionedScalar(dimVelocity, Zero)
)
); );
auto& Su0 = tSu0.ref();
volScalarField& Su0 = tSu0.ref();
forAll(Su0, celli) forAll(Su0, celli)
{ {
@ -304,24 +295,14 @@ Foam::tmp<Foam::volScalarField> Foam::laminarFlameSpeedModels::SCOPE::Su0pTphi
const volScalarField& phi const volScalarField& phi
) const ) const
{ {
tmp<volScalarField> tSu0 auto tSu0 = volScalarField::New
( (
new volScalarField "Su0",
( IOobject::NO_REGISTER,
IOobject p.mesh(),
( dimensionedScalar(dimVelocity, Zero)
"Su0",
p.time().timeName(),
p.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
p.mesh(),
dimensionedScalar(dimVelocity, Zero)
)
); );
auto& Su0 = tSu0.ref();
volScalarField& Su0 = tSu0.ref();
forAll(Su0, celli) forAll(Su0, celli)
{ {
@ -358,24 +339,14 @@ Foam::tmp<Foam::volScalarField> Foam::laminarFlameSpeedModels::SCOPE::Ma
const volScalarField& phi const volScalarField& phi
) const ) const
{ {
tmp<volScalarField> tMa auto tMa = volScalarField::New
( (
new volScalarField "Ma",
( IOobject::NO_REGISTER,
IOobject phi.mesh(),
( dimensionedScalar(dimless, Zero)
"Ma",
phi.time().timeName(),
phi.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
phi.mesh(),
dimensionedScalar(dimless, Zero)
)
); );
auto& ma = tMa.ref();
volScalarField& ma = tMa.ref();
forAll(ma, celli) forAll(ma, celli)
{ {
@ -418,21 +389,12 @@ Foam::laminarFlameSpeedModels::SCOPE::Ma() const
{ {
const fvMesh& mesh = psiuReactionThermo_.p().mesh(); const fvMesh& mesh = psiuReactionThermo_.p().mesh();
return tmp<volScalarField> return volScalarField::New
( (
new volScalarField "Ma",
( IOobject::NO_REGISTER,
IOobject mesh,
( dimensionedScalar("Ma", dimless, Ma(equivalenceRatio_))
"Ma",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("Ma", dimless, Ma(equivalenceRatio_))
)
); );
} }
} }

View File

@ -3,12 +3,7 @@ if (nAlphaSubCycles > 1)
dimensionedScalar totalDeltaT = runTime.deltaT(); dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum surfaceScalarField rhoPhiSum
( (
IOobject mesh.newIOobject("rhoPhiSum"),
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh, mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero) dimensionedScalar(rhoPhi.dimensions(), Zero)
); );

View File

@ -3,12 +3,7 @@ if (nAlphaSubCycles > 1)
dimensionedScalar totalDeltaT = runTime.deltaT(); dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum surfaceScalarField rhoPhiSum
( (
IOobject mesh.newIOobject("rhoPhiSum"),
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh, mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero) dimensionedScalar(rhoPhi.dimensions(), Zero)
); );

View File

@ -4,26 +4,19 @@ if (nAlphaSubCycles > 1)
{ {
dimensionedScalar totalDeltaT = runTime.deltaT(); dimensionedScalar totalDeltaT = runTime.deltaT();
talphaPhi1 = new surfaceScalarField talphaPhi1.reset
( (
IOobject new surfaceScalarField
( (
"alphaPhi1", mesh.newIOobject("alphaPhi1"),
runTime.timeName(), mesh,
mesh dimensionedScalar(alphaPhi10.dimensions(), Zero)
), )
mesh,
dimensionedScalar(alphaPhi10.dimensions(), Zero)
); );
surfaceScalarField rhoPhiSum surfaceScalarField rhoPhiSum
( (
IOobject mesh.newIOobject("rhoPhiSum"),
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh, mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero) dimensionedScalar(rhoPhi.dimensions(), Zero)
); );

View File

@ -13,26 +13,19 @@ if (nAlphaSubCycles > 1)
{ {
dimensionedScalar totalDeltaT = runTime.deltaT(); dimensionedScalar totalDeltaT = runTime.deltaT();
talphaPhi1 = new surfaceScalarField talphaPhi1.reset
( (
IOobject new surfaceScalarField
( (
"alphaPhi1", mesh.newIOobject("alphaPhi1"),
runTime.timeName(), mesh,
mesh dimensionedScalar(alphaPhi10.dimensions(), Zero)
), )
mesh,
dimensionedScalar(alphaPhi10.dimensions(), Zero)
); );
surfaceScalarField rhoPhiSum surfaceScalarField rhoPhiSum
( (
IOobject mesh.newIOobject("rhoPhiSum"),
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh, mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero) dimensionedScalar(rhoPhi.dimensions(), Zero)
); );

View File

@ -99,7 +99,8 @@ Foam::multiphaseMixtureThermo::multiphaseMixtureThermo
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE,
IOobject::REGISTER
), ),
mesh_, mesh_,
dimensionedScalar(dimless, Zero) dimensionedScalar(dimless, Zero)
@ -998,19 +999,12 @@ Foam::tmp<Foam::volScalarField> Foam::multiphaseMixtureThermo::K
Foam::tmp<Foam::volScalarField> Foam::tmp<Foam::volScalarField>
Foam::multiphaseMixtureThermo::nearInterface() const Foam::multiphaseMixtureThermo::nearInterface() const
{ {
tmp<volScalarField> tnearInt auto tnearInt = volScalarField::New
( (
new volScalarField "nearInterface",
( IOobject::NO_REGISTER,
IOobject mesh_,
( dimensionedScalar(dimless, Zero)
"nearInterface",
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar(dimless, Zero)
)
); );
for (const phaseModel& phase : phases_) for (const phaseModel& phase : phases_)

View File

@ -18,12 +18,7 @@
dimensionedScalar totalDeltaT = runTime.deltaT(); dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField alphaPhiSum surfaceScalarField alphaPhiSum
( (
IOobject mesh.newIOobject("alphaPhiSum"),
(
"alphaPhiSum",
runTime.timeName(),
mesh
),
mesh, mesh,
dimensionedScalar(phi.dimensions(), Zero) dimensionedScalar(phi.dimensions(), Zero)
); );

View File

@ -158,13 +158,11 @@ Foam::tmp<Foam::volSymmTensorField> Foam::relativeVelocityModel::tauDm() const
// Calculate the relative velocity of the continuous phase w.r.t the mean // Calculate the relative velocity of the continuous phase w.r.t the mean
volVectorField Ucm(betad*Udm_/betac); volVectorField Ucm(betad*Udm_/betac);
return tmp<volSymmTensorField> return volSymmTensorField::New
( (
new volSymmTensorField "tauDm",
( IOobject::NO_REGISTER,
"tauDm", betad*sqr(Udm_) + betac*sqr(Ucm)
betad*sqr(Udm_) + betac*sqr(Ucm)
)
); );
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2022 OpenCFD Ltd. Copyright (C) 2017-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -407,7 +407,8 @@ Foam::radiation::laserDTRM::laserDTRM(const volScalarField& T)
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE,
IOobject::REGISTER
), ),
mesh_, mesh_,
dimensionedScalar(dimPower/dimVolume, Zero) dimensionedScalar(dimPower/dimVolume, Zero)
@ -504,7 +505,8 @@ Foam::radiation::laserDTRM::laserDTRM
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE,
IOobject::REGISTER
), ),
mesh_, mesh_,
dimensionedScalar(dimPower/pow3(dimLength), Zero) dimensionedScalar(dimPower/pow3(dimLength), Zero)
@ -535,42 +537,23 @@ Foam::label Foam::radiation::laserDTRM::nBands() const
void Foam::radiation::laserDTRM::calculate() void Foam::radiation::laserDTRM::calculate()
{ {
tmp<volScalarField> treflectingCells auto treflectingCells = volScalarField::New
( (
new volScalarField "reflectingCellsVol",
( IOobject::NO_REGISTER,
IOobject mesh_,
( dimensionedScalar("zero", dimless, -1)
"reflectingCellsVol",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimless, -1)
)
); );
volScalarField& reflectingCellsVol = treflectingCells.ref(); auto& reflectingCellsVol = treflectingCells.ref();
auto tnHat = volVectorField::New
tmp<volVectorField> tnHat
( (
new volVectorField "nHat",
( IOobject::NO_REGISTER,
IOobject mesh_,
( dimensionedVector(dimless, Zero)
"nHat",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedVector(dimless, Zero)
)
); );
volVectorField& nHat = tnHat.ref(); auto& nHat = tnHat.ref();
// Reset the field // Reset the field
@ -686,9 +669,9 @@ void Foam::radiation::laserDTRM::calculate()
globalIndex::gatherInplaceOp(lines); globalIndex::gatherInplaceOp(lines);
if (Pstream::master()) if (UPstream::master())
{ {
OBJstream os(type() + ":particlePath.obj"); OBJstream os(type() + "-particlePath.obj");
for (label pointi = 0; pointi < lines.size(); pointi += 2) for (label pointi = 0; pointi < lines.size(); pointi += 2)
{ {

View File

@ -88,25 +88,14 @@ Foam::radiation::localDensityAbsorptionEmission::localDensityAbsorptionEmission
Foam::tmp<Foam::volScalarField> Foam::tmp<Foam::volScalarField>
Foam::radiation::localDensityAbsorptionEmission::aCont(const label bandI) const Foam::radiation::localDensityAbsorptionEmission::aCont(const label bandI) const
{ {
tmp<volScalarField> ta auto ta = volScalarField::New
( (
new volScalarField "a",
( IOobject::NO_REGISTER,
IOobject mesh_,
( dimensionedScalar(inv(dimLength), Zero)
"a",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
mesh_,
dimensionedScalar(inv(dimLength), Zero)
)
); );
auto& a = ta.ref();
volScalarField& a = ta.ref();
forAll(alphaNames_, i) forAll(alphaNames_, i)
{ {
@ -121,25 +110,14 @@ Foam::radiation::localDensityAbsorptionEmission::aCont(const label bandI) const
Foam::tmp<Foam::volScalarField> Foam::tmp<Foam::volScalarField>
Foam::radiation::localDensityAbsorptionEmission::eCont(const label bandI) const Foam::radiation::localDensityAbsorptionEmission::eCont(const label bandI) const
{ {
tmp<volScalarField> te auto te = volScalarField::New
( (
new volScalarField "e",
( IOobject::NO_REGISTER,
IOobject mesh_,
( dimensionedScalar(inv(dimLength), Zero)
"e",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
mesh_,
dimensionedScalar(inv(dimLength), Zero)
)
); );
auto& e = te.ref();
volScalarField& e = te.ref();
forAll(alphaNames_, i) forAll(alphaNames_, i)
{ {
@ -154,22 +132,12 @@ Foam::radiation::localDensityAbsorptionEmission::eCont(const label bandI) const
Foam::tmp<Foam::volScalarField> Foam::tmp<Foam::volScalarField>
Foam::radiation::localDensityAbsorptionEmission::ECont(const label bandI) const Foam::radiation::localDensityAbsorptionEmission::ECont(const label bandI) const
{ {
tmp<volScalarField> tE auto tE = volScalarField::New
( (
new volScalarField "E",
( IOobject::NO_REGISTER,
IOobject mesh_,
( dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero)
"E",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
mesh_,
dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero)
)
); );
scalarField& E = tE.ref().primitiveFieldRef(); scalarField& E = tE.ref().primitiveFieldRef();

View File

@ -171,16 +171,8 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::TSource() const
const volScalarField& T = mesh_.lookupObject<volScalarField>("T"); const volScalarField& T = mesh_.lookupObject<volScalarField>("T");
tmp<fvScalarMatrix> tTSource auto tTSource = tmp<fvScalarMatrix>::New(T, dimEnergy/dimTime);
( auto& TSource = tTSource.ref();
new fvScalarMatrix
(
T,
dimEnergy/dimTime
)
);
fvScalarMatrix& TSource = tTSource.ref();
const twoPhaseMixtureEThermo& thermo = const twoPhaseMixtureEThermo& thermo =
refCast<const twoPhaseMixtureEThermo> refCast<const twoPhaseMixtureEThermo>

View File

@ -382,7 +382,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::kappaEff
const volScalarField& kappat const volScalarField& kappat
) const ) const
{ {
tmp<Foam::volScalarField> kappaEff(kappa() + kappat); tmp<volScalarField> kappaEff(kappa() + kappat);
kappaEff.ref().rename("kappaEff"); kappaEff.ref().rename("kappaEff");
return kappaEff; return kappaEff;
} }

View File

@ -3,12 +3,7 @@ if (nAlphaSubCycles > 1)
dimensionedScalar totalDeltaT = runTime.deltaT(); dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum surfaceScalarField rhoPhiSum
( (
IOobject mesh.newIOobject("rhoPhiSum"),
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh, mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero) dimensionedScalar(rhoPhi.dimensions(), Zero)
); );

View File

@ -32,12 +32,7 @@ if (nAlphaSubCycles > 1)
dimensionedScalar totalDeltaT = runTime.deltaT(); dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum surfaceScalarField rhoPhiSum
( (
IOobject mesh.newIOobject("rhoPhiSum"),
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh, mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero) dimensionedScalar(rhoPhi.dimensions(), Zero)
); );

View File

@ -21,12 +21,7 @@
dimensionedScalar totalDeltaT = runTime.deltaT(); dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum surfaceScalarField rhoPhiSum
( (
IOobject mesh.newIOobject("rhoPhiSum"),
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh, mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero) dimensionedScalar(rhoPhi.dimensions(), Zero)
); );

View File

@ -50,7 +50,8 @@
runTime.timeName(), runTime.timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE,
IOobject::REGISTER
), ),
mesh, mesh,
dimensionedScalar(dimVelocity*dimArea, Zero) dimensionedScalar(dimVelocity*dimArea, Zero)

View File

@ -68,8 +68,9 @@ Foam::multiphaseMixture::multiphaseMixture
"transportProperties", "transportProperties",
U.time().constant(), U.time().constant(),
U.db(), U.db(),
IOobject::MUST_READ_IF_MODIFIED, IOobject::READ_MODIFIED,
IOobject::NO_WRITE IOobject::NO_WRITE,
IOobject::REGISTER
) )
), ),
@ -85,9 +86,7 @@ Foam::multiphaseMixture::multiphaseMixture
( (
"rhoPhi", "rhoPhi",
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_
IOobject::NO_READ,
IOobject::NO_WRITE
), ),
mesh_, mesh_,
dimensionedScalar(dimMass/dimTime, Zero) dimensionedScalar(dimMass/dimTime, Zero)
@ -101,7 +100,8 @@ Foam::multiphaseMixture::multiphaseMixture
mesh_.time().timeName(), mesh_.time().timeName(),
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE,
IOobject::REGISTER
), ),
mesh_, mesh_,
dimensionedScalar(dimless, Zero) dimensionedScalar(dimless, Zero)
@ -257,19 +257,12 @@ Foam::multiphaseMixture::nuf() const
Foam::tmp<Foam::surfaceScalarField> Foam::tmp<Foam::surfaceScalarField>
Foam::multiphaseMixture::surfaceTensionForce() const Foam::multiphaseMixture::surfaceTensionForce() const
{ {
tmp<surfaceScalarField> tstf auto tstf = surfaceScalarField::New
( (
new surfaceScalarField "surfaceTensionForce",
( IOobject::NO_REGISTER,
IOobject mesh_,
( dimensionedScalar(dimensionSet(1, -2, -2, 0, 0), Zero)
"surfaceTensionForce",
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar(dimensionSet(1, -2, -2, 0, 0), Zero)
)
); );
surfaceScalarField& stf = tstf.ref(); surfaceScalarField& stf = tstf.ref();
@ -324,12 +317,7 @@ void Foam::multiphaseMixture::solve()
{ {
surfaceScalarField rhoPhiSum surfaceScalarField rhoPhiSum
( (
IOobject mesh_.newIOobject("rhoPhiSum"),
(
"rhoPhiSum",
runTime.timeName(),
mesh_
),
mesh_, mesh_,
dimensionedScalar(rhoPhi_.dimensions(), Zero) dimensionedScalar(rhoPhi_.dimensions(), Zero)
); );
@ -552,19 +540,12 @@ Foam::tmp<Foam::volScalarField> Foam::multiphaseMixture::K
Foam::tmp<Foam::volScalarField> Foam::tmp<Foam::volScalarField>
Foam::multiphaseMixture::nearInterface() const Foam::multiphaseMixture::nearInterface() const
{ {
tmp<volScalarField> tnearInt auto tnearInt = volScalarField::New
( (
new volScalarField "nearInterface",
( IOobject::NO_REGISTER,
IOobject mesh_,
( dimensionedScalar(dimless, Zero)
"nearInterface",
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar(dimless, Zero)
)
); );
for (const phase& ph : phases_) for (const phase& ph : phases_)
@ -649,12 +630,7 @@ void Foam::multiphaseMixture::solveAlphas
volScalarField sumAlpha volScalarField sumAlpha
( (
IOobject mesh_.newIOobject("sumAlpha"),
(
"sumAlpha",
mesh_.time().timeName(),
mesh_
),
mesh_, mesh_,
dimensionedScalar(dimless, Zero) dimensionedScalar(dimless, Zero)
); );

View File

@ -5,12 +5,7 @@ if (nAlphaSubCycles > 1)
dimensionedScalar totalDeltaT = runTime.deltaT(); dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum surfaceScalarField rhoPhiSum
( (
IOobject mesh.newIOobject("rhoPhiSum"),
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh, mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero) dimensionedScalar(rhoPhi.dimensions(), Zero)
); );

View File

@ -67,8 +67,8 @@ using namespace Foam;
// // (note:without calculating pointNormals // // (note:without calculating pointNormals
// // to avoid them being stored) // // to avoid them being stored)
// //
// tmp<pointField> textrudeN(new pointField(p.nPoints(), Zero)); // auto textrudeN = tmp<pointField>::New(p.nPoints(), Zero);
// pointField& extrudeN = textrudeN(); // auto& extrudeN = textrudeN.ref();
// { // {
// const faceList& localFaces = p.localFaces(); // const faceList& localFaces = p.localFaces();
// const vectorField& faceAreas = mesh.faceAreas(); // const vectorField& faceAreas = mesh.faceAreas();

View File

@ -1088,8 +1088,8 @@ tmp<pointField> calcOffset
{ {
vectorField::subField fc = pp.faceCentres(); vectorField::subField fc = pp.faceCentres();
tmp<pointField> toffsets(new pointField(fc.size())); auto toffsets = tmp<pointField>::New(fc.size());
pointField& offsets = toffsets.ref(); auto& offsets = toffsets.ref();
forAll(fc, i) forAll(fc, i)
{ {

View File

@ -64,8 +64,8 @@ Foam::tmp<Foam::Field<Type>> filterFarPoints
const Field<Type>& field const Field<Type>& field
) )
{ {
tmp<Field<Type>> tNewField(new Field<Type>(field.size())); auto tNewField = tmp<Field<Type>>::New(field.size());
Field<Type>& newField = tNewField.ref(); auto& newField = tNewField.ref();
label added = 0; label added = 0;
label count = 0; label count = 0;

View File

@ -268,8 +268,8 @@ Foam::tmp<Foam::pointField> Foam::DelaunayMeshTools::allPoints
const Triangulation& t const Triangulation& t
) )
{ {
tmp<pointField> tpts(new pointField(t.vertexCount(), point::max)); auto tpts = tmp<pointField>::New(t.vertexCount(), point::max);
pointField& pts = tpts.ref(); auto& pts = tpts.ref();
for for
( (

View File

@ -258,8 +258,8 @@ Foam::label Foam::cellShapeControlMesh::removePoints()
Foam::tmp<Foam::pointField> Foam::cellShapeControlMesh::cellCentres() const Foam::tmp<Foam::pointField> Foam::cellShapeControlMesh::cellCentres() const
{ {
tmp<pointField> tcellCentres(new pointField(number_of_finite_cells())); auto tcellCentres = tmp<pointField>::New(number_of_finite_cells());
pointField& cellCentres = tcellCentres.ref(); auto& cellCentres = tcellCentres.ref();
label count = 0; label count = 0;
for for

View File

@ -36,8 +36,8 @@ Foam::tmp<Foam::Field<Type>> Foam::smoothAlignmentSolver::filterFarPoints
const Field<Type>& field const Field<Type>& field
) )
{ {
tmp<Field<Type>> tNewField(new Field<Type>(field.size())); auto tNewField = tmp<Field<Type>>::New(field.size());
Field<Type>& newField = tNewField.ref(); auto& newField = tNewField.ref();
label added = 0; label added = 0;
label count = 0; label count = 0;

View File

@ -310,8 +310,8 @@ tmp<scalarField> signedDistance
const labelList& surfaces const labelList& surfaces
) )
{ {
tmp<scalarField> tfld(new scalarField(points.size(), Foam::sqr(GREAT))); auto tfld = tmp<scalarField>::New(points.size(), Foam::sqr(GREAT));
scalarField& fld = tfld.ref(); auto& fld = tfld.ref();
// Find nearest // Find nearest
List<pointIndexHit> nearest; List<pointIndexHit> nearest;

View File

@ -368,7 +368,7 @@ int main(int argc, char *argv[])
const auto dictFileName = args.get<fileName>(1); const auto dictFileName = args.get<fileName>(1);
autoPtr<IFstream> dictFile(new IFstream(dictFileName)); auto dictFile = autoPtr<IFstream>::New(dictFileName);
if (!dictFile().good()) if (!dictFile().good())
{ {
FatalErrorInFunction FatalErrorInFunction

View File

@ -360,8 +360,8 @@ tmp<scalarField> avg
const scalarField& edgeWeights const scalarField& edgeWeights
) )
{ {
tmp<scalarField> tres(new scalarField(s.nPoints(), Zero)); auto tres = tmp<scalarField>::New(s.nPoints(), Zero);
scalarField& res = tres.ref(); auto& res = tres.ref();
scalarField sumWeight(s.nPoints(), Zero); scalarField sumWeight(s.nPoints(), Zero);

View File

@ -62,8 +62,8 @@ tmp<pointField> avg
{ {
const labelListList& pointEdges = s.pointEdges(); const labelListList& pointEdges = s.pointEdges();
tmp<pointField> tavg(new pointField(s.nPoints(), Zero)); auto tavg = tmp<pointField>::New(s.nPoints(), Zero);
pointField& avg = tavg.ref(); auto& avg = tavg.ref();
forAll(pointEdges, vertI) forAll(pointEdges, vertI)
{ {

View File

@ -33,8 +33,8 @@ localCode
const pointField& points const pointField& points
) )
{ {
tmp<pointField> tnewPoints(new pointField(points)); auto tnewPoints = tmp<pointField>::New(points);
pointField& newPoints = tnewPoints.ref(); auto& newPoints = tnewPoints.ref();
const boundBox bb(points, true); const boundBox bb(points, true);
const scalar zMin = bb.min()[vector::Z]; const scalar zMin = bb.min()[vector::Z];