Merge branch 'md23-update-registry-handling' into 'develop'

Updates to reduce unnecessary registration of tmp fields

See merge request Development/openfoam!665
This commit is contained in:
Andrew Heather
2024-02-21 15:28:09 +00:00
370 changed files with 3341 additions and 6345 deletions

View File

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

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
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 Ma(MaModel.Ma());
tmp<volScalarField> tXiEq
auto tXiEq = volScalarField::New
(
new volScalarField
(
IOobject
(
"XiEq",
epsilon.time().timeName(),
epsilon.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
epsilon.mesh(),
dimensionedScalar(dimless, Zero)
)
"XiEq",
IOobject::NO_REGISTER,
epsilon.mesh(),
dimensionedScalar(dimless, Zero)
);
volScalarField& xieq = tXiEq.ref();
auto& xieq = tXiEq.ref();
forAll(xieq, celli)
{

View File

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

View File

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

View File

@ -10,7 +10,8 @@ if (pimple.dict().getOrDefault("hydrostaticInitialization", false))
"0",
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
IOobject::NO_WRITE,
IOobject::REGISTER
),
mesh
)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,12 +18,7 @@
dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField alphaPhiSum
(
IOobject
(
"alphaPhiSum",
runTime.timeName(),
mesh
),
mesh.newIOobject("alphaPhiSum"),
mesh,
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
volVectorField Ucm(betad*Udm_/betac);
return tmp<volSymmTensorField>
return volSymmTensorField::New
(
new volSymmTensorField
(
"tauDm",
betad*sqr(Udm_) + betac*sqr(Ucm)
)
"tauDm",
IOobject::NO_REGISTER,
betad*sqr(Udm_) + betac*sqr(Ucm)
);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -71,7 +71,7 @@ class readFieldsHandler
Log << " Reading " << io.name()
<< " (" << FieldType::typeName << ')' << endl;
mesh_.objectRegistry::store(new FieldType(io, mesh_));
regIOobject::store(new FieldType(io, mesh_));
return true;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2022-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -71,7 +71,7 @@ class readFieldsHandler
Log << " Reading " << io.name()
<< " (" << FieldType::typeName << ')' << endl;
mesh_.objectRegistry::store(new FieldType(io, mesh_));
regIOobject::store(new FieldType(io, mesh_));
return true;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -71,7 +71,7 @@ class readFieldsHandler
Log << " Reading " << io.name()
<< " (" << FieldType::typeName << ')' << endl;
mesh_.objectRegistry::store(new FieldType(io, mesh_));
regIOobject::store(new FieldType(io, mesh_));
return true;
}

View File

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

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -139,7 +139,7 @@ bool Foam::functionObjects::regionFunctionObject::store
}
else
{
obr().objectRegistry::store(tfield.ptr());
regIOobject::store(tfield.ptr());
}
}
else
@ -153,7 +153,7 @@ bool Foam::functionObjects::regionFunctionObject::store
fieldName = tfield().name();
}
obr().objectRegistry::store(tfield.ptr());
regIOobject::store(tfield.ptr());
}
return true;
@ -179,8 +179,11 @@ bool Foam::functionObjects::regionFunctionObject::storeInDb
}
else
{
tfield.ref().rename(fieldName);
obr.objectRegistry::store(tfield.ptr());
if (fieldName.size() && fieldName != tfield().name())
{
tfield.ref().rename(fieldName);
}
regIOobject::store(tfield.ptr());
}
return true;

View File

@ -46,7 +46,8 @@ Foam::tmp<GeoField> Foam::uniformInterpolate
field0.time().timeName(),
field0.db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
IOobject::AUTO_WRITE,
IOobject::REGISTER
),
weights[0]*(*fields[indices[0]])
);

View File

@ -90,16 +90,11 @@ template<class Type, class DType, class LUType>
Foam::tmp<Foam::Field<Type>>
Foam::LduMatrix<Type, DType, LUType>::H(const Field<Type>& psi) const
{
tmp<Field<Type>> tHpsi
(
new Field<Type>(lduAddr().size(), Zero)
);
auto tHpsi = tmp<Field<Type>>::New(lduAddr().size(), Foam::zero{});
if (lowerPtr_ || upperPtr_)
{
Field<Type> & Hpsi = tHpsi();
Type* __restrict__ HpsiPtr = Hpsi.begin();
Type* __restrict__ HpsiPtr = tHpsi.ref().begin();
const Type* __restrict__ psiPtr = psi.begin();

View File

@ -35,7 +35,7 @@ Description
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::lduMatrix::H(const Field<Type>& psi) const
{
auto tHpsi = tmp<Field<Type>>::New(lduAddr().size(), Zero);
auto tHpsi = tmp<Field<Type>>::New(lduAddr().size(), Foam::zero{});
if (lowerPtr_ || upperPtr_)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2019-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -348,7 +348,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
{
agglomPtr().printLevels();
}
return store(agglomPtr.ptr());
return regIOobject::store(agglomPtr);
}
}
@ -398,7 +398,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
{
agglomPtr().printLevels();
}
return store(agglomPtr.ptr());
return regIOobject::store(agglomPtr);
}
}
}
@ -463,7 +463,7 @@ const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
{
agglomPtr().printLevels();
}
return store(agglomPtr.ptr());
return regIOobject::store(agglomPtr);
}
}

View File

@ -1195,7 +1195,7 @@ void Foam::polyMesh::movePoints(const pointField& newPoints)
{
if (debug)
{
Info<< "tmp<scalarField> polyMesh::movePoints(const pointField&) : "
Info<< "void polyMesh::movePoints(const pointField&) : "
<< " Storing current points for time " << time().value()
<< " index " << time().timeIndex() << endl;
}

View File

@ -333,8 +333,8 @@ const Foam::vectorField::subField Foam::polyPatch::faceAreas() const
Foam::tmp<Foam::vectorField> Foam::polyPatch::faceCellCentres() const
{
tmp<vectorField> tcc(new vectorField(size()));
vectorField& cc = tcc.ref();
auto tcc = tmp<vectorField>::New(size());
auto& cc = tcc.ref();
// get reference to global cell centres
const vectorField& gcc = boundaryMesh_.mesh().cellCentres();
@ -352,8 +352,8 @@ Foam::tmp<Foam::vectorField> Foam::polyPatch::faceCellCentres() const
Foam::tmp<Foam::scalarField> Foam::polyPatch::areaFraction() const
{
tmp<scalarField> tfraction(new scalarField(size()));
scalarField& fraction = tfraction.ref();
auto tfraction = tmp<scalarField>::New(size());
auto& fraction = tfraction.ref();
const vectorField::subField faceAreas = this->faceAreas();
const pointField& points = this->points();

View File

@ -143,10 +143,7 @@ Foam::ThermalDiffusivity<BasicTurbulenceModel>::alphat
const label patchi
) const
{
return tmp<scalarField>
(
new scalarField(this->mesh_.boundary()[patchi].size(), Zero)
);
return tmp<scalarField>::New(this->mesh_.boundary()[patchi].size(), Zero);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd.
Copyright (C) 2015-2024 OpenCFD Ltd.
Copyright (C) 2022 Upstream CFD GmbH
-------------------------------------------------------------------------------
License
@ -301,7 +301,7 @@ class DEShybrid
(
factorName,
mesh.time().timeName(),
mesh,
mesh.thisDb(),
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::REGISTER
@ -321,7 +321,7 @@ class DEShybrid
dimensionedScalar(dimless, Zero)
);
const_cast<fvMesh&>(mesh).objectRegistry::store(factorPtr);
regIOobject::store(factorPtr);
}
auto& factor = *factorPtr;

View File

@ -168,16 +168,10 @@ tmp<volScalarField> DESModel<BasicTurbulenceModel>::Ssigma
template<class BasicTurbulenceModel>
tmp<volScalarField> DESModel<BasicTurbulenceModel>::fd() const
{
return tmp<volScalarField>::New
return volScalarField::New
(
IOobject
(
"fd",
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
"fd",
IOobject::NO_REGISTER,
this->mesh_,
dimensionedScalar(dimless, Zero)
);

View File

@ -53,21 +53,12 @@ void Foam::LESModels::IDDESDelta::calcDelta()
// Wall-normal vectors
const volVectorField& n = wallDist::New(mesh).n();
tmp<volScalarField> tfaceToFacenMax
auto tfaceToFacenMax = volScalarField::New
(
new volScalarField
(
IOobject
(
"faceToFaceMax",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar(dimLength, Zero)
)
"faceToFaceMax",
IOobject::NO_REGISTER,
mesh,
dimensionedScalar(dimLength, Zero)
);
scalarField& faceToFacenMax = tfaceToFacenMax.ref().primitiveFieldRef();

View File

@ -182,19 +182,12 @@ Foam::tmp<Foam::volSymmTensorField> Foam::anisotropicFilter::operator()
{
correctBoundaryConditions(unFilteredField);
tmp<volSymmTensorField> tmpFilteredField
auto tmpFilteredField = volSymmTensorField::New
(
new volSymmTensorField
(
IOobject
(
"anisotropicFilteredSymmTensorField",
mesh().time().timeName(),
mesh()
),
mesh(),
unFilteredField().dimensions()
)
"anisotropicFilteredSymmTensorField",
IOobject::NO_REGISTER,
mesh(),
unFilteredField().dimensions()
);
for (direction d=0; d<symmTensor::nComponents; d++)
@ -218,19 +211,12 @@ Foam::tmp<Foam::volTensorField> Foam::anisotropicFilter::operator()
{
correctBoundaryConditions(unFilteredField);
tmp<volTensorField> tmpFilteredField
auto tmpFilteredField = volTensorField::New
(
new volTensorField
(
IOobject
(
"anisotropicFilteredTensorField",
mesh().time().timeName(),
mesh()
),
mesh(),
unFilteredField().dimensions()
)
"anisotropicFilteredTensorField",
IOobject::NO_REGISTER,
mesh(),
unFilteredField().dimensions()
);
for (direction d=0; d<tensor::nComponents; d++)

View File

@ -138,14 +138,10 @@ void dynamicKEqn<BasicTurbulenceModel>::correctNut()
template<class BasicTurbulenceModel>
tmp<fvScalarMatrix> dynamicKEqn<BasicTurbulenceModel>::kSource() const
{
return tmp<fvScalarMatrix>
return tmp<fvScalarMatrix>::New
(
new fvScalarMatrix
(
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()
/dimTime
)
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime
);
}

View File

@ -52,14 +52,10 @@ void kEqn<BasicTurbulenceModel>::correctNut()
template<class BasicTurbulenceModel>
tmp<fvScalarMatrix> kEqn<BasicTurbulenceModel>::kSource() const
{
return tmp<fvScalarMatrix>
return tmp<fvScalarMatrix>::New
(
new fvScalarMatrix
(
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()
/dimTime
)
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime
);
}

View File

@ -69,14 +69,10 @@ void LaunderSharmaKE<BasicTurbulenceModel>::correctNut()
template<class BasicTurbulenceModel>
tmp<fvScalarMatrix> LaunderSharmaKE<BasicTurbulenceModel>::kSource() const
{
return tmp<fvScalarMatrix>
return tmp<fvScalarMatrix>::New
(
new fvScalarMatrix
(
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()
/dimTime
)
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime
);
}
@ -84,14 +80,10 @@ tmp<fvScalarMatrix> LaunderSharmaKE<BasicTurbulenceModel>::kSource() const
template<class BasicTurbulenceModel>
tmp<fvScalarMatrix> LaunderSharmaKE<BasicTurbulenceModel>::epsilonSource() const
{
return tmp<fvScalarMatrix>
return tmp<fvScalarMatrix>::New
(
new fvScalarMatrix
(
epsilon_,
dimVolume*this->rho_.dimensions()*epsilon_.dimensions()
/dimTime
)
epsilon_,
dimVolume*this->rho_.dimensions()*epsilon_.dimensions()/dimTime
);
}

View File

@ -193,14 +193,10 @@ Foam::RASModel<BasicTurbulenceModel>::epsilon() const
{
const scalar Cmu = 0.09;
return tmp<volScalarField>::New
return volScalarField::New
(
IOobject
(
IOobject::groupName("epsilon", this->alphaRhoPhi_.group()),
this->mesh_.time().timeName(),
this->mesh_
),
IOobject::groupName("epsilon", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
Cmu*this->k()*this->omega()
);
}
@ -213,14 +209,10 @@ Foam::RASModel<BasicTurbulenceModel>::omega() const
const scalar betaStar = 0.09;
const dimensionedScalar k0(sqr(dimLength/dimTime), SMALL);
return tmp<volScalarField>::New
return volScalarField::New
(
IOobject
(
IOobject::groupName("omega", this->alphaRhoPhi_.group()),
this->mesh_.time().timeName(),
this->mesh_
),
IOobject::groupName("omega", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->epsilon()/(betaStar*(this->k() + k0))
);
}

View File

@ -53,14 +53,10 @@ void RNGkEpsilon<BasicTurbulenceModel>::correctNut()
template<class BasicTurbulenceModel>
tmp<fvScalarMatrix> RNGkEpsilon<BasicTurbulenceModel>::kSource() const
{
return tmp<fvScalarMatrix>
return tmp<fvScalarMatrix>::New
(
new fvScalarMatrix
(
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()
/dimTime
)
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime
);
}
@ -68,14 +64,10 @@ tmp<fvScalarMatrix> RNGkEpsilon<BasicTurbulenceModel>::kSource() const
template<class BasicTurbulenceModel>
tmp<fvScalarMatrix> RNGkEpsilon<BasicTurbulenceModel>::epsilonSource() const
{
return tmp<fvScalarMatrix>
return tmp<fvScalarMatrix>::New
(
new fvScalarMatrix
(
epsilon_,
dimVolume*this->rho_.dimensions()*epsilon_.dimensions()
/dimTime
)
epsilon_,
dimVolume*this->rho_.dimensions()*epsilon_.dimensions()/dimTime
);
}

View File

@ -53,14 +53,10 @@ void kEpsilon<BasicTurbulenceModel>::correctNut()
template<class BasicTurbulenceModel>
tmp<fvScalarMatrix> kEpsilon<BasicTurbulenceModel>::kSource() const
{
return tmp<fvScalarMatrix>
return tmp<fvScalarMatrix>::New
(
new fvScalarMatrix
(
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()
/dimTime
)
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime
);
}
@ -68,14 +64,10 @@ tmp<fvScalarMatrix> kEpsilon<BasicTurbulenceModel>::kSource() const
template<class BasicTurbulenceModel>
tmp<fvScalarMatrix> kEpsilon<BasicTurbulenceModel>::epsilonSource() const
{
return tmp<fvScalarMatrix>
return tmp<fvScalarMatrix>::New
(
new fvScalarMatrix
(
epsilon_,
dimVolume*this->rho_.dimensions()*epsilon_.dimensions()
/dimTime
)
epsilon_,
dimVolume*this->rho_.dimensions()*epsilon_.dimensions()/dimTime
);
}

View File

@ -95,11 +95,11 @@ tmp<volScalarField::Internal> kOmegaSSTLM<BasicTurbulenceModel>::Fthetat
const volScalarField::Internal ReOmega(sqr(y)*omega/nu);
const volScalarField::Internal Fwake(exp(-sqr(ReOmega/1e5)));
return tmp<volScalarField::Internal>
return volScalarField::Internal::New
(
new volScalarField::Internal
IOobject::groupName("Fthetat", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
(
IOobject::groupName("Fthetat", this->alphaRhoPhi_.group()),
min
(
max
@ -118,21 +118,14 @@ template<class BasicTurbulenceModel>
tmp<volScalarField::Internal>
kOmegaSSTLM<BasicTurbulenceModel>::ReThetac() const
{
tmp<volScalarField::Internal> tReThetac
auto tReThetac = volScalarField::Internal::New
(
new volScalarField::Internal
(
IOobject
(
IOobject::groupName("ReThetac", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_
),
this->mesh_,
dimless
)
IOobject::groupName("ReThetac", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->mesh_,
dimless
);
volScalarField::Internal& ReThetac = tReThetac.ref();
auto& ReThetac = tReThetac.ref();
forAll(ReThetac, celli)
{
@ -161,21 +154,14 @@ tmp<volScalarField::Internal> kOmegaSSTLM<BasicTurbulenceModel>::Flength
const volScalarField::Internal& nu
) const
{
tmp<volScalarField::Internal> tFlength
auto tFlength = volScalarField::Internal::New
(
new volScalarField::Internal
(
IOobject
(
IOobject::groupName("Flength", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_
),
this->mesh_,
dimless
)
IOobject::groupName("Flength", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->mesh_,
dimless
);
volScalarField::Internal& Flength = tFlength.ref();
auto& Flength = tFlength.ref();
const volScalarField::Internal& omega = this->omega_();
const volScalarField::Internal& y = this->y_();
@ -226,21 +212,14 @@ tmp<volScalarField::Internal> kOmegaSSTLM<BasicTurbulenceModel>::ReThetat0
const volScalarField::Internal& nu
) const
{
tmp<volScalarField::Internal> tReThetat0
auto tReThetat0 = volScalarField::Internal::New
(
new volScalarField::Internal
(
IOobject
(
IOobject::groupName("ReThetat0", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_
),
this->mesh_,
dimless
)
IOobject::groupName("ReThetat0", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->mesh_,
dimless
);
volScalarField::Internal& ReThetat0 = tReThetat0.ref();
auto& ReThetat0 = tReThetat0.ref();
const volScalarField& k = this->k_;
@ -349,13 +328,11 @@ tmp<volScalarField::Internal> kOmegaSSTLM<BasicTurbulenceModel>::Fonset
const volScalarField::Internal Fonset3(max(1 - pow3(RT/2.5), scalar(0)));
return tmp<volScalarField::Internal>
return volScalarField::Internal::New
(
new volScalarField::Internal
(
IOobject::groupName("Fonset", this->alphaRhoPhi_.group()),
max(Fonset2 - Fonset3, scalar(0))
)
IOobject::groupName("Fonset", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
max(Fonset2 - Fonset3, scalar(0))
);
}
@ -459,7 +436,8 @@ kOmegaSSTLM<BasicTurbulenceModel>::kOmegaSSTLM
this->runTime_.timeName(),
this->mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
IOobject::AUTO_WRITE,
IOobject::REGISTER
),
this->mesh_
),
@ -472,7 +450,8 @@ kOmegaSSTLM<BasicTurbulenceModel>::kOmegaSSTLM
this->runTime_.timeName(),
this->mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
IOobject::AUTO_WRITE,
IOobject::REGISTER
),
this->mesh_
),

View File

@ -101,14 +101,10 @@ void realizableKE<BasicTurbulenceModel>::correctNut()
template<class BasicTurbulenceModel>
tmp<fvScalarMatrix> realizableKE<BasicTurbulenceModel>::kSource() const
{
return tmp<fvScalarMatrix>
return tmp<fvScalarMatrix>::New
(
new fvScalarMatrix
(
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()
/dimTime
)
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime
);
}
@ -116,14 +112,10 @@ tmp<fvScalarMatrix> realizableKE<BasicTurbulenceModel>::kSource() const
template<class BasicTurbulenceModel>
tmp<fvScalarMatrix> realizableKE<BasicTurbulenceModel>::epsilonSource() const
{
return tmp<fvScalarMatrix>
return tmp<fvScalarMatrix>::New
(
new fvScalarMatrix
(
epsilon_,
dimVolume*this->rho_.dimensions()*epsilon_.dimensions()
/dimTime
)
epsilon_,
dimVolume*this->rho_.dimensions()*epsilon_.dimensions()/dimTime
);
}

View File

@ -65,7 +65,8 @@ Foam::eddyViscosity<BasicTurbulenceModel>::eddyViscosity
this->runTime_.timeName(),
this->mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
IOobject::AUTO_WRITE,
IOobject::REGISTER
),
this->mesh_
)
@ -104,22 +105,12 @@ Foam::eddyViscosity<BasicTurbulenceModel>::R() const
}
}
return tmp<volSymmTensorField>
return volSymmTensorField::New
(
new volSymmTensorField
(
IOobject
(
IOobject::groupName("R", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
((2.0/3.0)*I)*tk() - (nut_)*devTwoSymm(fvc::grad(this->U_)),
patchFieldTypes
)
IOobject::groupName("R", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
((2.0/3.0)*I)*tk() - (nut_)*devTwoSymm(fvc::grad(this->U_)),
patchFieldTypes
);
}

View File

@ -89,17 +89,10 @@ template<class BasicTurbulenceModel>
tmp<volScalarField>
Stokes<BasicTurbulenceModel>::nut() const
{
return tmp<volScalarField>::New
return volScalarField::New
(
IOobject
(
IOobject::groupName("nut", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
IOobject::groupName("nut", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->mesh_,
dimensionedScalar(dimViscosity, Zero)
);
@ -113,10 +106,7 @@ Stokes<BasicTurbulenceModel>::nut
const label patchi
) const
{
return tmp<scalarField>
(
new scalarField(this->mesh_.boundary()[patchi].size(), Zero)
);
return tmp<scalarField>::New(this->mesh_.boundary()[patchi].size(), Zero);
}
@ -124,12 +114,11 @@ template<class BasicTurbulenceModel>
tmp<volScalarField>
Stokes<BasicTurbulenceModel>::nuEff() const
{
return tmp<volScalarField>
return volScalarField::New
(
new volScalarField
(
IOobject::groupName("nuEff", this->alphaRhoPhi_.group()), this->nu()
)
IOobject::groupName("nuEff", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->nu()
);
}

View File

@ -189,17 +189,10 @@ template<class BasicTurbulenceModel>
Foam::tmp<Foam::volScalarField>
Foam::laminarModel<BasicTurbulenceModel>::nut() const
{
return tmp<volScalarField>::New
return volScalarField::New
(
IOobject
(
IOobject::groupName("nut", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
IOobject::groupName("nut", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->mesh_,
dimensionedScalar(dimViscosity, Zero)
);
@ -213,10 +206,7 @@ Foam::laminarModel<BasicTurbulenceModel>::nut
const label patchi
) const
{
return tmp<scalarField>
(
new scalarField(this->mesh_.boundary()[patchi].size(), Zero)
);
return tmp<scalarField>::New(this->mesh_.boundary()[patchi].size(), Zero);
}
@ -224,12 +214,11 @@ template<class BasicTurbulenceModel>
Foam::tmp<Foam::volScalarField>
Foam::laminarModel<BasicTurbulenceModel>::nuEff() const
{
return tmp<volScalarField>
return volScalarField::New
(
new volScalarField
(
IOobject::groupName("nuEff", this->alphaRhoPhi_.group()), this->nu()
)
IOobject::groupName("nuEff", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->nu()
);
}
@ -249,17 +238,10 @@ template<class BasicTurbulenceModel>
Foam::tmp<Foam::volScalarField>
Foam::laminarModel<BasicTurbulenceModel>::k() const
{
return tmp<volScalarField>::New
return volScalarField::New
(
IOobject
(
IOobject::groupName("k", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
IOobject::groupName("k", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->mesh_,
dimensionedScalar(sqr(this->U_.dimensions()), Zero)
);
@ -270,17 +252,10 @@ template<class BasicTurbulenceModel>
Foam::tmp<Foam::volScalarField>
Foam::laminarModel<BasicTurbulenceModel>::epsilon() const
{
return tmp<volScalarField>::New
return volScalarField::New
(
IOobject
(
IOobject::groupName("epsilon", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
IOobject::groupName("epsilon", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->mesh_,
dimensionedScalar(sqr(this->U_.dimensions())/dimTime, Zero)
);
@ -291,17 +266,10 @@ template<class BasicTurbulenceModel>
Foam::tmp<Foam::volScalarField>
Foam::laminarModel<BasicTurbulenceModel>::omega() const
{
return tmp<volScalarField>::New
return volScalarField::New
(
IOobject
(
IOobject::groupName("omega", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
IOobject::groupName("omega", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->mesh_,
dimensionedScalar(dimless/dimTime, Zero)
);
@ -312,17 +280,10 @@ template<class BasicTurbulenceModel>
Foam::tmp<Foam::volSymmTensorField>
Foam::laminarModel<BasicTurbulenceModel>::R() const
{
return tmp<volSymmTensorField>::New
return volSymmTensorField::New
(
IOobject
(
IOobject::groupName("R", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
IOobject::groupName("R", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->mesh_,
dimensionedSymmTensor(sqr(this->U_.dimensions()), Zero)
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 ENERCON GmbH
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,14 +58,14 @@ Foam::volScalarField& Foam::fv::atmPlantCanopyTurbSource::getOrReadField
(
fieldName,
mesh_.time().timeName(),
mesh_,
mesh_.thisDb(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE,
IOobject::REGISTER
),
mesh_
);
mesh_.objectRegistry::store(ptr);
regIOobject::store(ptr);
}
return *ptr;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 ENERCON GmbH
Copyright (C) 2020-2022 OpenCFD Ltd.
Copyright (C) 2020-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,14 +59,14 @@ Foam::volScalarField& Foam::fv::atmPlantCanopyUSource::getOrReadField
(
fieldName,
mesh_.time().timeName(),
mesh_,
mesh_.thisDb(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE,
IOobject::REGISTER
),
mesh_
);
mesh_.objectRegistry::store(ptr);
regIOobject::store(ptr);
}
return *ptr;

View File

@ -80,17 +80,10 @@ tmp<volScalarField> kL<BasicTurbulenceModel>::epsilonCanopy() const
return Cd*LAD*mag(U)*k_;
}
return tmp<volScalarField>::New
return volScalarField::New
(
IOobject
(
IOobject::groupName("epsilonCanopy", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
IOobject::groupName("epsilonCanopy", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->mesh_,
dimensionedScalar(sqr(dimLength)/pow3(dimTime), Zero)
);
@ -118,26 +111,22 @@ tmp<volScalarField> kL<BasicTurbulenceModel>::epsilon() const
template<class BasicTurbulenceModel>
tmp<volScalarField> kL<BasicTurbulenceModel>::canopyHeight() const
{
const auto* canopyHeightPtr =
this->mesh_.template findObject<volScalarField>("canopyHeight");
tmp<volScalarField> tcanopy;
if (canopyHeightPtr)
tcanopy.cref
(
this->mesh_.template cfindObject<volScalarField>("canopyHeight")
);
if (tcanopy)
{
const auto& canopyHeight = *canopyHeightPtr;
return canopyHeight;
return tcanopy;
}
return tmp<volScalarField>::New
return volScalarField::New
(
IOobject
(
IOobject::groupName("canopyHeight", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
IOobject::groupName("canopyHeight", this->alphaRhoPhi_.group()),
IOobject::NO_REGISTER,
this->mesh_,
dimensionedScalar(dimLength, Zero)
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2019-2020,2023 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,11 +59,12 @@ Foam::combustionModels::EDC<ReactionThermo>::EDC
(
IOobject
(
this->thermo().phasePropertyName(typeName + ":kappa"),
this->thermo().phaseScopedName(typeName, "kappa"),
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
IOobject::AUTO_WRITE,
IOobject::REGISTER
),
this->mesh(),
dimensionedScalar(dimless, Zero)
@ -86,23 +87,23 @@ void Foam::combustionModels::EDC<ReactionThermo>::correct()
if (this->active())
{
tmp<volScalarField> tepsilon(this->turbulence().epsilon());
const volScalarField& epsilon = tepsilon();
const auto& epsilon = tepsilon();
tmp<volScalarField> tmu(this->turbulence().mu());
const volScalarField& mu = tmu();
const auto& mu = tmu();
tmp<volScalarField> tk(this->turbulence().k());
const volScalarField& k = tk();
const auto& k = tk();
tmp<volScalarField> trho(this->rho());
const volScalarField& rho = trho();
const auto& rho = trho();
scalarField tauStar(epsilon.size(), Zero);
if (version_ == EDCversions::v2016)
{
tmp<volScalarField> ttc(this->chemistryPtr_->tc());
const volScalarField& tc = ttc();
const auto& tc = ttc();
forAll(tauStar, i)
{
@ -199,22 +200,12 @@ template<class ReactionThermo>
Foam::tmp<Foam::volScalarField>
Foam::combustionModels::EDC<ReactionThermo>::Qdot() const
{
tmp<volScalarField> tQdot
auto tQdot = volScalarField::New
(
new volScalarField
(
IOobject
(
this->thermo().phasePropertyName(typeName + ":Qdot"),
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
this->mesh(),
dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero)
)
this->thermo().phaseScopedName(typeName, "Qdot"),
IOobject::NO_REGISTER,
this->mesh(),
dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero)
);
if (this->active())

View File

@ -72,7 +72,8 @@ FSD<ReactionThermo, ThermoType>::FSD
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
IOobject::AUTO_WRITE,
IOobject::REGISTER
),
this->mesh(),
dimensionedScalar(dimless, Zero)
@ -149,43 +150,23 @@ void FSD<ReactionThermo, ThermoType>::calculateSourceNorm()
s.value()*YFuelFuelStream_.value() + YO2OxiStream_.value()
);
tmp<volScalarField> tPc
auto tPc = volScalarField::New
(
new volScalarField
(
IOobject
(
this->thermo().phasePropertyName("Pc"),
U.time().timeName(),
U.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
U.mesh(),
dimensionedScalar(dimless, Zero)
)
this->thermo().phasePropertyName("Pc"),
IOobject::NO_REGISTER,
U.mesh(),
dimensionedScalar(dimless, Zero)
);
auto& pc = tPc.ref();
volScalarField& pc = tPc.ref();
tmp<volScalarField> tomegaFuel
auto tomegaFuel = volScalarField::New
(
new volScalarField
(
IOobject
(
this->thermo().phasePropertyName("omegaFuelBar"),
U.time().timeName(),
U.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
U.mesh(),
dimensionedScalar(omegaFuel.dimensions(), Zero)
)
this->thermo().phasePropertyName("omegaFuelBar"),
IOobject::NO_REGISTER,
U.mesh(),
dimensionedScalar(omegaFuel.dimensions(), Zero)
);
volScalarField& omegaFuelBar = tomegaFuel.ref();
auto& omegaFuelBar = tomegaFuel.ref();
// Calculation of the mixture fraction variance (ftVar)
const compressible::LESModel& lesModel =
@ -294,24 +275,14 @@ void FSD<ReactionThermo, ThermoType>::calculateSourceNorm()
}
}
tmp<volScalarField> tproducts
auto tproducts = volScalarField::New
(
new volScalarField
(
IOobject
(
this->thermo().phasePropertyName("products"),
U.time().timeName(),
U.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
U.mesh(),
dimensionedScalar(dimless, Zero)
)
this->thermo().phasePropertyName("products"),
IOobject::NO_REGISTER,
U.mesh(),
dimensionedScalar(dimless, Zero)
);
volScalarField& products = tproducts.ref();
auto& products = tproducts.ref();
forAll(productsIndex, j)
{

View File

@ -82,24 +82,14 @@ Foam::tmp<Foam::volScalarField> Foam::consumptionSpeed::omega0Sigma
const volScalarField& sigma
)
{
tmp<volScalarField> tomega0
auto tomega0 = volScalarField::New
(
new volScalarField
(
IOobject
(
"omega0",
sigma.time().timeName(),
sigma.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
sigma.mesh(),
dimensionedScalar(dimensionSet(1, -2, -1, 0, 0, 0, 0), Zero)
)
"omega0",
IOobject::NO_REGISTER,
sigma.mesh(),
dimensionedScalar(dimensionSet(1, -2, -1, 0, 0, 0, 0), Zero)
);
volScalarField& omega0 = tomega0.ref();
auto& omega0 = tomega0.ref();
volScalarField::Internal& iomega0 = omega0;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019,2023 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -45,11 +45,12 @@ Foam::combustionModels::PaSR<ReactionThermo>::PaSR
(
IOobject
(
thermo.phasePropertyName(typeName + ":kappa"),
thermo.phaseScopedName(typeName, "kappa"),
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
IOobject::AUTO_WRITE,
IOobject::REGISTER
),
this->mesh(),
dimensionedScalar(dimless, Zero)
@ -74,16 +75,16 @@ void Foam::combustionModels::PaSR<ReactionThermo>::correct()
laminar<ReactionThermo>::correct();
tmp<volScalarField> tepsilon(this->turbulence().epsilon());
const scalarField& epsilon = tepsilon();
const auto& epsilon = tepsilon();
tmp<volScalarField> tmuEff(this->turbulence().muEff());
const scalarField& muEff = tmuEff();
const auto& muEff = tmuEff();
tmp<volScalarField> ttc(this->tc());
const scalarField& tc = ttc();
const auto& tc = ttc();
tmp<volScalarField> trho(this->rho());
const scalarField& rho = trho();
const auto& rho = trho();
forAll(epsilon, i)
{
@ -118,13 +119,11 @@ template<class ReactionThermo>
Foam::tmp<Foam::volScalarField>
Foam::combustionModels::PaSR<ReactionThermo>::Qdot() const
{
return tmp<volScalarField>
return volScalarField::New
(
new volScalarField
(
this->thermo().phasePropertyName(typeName + ":Qdot"),
kappa_*laminar<ReactionThermo>::Qdot()
)
this->thermo().phaseScopedName(typeName, "Qdot"),
IOobject::NO_REGISTER,
kappa_*laminar<ReactionThermo>::Qdot()
);
}

View File

@ -60,15 +60,7 @@ diffusionMulticomponent<ReactionThermo, ThermoType>::init()
k,
new volScalarField
(
IOobject
(
"Rijk" + Foam::name(k),
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
this->mesh_.newIOobject("Rijk" + Foam::name(k)),
this->mesh_,
dimensionedScalar(dimMass/dimTime/dimVolume, Zero),
fvPatchFieldBase::zeroGradientType()
@ -198,15 +190,7 @@ diffusionMulticomponent<ReactionThermo, ThermoType>::correct()
k,
new volScalarField
(
IOobject
(
"Rijl" + Foam::name(k),
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
this->mesh_.newIOobject("Rijl" + Foam::name(k)),
this->mesh_,
dimensionedScalar(dimMass/dimTime/dimVolume, Zero),
fvPatchFieldBase::zeroGradientType()
@ -374,9 +358,8 @@ Foam::combustionModels::diffusionMulticomponent<ReactionThermo, ThermoType>::R
volScalarField& Y
) const
{
tmp<fvScalarMatrix> tSu(new fvScalarMatrix(Y, dimMass/dimTime));
fvScalarMatrix& Su = tSu.ref();
auto tSu = tmp<fvScalarMatrix>::New(Y, dimMass/dimTime);
auto& Su = tSu.ref();
if (this->active())
{
@ -395,23 +378,13 @@ Foam::tmp<Foam::volScalarField>
Foam::combustionModels::
diffusionMulticomponent<ReactionThermo, ThermoType>::Qdot() const
{
tmp<volScalarField> tQdot
auto tQdot = volScalarField::New
(
new volScalarField
(
IOobject
(
"Qdot",
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
this->mesh(),
dimensionedScalar(dimEnergy/dimTime/dimVolume, Zero),
fvPatchFieldBase::zeroGradientType()
)
"Qdot",
IOobject::NO_REGISTER,
this->mesh(),
dimensionedScalar(dimEnergy/dimTime/dimVolume, Zero),
fvPatchFieldBase::zeroGradientType()
);
if (this->active())

View File

@ -77,25 +77,16 @@ template<class ReactionThermo, class ThermoType>
Foam::tmp<Foam::volScalarField>
eddyDissipationDiffusionModel<ReactionThermo, ThermoType>::rtDiff() const
{
tmp<volScalarField> tdelta
auto tdelta = volScalarField::New
(
new volScalarField
(
IOobject
(
"tdelta",
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
this->mesh(),
dimensionedScalar(dimLength, Zero),
fvPatchFieldBase::zeroGradientType()
)
"tdelta",
IOobject::NO_REGISTER,
this->mesh(),
dimensionedScalar(dimLength, Zero),
fvPatchFieldBase::zeroGradientType()
);
auto& delta = tdelta.ref();
volScalarField& delta = tdelta.ref();
delta.ref() = cbrt(this->mesh().V());
delta.correctBoundaryConditions();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -123,9 +123,8 @@ template<class ReactionThermo>
Foam::tmp<Foam::fvScalarMatrix>
Foam::combustionModels::laminar<ReactionThermo>::R(volScalarField& Y) const
{
tmp<fvScalarMatrix> tSu(new fvScalarMatrix(Y, dimMass/dimTime));
fvScalarMatrix& Su = tSu.ref();
auto tSu = tmp<fvScalarMatrix>::New(Y, dimMass/dimTime);
auto& Su = tSu.ref();
if (this->active())
{
@ -143,22 +142,12 @@ template<class ReactionThermo>
Foam::tmp<Foam::volScalarField>
Foam::combustionModels::laminar<ReactionThermo>::Qdot() const
{
tmp<volScalarField> tQdot
auto tQdot = volScalarField::New
(
new volScalarField
(
IOobject
(
this->thermo().phasePropertyName(typeName + ":Qdot"),
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
this->mesh(),
dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero)
)
this->thermo().phaseScopedName(typeName, "Qdot"),
IOobject::NO_REGISTER,
this->mesh(),
dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero)
);
if (this->active())

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,12 +65,7 @@ Foam::combustionModels::noCombustion<ReactionThermo>::R
volScalarField& Y
) const
{
tmp<fvScalarMatrix> tSu
(
new fvScalarMatrix(Y, dimMass/dimTime)
);
return tSu;
return tmp<fvScalarMatrix>::New(Y, dimMass/dimTime);
}
@ -78,17 +73,10 @@ template<class ReactionThermo>
Foam::tmp<Foam::volScalarField>
Foam::combustionModels::noCombustion<ReactionThermo>::Qdot() const
{
return tmp<volScalarField>::New
return volScalarField::New
(
IOobject
(
this->thermo().phasePropertyName(typeName + ":Qdot"),
this->mesh().time().timeName(),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
this->thermo().phaseScopedName(typeName, "Qdot"),
IOobject::NO_REGISTER,
this->mesh(),
dimensionedScalar(dimEnergy/dimVolume/dimTime, Zero)
);

View File

@ -295,46 +295,31 @@ void Foam::interfaceTrackingFvMesh::makeControlPoints()
<< abort(FatalError);
}
IOobject controlPointsHeader
IOobject pointsIO
(
"controlPoints",
mesh().time().timeName(),
mesh(),
IOobject::MUST_READ
IOobject::MUST_READ,
IOobject::AUTO_WRITE,
IOobject::REGISTER
);
if (controlPointsHeader.typeHeaderOk<vectorIOField>())
if (pointsIO.typeHeaderOk<vectorIOField>())
{
Info<< "Reading control points" << endl;
controlPointsPtr_ =
new vectorIOField
(
IOobject
(
"controlPoints",
mesh().time().timeName(),
mesh(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
)
);
controlPointsPtr_ = new vectorIOField(pointsIO);
}
else
{
pointsIO.readOpt(IOobject::NO_READ);
Info<< "Creating new control points" << endl;
controlPointsPtr_ =
new vectorIOField
(
IOobject
(
"controlPoints",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
aMesh().areaCentres().internalField()
);
controlPointsPtr_ = new vectorIOField
(
pointsIO,
aMesh().areaCentres().internalField()
);
initializeControlPointsPosition();
}

View File

@ -47,8 +47,8 @@ Foam::tmp<Foam::vectorField> Foam::layerAdditionRemoval::extrusionDir() const
const pointField& points = mesh.points();
const labelList& mp = masterFaceLayer.meshPoints();
tmp<vectorField> textrusionDir(new vectorField(mp.size()));
vectorField& extrusionDir = textrusionDir.ref();
auto textrusionDir = tmp<vectorField>::New(mp.size());
auto& extrusionDir = textrusionDir.ref();
if (setLayerPairing())
{

View File

@ -339,8 +339,8 @@ Foam::displacementInterpolationMotionSolver::curPoints() const
<< " points." << exit(FatalError);
}
tmp<pointField> tcurPoints(new pointField(points0()));
pointField& curPoints = tcurPoints.ref();
auto tcurPoints = tmp<pointField>::New(points0());
auto& curPoints = tcurPoints.ref();
// Interpolate the displacement of the face zones.
vectorField zoneDisp(displacements_.size(), Zero);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -338,14 +338,9 @@ void Foam::displacementLayeredMotionMotionSolver::cellZoneSolve
patchi,
new pointVectorField
(
IOobject
mesh().newIOobject
(
mesh().cellZones()[cellZoneI].name() + "_" + fz.name(),
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
mesh().cellZones()[cellZoneI].name() + "_" + fz.name()
),
pointDisplacement_ // to inherit the boundary conditions
)
@ -429,20 +424,18 @@ void Foam::displacementLayeredMotionMotionSolver::cellZoneSolve
if (debug)
{
// Normalised distance
pointScalarField distance
auto tdistance = pointScalarField::New
(
IOobject
IOobject::scopedName
(
mesh().cellZones()[cellZoneI].name() + ":distance",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
mesh().cellZones()[cellZoneI].name(),
"distance"
),
IOobject::NO_REGISTER,
pointMesh::New(mesh()),
dimensionedScalar(dimLength, Zero)
);
auto& distance = tdistance.ref();
for (const label pointi : isZonePoint)
{

View File

@ -41,8 +41,8 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::source
{
checkApplied();
tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, ds));
faMatrix<Type>& mtx = tmtx.ref();
auto tmtx = tmp<faMatrix<Type>>::New(field, ds);
auto& mtx = tmtx.ref();
for (fa::option& source : *this)
{
@ -132,8 +132,8 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator()
rho.dimensions()*field.dimensions()/dimTime*dimArea
);
tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, ds));
faMatrix<Type>& mtx = tmtx.ref();
auto tmtx = tmp<faMatrix<Type>>::New(field, ds);
auto& mtx = tmtx.ref();
for (fa::option& source : *this)
{
@ -184,8 +184,8 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator()
const dimensionSet dsMat(ds*dimArea);
tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, dsMat));
faMatrix<Type>& mtx = tmtx.ref();
auto tmtx = tmp<faMatrix<Type>>::New(field, dsMat);
auto& mtx = tmtx.ref();
for (fa::option& source : *this)
{

View File

@ -58,11 +58,12 @@ Foam::fa::jouleHeatingSource::jouleHeatingSource
(
IOobject
(
typeName + ":V_" + regionName_,
IOobject::scopedName(typeName, "V_" + regionName_),
regionMesh().thisDb().time().timeName(),
regionMesh().thisDb(),
IOobject::MUST_READ,
IOobject::AUTO_WRITE
IOobject::AUTO_WRITE,
IOobject::REGISTER
),
regionMesh()
),
@ -141,6 +142,11 @@ void Foam::fa::jouleHeatingSource::addSup
}
// Add the Joule heating contribution
const word sigmaName
(
IOobject::scopedName(typeName, "sigma_" + regionName_)
);
areaVectorField gradV("gradV", fac::grad(V_));
if (debug > 1 && mesh().time().writeTime())
@ -156,20 +162,14 @@ void Foam::fa::jouleHeatingSource::addSup
if (anisotropicElectricalConductivity_)
{
const auto& sigma =
obr.lookupObject<areaTensorField>
(
typeName + ":sigma_" + regionName_
);
obr.lookupObject<areaTensorField>(sigmaName);
tsource = (h*sigma & gradV) & gradV;
}
else
{
const auto& sigma =
obr.lookupObject<areaScalarField>
(
typeName + ":sigma_" + regionName_
);
obr.lookupObject<areaScalarField>(sigmaName);
tsource = (h*sigma*gradV) & gradV;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2019-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,54 +36,52 @@ void Foam::fa::jouleHeatingSource::initialiseSigma
autoPtr<Function1<Type>>& sigmaVsTPtr
)
{
typedef GeometricField<Type, faPatchField, areaMesh> AreaFieldType;
typedef GeometricField<Type, faPatchField, areaMesh> FieldType;
auto& obr = regionMesh().thisDb();
IOobject io
(
IOobject::scopedName(typeName, "sigma_" + regionName_),
obr.time().timeName(),
obr,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
IOobject::REGISTER
);
autoPtr<FieldType> tsigma;
if (dict.found("sigma"))
{
// Sigma to be defined using a Function1 type
sigmaVsTPtr = Function1<Type>::New("sigma", dict, &mesh_);
auto tsigma = tmp<AreaFieldType>::New
tsigma.reset
(
IOobject
new FieldType
(
typeName + ":sigma_" + regionName_,
obr.time().timeName(),
obr,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
regionMesh(),
dimensioned<Type>(sqr(dimCurrent)/dimPower/dimLength, Zero)
io,
regionMesh(),
Foam::zero{}, // value
sqr(dimCurrent)/dimPower/dimLength
)
);
regIOobject::store(tsigma.ptr());
Info<< " Conductivity 'sigma' read from dictionary as f(T)"
<< nl << endl;
}
else
{
// Sigma to be defined by user input
auto tsigma = tmp<AreaFieldType>::New
(
IOobject
(
typeName + ":sigma_" + regionName_,
obr.time().timeName(),
obr,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
regionMesh()
);
io.readOpt(IOobject::MUST_READ);
regIOobject::store(tsigma.ptr());
tsigma.reset(new FieldType(io, regionMesh()));
Info<< " Conductivity 'sigma' read from file" << nl << endl;
}
regIOobject::store(tsigma);
}
@ -94,12 +92,15 @@ Foam::fa::jouleHeatingSource::updateSigma
const autoPtr<Function1<Type>>& sigmaVsTPtr
) const
{
typedef GeometricField<Type, faPatchField, areaMesh> AreaFieldType;
typedef GeometricField<Type, faPatchField, areaMesh> FieldType;
const auto& obr = regionMesh().thisDb();
auto& sigma =
obr.lookupObjectRef<AreaFieldType>(typeName + ":sigma_" + regionName_);
obr.lookupObjectRef<FieldType>
(
IOobject::scopedName(typeName, "sigma_" + regionName_)
);
if (!sigmaVsTPtr)
{
@ -117,11 +118,11 @@ Foam::fa::jouleHeatingSource::updateSigma
// Boundary field
typename AreaFieldType::Boundary& bf = sigma.boundaryFieldRef();
auto& bf = sigma.boundaryFieldRef();
forAll(bf, patchi)
{
faPatchField<Type>& pf = bf[patchi];
if (!isA<emptyFaPatch>(bf[patchi]))
if (!isA<emptyFaPatch>(pf))
{
const scalarField& Tbf = T.boundaryField()[patchi];
forAll(pf, facei)

View File

@ -1207,7 +1207,7 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
)
{
checkMethod(A, B, "+");
tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
auto tC = tmp<faMatrix<Type>>::New(A);
tC.ref() += B;
return tC;
}
@ -1262,7 +1262,7 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
const faMatrix<Type>& A
)
{
tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
auto tC = tmp<faMatrix<Type>>::New(A);
tC.ref().negate();
return tC;
}
@ -1288,7 +1288,7 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
)
{
checkMethod(A, B, "-");
tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
auto tC = tmp<faMatrix<Type>>::New(A);
tC.ref() -= B;
return tC;
}

View File

@ -192,8 +192,8 @@ Foam::SolverPerformance<Type> Foam::faMatrix<Type>::solve()
template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::faMatrix<Type>::residual() const
{
tmp<Field<Type>> tres(new Field<Type>(source_));
Field<Type>& res = tres().ref();
auto tres = tmp<Field<Type>>::New(source_);
auto& res = tres().ref();
addBoundarySource(res);

View File

@ -108,10 +108,7 @@ Foam::fixedValueFaPatchField<Type>::valueInternalCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Foam::zero{});
}

View File

@ -130,8 +130,8 @@ Foam::cyclicFaPatchField<Type>::patchNeighbourField() const
const Field<Type>& iField = this->primitiveField();
const labelUList& faceCells = cyclicPatch_.faceCells();
tmp<Field<Type>> tpnf(new Field<Type>(this->size()));
Field<Type>& pnf = tpnf.ref();
auto tpnf = tmp<Field<Type>>::New(this->size());
auto& pnf = tpnf.ref();
const label sizeby2 = this->size()/2;

View File

@ -143,19 +143,18 @@ Foam::wedgeFaPatchField<Type>::snGradTransformDiag() const
const vector diagV(diagT.xx(), diagT.yy(), diagT.zz());
return tmp<Field<Type>>
return tmp<Field<Type>>::New
(
new Field<Type>
this->size(),
transformMask<Type>
(
this->size(),
transformMask<Type>
pow
(
pow
(
diagV,
pTraits<typename powProduct<vector, pTraits<Type>::rank>
::type>::zero
)
diagV,
pTraits
<
typename powProduct<vector, pTraits<Type>::rank>::type
>::zero
)
)
);

View File

@ -149,10 +149,7 @@ public:
//- Return gradient at boundary
virtual tmp<Field<Type>> snGrad() const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Foam::zero{});
}
//- Evaluate the patch field

View File

@ -95,10 +95,7 @@ Foam::fixedValueOutflowFaPatchField<Type>::valueInternalCoeffs
const tmp<scalarField>& weights
) const
{
return tmp<Field<Type>>
(
new Field<Type>(Type(pTraits<Type>::one)*weights)
);
return pTraits<Type>::one*weights;
}

View File

@ -377,10 +377,7 @@ public:
const DimensionedField<Type, edgeMesh>& iF
) const
{
return tmp<faePatchField<Type>>
(
new faePatchField<Type>(*this, iF)
);
return tmp<faePatchField<Type>>::New(*this, iF);
}

View File

@ -34,9 +34,6 @@ License
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace fa
{
@ -84,19 +81,9 @@ tmp<divScheme<Type>> divScheme<Type>::New
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
divScheme<Type>::~divScheme()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fa
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef faDivScheme_H
#define faDivScheme_H
#ifndef Foam_faDivScheme_H
#define Foam_faDivScheme_H
#include "tmp.H"
#include "areaFieldsFwd.H"
@ -50,9 +50,8 @@ SourceFiles
namespace Foam
{
template<class Type>
class faMatrix;
// Forward Declarations
template<class Type> class faMatrix;
class faMesh;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -69,12 +68,12 @@ class divScheme
:
public refCount
{
protected:
// Protected data
// Protected Data
const faMesh& mesh_;
tmp<edgeInterpolationScheme<Type>> tinterpScheme_;
@ -113,9 +112,23 @@ public:
//- Construct from mesh and Istream
divScheme(const faMesh& mesh, Istream& is)
:
mesh_(mesh),
tinterpScheme_(edgeInterpolationScheme<Type>::New(mesh, is))
{}
mesh_(mesh)
{
if (is.eof())
{
tinterpScheme_.reset
(
new linearEdgeInterpolation<Type>(mesh)
);
}
else
{
tinterpScheme_.reset
(
edgeInterpolationScheme<Type>::New(mesh, is)
);
}
}
// Selectors
@ -129,7 +142,7 @@ public:
//- Destructor
virtual ~divScheme();
virtual ~divScheme() = default;
// Member Functions

View File

@ -76,7 +76,7 @@ public:
// Constructors
//- Construct null
//- Construct from mesh
gaussDivScheme(const faMesh& mesh)
:
divScheme<Type>(mesh)

View File

@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef gaussFaGrad_H
#define gaussFaGrad_H
#ifndef Foam_gaussFaGrad_H
#define Foam_gaussFaGrad_H
#include "faGradScheme.H"
#include "edgeInterpolationScheme.H"
@ -96,24 +96,21 @@ public:
//- Construct from Istream
gaussGrad(const faMesh& mesh, Istream& is)
:
gradScheme<Type>(mesh),
tinterpScheme_(nullptr)
gradScheme<Type>(mesh)
{
if (is.eof())
{
tinterpScheme_ =
tmp<edgeInterpolationScheme<Type>>
(
new linearEdgeInterpolation<Type>(mesh)
);
tinterpScheme_.reset
(
new linearEdgeInterpolation<Type>(mesh)
);
}
else
{
tinterpScheme_ =
tmp<edgeInterpolationScheme<Type>>
(
edgeInterpolationScheme<Type>::New(mesh, is)
);
tinterpScheme_.reset
(
edgeInterpolationScheme<Type>::New(mesh, is)
);
}
}

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef faLaplacianScheme_H
#define faLaplacianScheme_H
#ifndef Foam_faLaplacianScheme_H
#define Foam_faLaplacianScheme_H
#include "tmp.H"
#include "areaFieldsFwd.H"
@ -51,9 +51,8 @@ SourceFiles
namespace Foam
{
template<class Type>
class faMatrix;
// Forward Declarations
template<class Type> class faMatrix;
class faMesh;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -70,12 +69,12 @@ class laplacianScheme
:
public refCount
{
protected:
// Protected data
// Protected Data
const faMesh& mesh_;
tmp<edgeInterpolationScheme<scalar>> tinterpGammaScheme_;
tmp<lnGradScheme<Type>> tlnGradScheme_;
@ -116,30 +115,28 @@ public:
//- Construct from mesh and Istream
laplacianScheme(const faMesh& mesh, Istream& is)
:
mesh_(mesh),
tinterpGammaScheme_(nullptr),
tlnGradScheme_(nullptr)
mesh_(mesh)
{
if (is.eof())
{
tinterpGammaScheme_ = tmp<edgeInterpolationScheme<scalar>>
tinterpGammaScheme_.reset
(
new linearEdgeInterpolation<scalar>(mesh)
);
tlnGradScheme_ = tmp<lnGradScheme<Type>>
tlnGradScheme_.reset
(
new correctedLnGrad<Type>(mesh)
);
}
else
{
tinterpGammaScheme_ = tmp<edgeInterpolationScheme<scalar>>
tinterpGammaScheme_.reset
(
edgeInterpolationScheme<scalar>::New(mesh, is)
);
tlnGradScheme_ = tmp<lnGradScheme<Type>>
tlnGradScheme_.reset
(
lnGradScheme<Type>::New(mesh, is)
);
@ -218,11 +215,11 @@ public:
\
namespace Foam \
{ \
namespace fa \
{ \
laplacianScheme<Type>::addIstreamConstructorToTable<SS<Type>> \
add##SS##Type##IstreamConstructorToTable_; \
} \
namespace fa \
{ \
laplacianScheme<Type>::addIstreamConstructorToTable<SS<Type>> \
add##SS##Type##IstreamConstructorToTable_; \
} \
}

View File

@ -35,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef gaussFaLaplacianScheme_H
#define gaussFaLaplacianScheme_H
#ifndef Foam_gaussFaLaplacianScheme_H
#define Foam_gaussFaLaplacianScheme_H
#include "faLaplacianScheme.H"
@ -76,7 +76,7 @@ public:
// Constructors
//- Construct null
//- Construct from mesh
gaussLaplacianScheme(const faMesh& mesh)
:
laplacianScheme<Type>(mesh)

View File

@ -188,18 +188,13 @@ Foam::tmp<Foam::volVectorField> Foam::MRFZoneList::DDt
const volVectorField& U
) const
{
auto tacceleration =
tmp<volVectorField>::New
(
IOobject
(
"MRFZoneList:acceleration",
U.mesh().time().timeName(),
U.mesh().thisDb()
),
U.mesh(),
dimensionedVector(U.dimensions()/dimTime, Zero)
);
auto tacceleration = volVectorField::New
(
IOobject::scopedName("MRFZoneList", "acceleration"),
IOobject::NO_REGISTER,
U.mesh(),
dimensionedVector(U.dimensions()/dimTime, Zero)
);
auto& acceleration = tacceleration.ref();
for (const auto& mrf: *this)
@ -263,10 +258,8 @@ Foam::tmp<Foam::surfaceScalarField> Foam::MRFZoneList::relative
return rphi;
}
else
{
return tmp<surfaceScalarField>(tphi, true);
}
return tmp<surfaceScalarField>(tphi, true);
}
@ -289,10 +282,8 @@ Foam::MRFZoneList::relative
return rphi;
}
else
{
return tmp<FieldField<fvsPatchField, scalar>>(tphi, true);
}
return tmp<FieldField<fvsPatchField, scalar>>(tphi, true);
}
@ -316,10 +307,8 @@ Foam::MRFZoneList::relative
return rphi;
}
else
{
return tmp<Field<scalar>>(tphi, true);
}
return tmp<Field<scalar>>(tphi, true);
}
@ -378,10 +367,8 @@ Foam::tmp<Foam::surfaceScalarField> Foam::MRFZoneList::absolute
return rphi;
}
else
{
return tmp<surfaceScalarField>(tphi, true);
}
return tmp<surfaceScalarField>(tphi, true);
}

View File

@ -55,8 +55,9 @@ Foam::SRF::SRFModel::SRFModel
"SRFProperties",
Urel.time().constant(),
Urel.db(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
IOobject::READ_MODIFIED,
IOobject::NO_WRITE,
IOobject::REGISTER
)
),
Urel_(Urel),
@ -118,19 +119,12 @@ const Foam::dimensionedVector& Foam::SRF::SRFModel::omega() const
Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh>>
Foam::SRF::SRFModel::Fcoriolis() const
{
return tmp<volVectorField::Internal>
return volVectorField::Internal::New
(
new volVectorField::Internal
"Fcoriolis",
IOobject::NO_REGISTER,
(
IOobject
(
"Fcoriolis",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
2.0*omega_ ^ Urel_
2.0*omega_ ^ Urel_.internalField()
)
);
}
@ -139,18 +133,11 @@ Foam::SRF::SRFModel::Fcoriolis() const
Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh>>
Foam::SRF::SRFModel::Fcentrifugal() const
{
return tmp<volVectorField::Internal>
return volVectorField::Internal::New
(
new volVectorField::Internal
"Fcentrifugal",
IOobject::NO_REGISTER,
(
IOobject
(
"Fcentrifugal",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
omega_ ^ (omega_ ^ (mesh_.C().internalField() - origin_))
)
);
@ -169,14 +156,14 @@ Foam::vectorField Foam::SRF::SRFModel::velocity
const vectorField& positions
) const
{
tmp<vectorField> tfld =
return vectorField
(
omega_.value()
^ (
(positions - origin_.value())
- axis_*(axis_ & (positions - origin_.value()))
);
return tfld();
)
);
}
@ -186,18 +173,11 @@ Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::U() const
volVectorField::Boundary::localConsistency = 0;
tmp<volVectorField> relPos(mesh_.C() - origin_);
tmp<volVectorField> tU
auto tU = volVectorField::New
(
new volVectorField
"Usrf",
IOobject::NO_REGISTER,
(
IOobject
(
"Usrf",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
omega_ ^ (relPos() - axis_*(axis_ & relPos()))
)
);
@ -211,24 +191,13 @@ Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::Uabs() const
{
tmp<volVectorField> Usrf = U();
tmp<volVectorField> tUabs
auto tUabs = volVectorField::New
(
new volVectorField
(
IOobject
(
"Uabs",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
Usrf
)
"Uabs",
IOobject::NO_REGISTER,
Usrf
);
volVectorField& Uabs = tUabs.ref();
auto& Uabs = tUabs.ref();
// Add SRF contribution to internal field
Uabs.primitiveFieldRef() += Urel_.primitiveField();

View File

@ -42,8 +42,8 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::source
{
checkApplied();
tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds));
fvMatrix<Type>& mtx = tmtx.ref();
auto tmtx = tmp<fvMatrix<Type>>::New(field, ds);
auto& mtx = tmtx.ref();
for (fv::option& source : *this)
{
@ -129,8 +129,8 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator()
rho.dimensions()*field.dimensions()/dimTime*dimVolume
);
tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds));
fvMatrix<Type>& mtx = tmtx.ref();
auto tmtx = tmp<fvMatrix<Type>>::New(field, ds);
auto& mtx = tmtx.ref();
for (fv::option& source : *this)
{
@ -198,8 +198,8 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator()
/dimTime*dimVolume
);
tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds));
fvMatrix<Type>& mtx = tmtx.ref();
auto tmtx = tmp<fvMatrix<Type>>::New(field, ds);
auto& mtx = tmtx.ref();
for (fv::option& source : *this)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -102,7 +102,7 @@ Foam::fv::options::options
Foam::fv::options& Foam::fv::options::New(const fvMesh& mesh)
{
options* ptr = mesh.thisDb().getObjectPtr<options>(typeName);
auto* ptr = mesh.thisDb().getObjectPtr<options>(typeName);
if (!ptr)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,21 +42,14 @@ Foam::levelSetFraction
const bool above
)
{
tmp<DimensionedField<scalar, volMesh>> tResult
auto tResult = DimensionedField<scalar, volMesh>::New
(
new DimensionedField<scalar, volMesh>
(
IOobject
(
"levelSetFraction",
mesh.time().timeName(),
mesh
),
mesh,
dimensionedScalar(dimless, Zero)
)
"levelSetFraction",
IOobject::NO_REGISTER,
mesh,
dimensionedScalar(dimless, Zero)
);
DimensionedField<scalar, volMesh>& result = tResult.ref();
auto& result = tResult.ref();
forAll(result, cI)
{
@ -113,8 +106,8 @@ Foam::tmp<Foam::scalarField> Foam::levelSetFraction
const bool above
)
{
tmp<scalarField> tResult(new scalarField(patch.size(), Zero));
scalarField& result = tResult.ref();
auto tResult = tmp<scalarField>::New(patch.size(), Zero);
auto& result = tResult.ref();
forAll(result, fI)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -45,21 +45,14 @@ Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh>> Foam::levelSetAverage
const DimensionedField<Type, pointMesh>& negativeP
)
{
tmp<DimensionedField<Type, volMesh>> tResult
auto tresult = DimensionedField<Type, volMesh>::New
(
new DimensionedField<Type, volMesh>
(
IOobject
(
positiveC.name() + ":levelSetAverage",
mesh.time().timeName(),
mesh
),
mesh,
dimensioned<Type>(positiveC.dimensions(), Zero)
)
IOobject::scopedName(positiveC.name(), "levelSetAverage"),
mesh,
Foam::zero{}, // value
positiveC.dimensions()
);
DimensionedField<Type, volMesh>& result = tResult.ref();
auto& result = tresult.ref();
forAll(result, cI)
{
@ -114,7 +107,7 @@ Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh>> Foam::levelSetAverage
result[cI] = r/v;
}
return tResult;
return tresult;
}
@ -132,8 +125,8 @@ Foam::tmp<Foam::Field<Type>> Foam::levelSetAverage
{
typedef typename outerProduct<Type, vector>::type sumType;
tmp<Field<Type>> tResult(new Field<Type>(patch.size(), Zero));
Field<Type>& result = tResult.ref();
auto tResult = tmp<Field<Type>>::New(patch.size(), Zero);
auto& result = tResult.ref();
forAll(result, fI)
{

View File

@ -126,32 +126,18 @@ void Foam::porosityModels::DarcyForchheimer::calcTransformModelData()
{
volTensorField Dout
(
IOobject
(
typeName + ":D",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_.newIOobject(IOobject::scopedName(typeName, "D")),
mesh_,
dimensionedTensor(dXYZ_.dimensions(), Zero)
);
volTensorField Fout
(
IOobject
(
typeName + ":F",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_.newIOobject(IOobject::scopedName(typeName, "F")),
mesh_,
dimensionedTensor(fXYZ_.dimensions(), Zero)
);
forAll(cellZoneIDs_, zonei)
{
const labelList& cells = mesh_.cellZones()[cellZoneIDs_[zonei]];

View File

@ -173,7 +173,7 @@ Foam::tmp<Foam::vectorField> Foam::porosityModel::porosityModel::force
{
transformModelData();
tmp<vectorField> tforce(new vectorField(U.size(), Zero));
auto tforce = tmp<vectorField>::New(U.size(), Zero);
if (!cellZoneIDs_.empty())
{

View File

@ -119,10 +119,7 @@ Foam::fixedValueFvPatchField<Type>::valueInternalCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Foam::zero{});
}

View File

@ -112,10 +112,7 @@ Foam::zeroGradientFvPatchField<Type>::valueInternalCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), pTraits<Type>::one)
);
return tmp<Field<Type>>::New(this->size(), pTraits<Type>::one);
}
@ -126,10 +123,7 @@ Foam::zeroGradientFvPatchField<Type>::valueBoundaryCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Foam::zero{});
}
@ -137,10 +131,7 @@ template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::zeroGradientFvPatchField<Type>::gradientInternalCoeffs() const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Foam::zero{});
}
@ -148,10 +139,7 @@ template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::zeroGradientFvPatchField<Type>::gradientBoundaryCoeffs() const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Foam::zero{});
}

Some files were not shown because too many files have changed in this diff Show More