diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index 62e6ed1ea9..de7a49be4e 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -808,13 +808,13 @@ bool Foam::Time::run() const { if (!running && timeIndex_ != startTimeIndex_) { + functionObjects_.execute(); + functionObjects_.end(); + if (cacheTemporaryObjects_) { cacheTemporaryObjects_ = checkCacheTemporaryObjects(); } - - functionObjects_.execute(); - functionObjects_.end(); } } @@ -830,12 +830,12 @@ bool Foam::Time::run() const } else { + functionObjects_.execute(); + if (cacheTemporaryObjects_) { cacheTemporaryObjects_ = checkCacheTemporaryObjects(); } - - functionObjects_.execute(); } } diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C b/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C index dbcd505707..946a050f32 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C +++ b/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C @@ -196,7 +196,19 @@ const Type& Foam::objectRegistry::lookupObject(const word& name) const << " " << name << " from objectRegistry " << this->name() << " failed\n available objects of type " << Type::typeName << " are" << nl - << names() + << names(); + + if (cacheTemporaryObject(name)) + { + FatalErrorInFunction + << nl + << " request for " << name << " from objectRegistry " + << this->name() << " to be cached failed" << nl + << " available temporary objects are" << nl + << temporaryObjects_; + } + + FatalErrorInFunction << abort(FatalError); } diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C index 8164b8fa76..926808c1db 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C @@ -283,7 +283,7 @@ DimensionedField::New mesh, IOobject::NO_READ, IOobject::NO_WRITE, - false + mesh.cacheTemporaryObject(name) ), mesh, ds, @@ -313,7 +313,7 @@ DimensionedField::New mesh, IOobject::NO_READ, IOobject::NO_WRITE, - false + mesh.cacheTemporaryObject(name) ), mesh, dt, @@ -343,7 +343,7 @@ DimensionedField::New df.db(), IOobject::NO_READ, IOobject::NO_WRITE, - false + df.db().cacheTemporaryObject(newName) ), df ) @@ -371,7 +371,7 @@ DimensionedField::New tdf().db(), IOobject::NO_READ, IOobject::NO_WRITE, - false + tdf().db().cacheTemporaryObject(newName) ), tdf ) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index eba598ae9a..4e1988998f 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -763,7 +763,7 @@ Foam::GeometricField::New diField.mesh().thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, - false + diField.mesh().thisDb().cacheTemporaryObject(name) ), diField, ptfl @@ -793,7 +793,7 @@ Foam::GeometricField::New mesh.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, - false + mesh.thisDb().cacheTemporaryObject(name) ), mesh, ds, @@ -824,7 +824,7 @@ Foam::GeometricField::New mesh.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, - false + mesh.thisDb().cacheTemporaryObject(name) ), mesh, dt, @@ -857,7 +857,7 @@ Foam::GeometricField::New mesh.thisDb(), IOobject::NO_READ, IOobject::NO_WRITE, - false + mesh.thisDb().cacheTemporaryObject(name) ), mesh, dt, @@ -888,7 +888,7 @@ Foam::GeometricField::New tgf().db(), IOobject::NO_READ, IOobject::NO_WRITE, - false + tgf().db().cacheTemporaryObject(newName) ), tgf ) @@ -918,7 +918,7 @@ Foam::GeometricField::New tgf().db(), IOobject::NO_READ, IOobject::NO_WRITE, - false + tgf().db().cacheTemporaryObject(newName) ), tgf, patchFieldTypes, diff --git a/src/TurbulenceModels/compressible/ThermalDiffusivity/ThermalDiffusivity.H b/src/TurbulenceModels/compressible/ThermalDiffusivity/ThermalDiffusivity.H index fcd4cfa130..72682f0031 100644 --- a/src/TurbulenceModels/compressible/ThermalDiffusivity/ThermalDiffusivity.H +++ b/src/TurbulenceModels/compressible/ThermalDiffusivity/ThermalDiffusivity.H @@ -142,7 +142,11 @@ public: // of mixture [W/m/K] virtual tmp kappaEff() const { - return kappa(); + return volScalarField::New + ( + "kappaEff", + this->transport_.kappa() + ); } //- Effective thermal turbulent diffusivity for temperature @@ -155,7 +159,11 @@ public: //- Effective thermal turbulent diffusivity of mixture [kg/m/s] virtual tmp alphaEff() const { - return this->transport_.alphahe(); + return volScalarField::New + ( + "alphaEff", + this->transport_.alphahe() + ); } //- Effective thermal turbulent diffusivity of mixture diff --git a/src/functionObjects/solvers/scalarTransport/scalarTransport.C b/src/functionObjects/solvers/scalarTransport/scalarTransport.C index d8a2ec239c..429f28f76c 100644 --- a/src/functionObjects/solvers/scalarTransport/scalarTransport.C +++ b/src/functionObjects/solvers/scalarTransport/scalarTransport.C @@ -172,7 +172,7 @@ bool Foam::functionObjects::scalarTransport::execute() mesh_.lookupObject(phiName_); // Calculate the diffusivity - volScalarField D(this->D(phi)); + volScalarField D("D" + s_.name(), this->D(phi)); word divScheme("div(phi," + schemesField_ + ")"); word laplacianScheme("laplacian(" + D.name() + "," + schemesField_ + ")"); diff --git a/src/thermophysicalModels/basic/heThermo/heThermo.C b/src/thermophysicalModels/basic/heThermo/heThermo.C index ee01e10260..fe01421575 100644 --- a/src/thermophysicalModels/basic/heThermo/heThermo.C +++ b/src/thermophysicalModels/basic/heThermo/heThermo.C @@ -633,9 +633,11 @@ template Foam::tmp Foam::heThermo::kappa() const { - tmp kappa(Cp()*this->alpha_); - kappa.ref().rename("kappa"); - return kappa; + return volScalarField::New + ( + "kappa", + Cp()*this->alpha_ + ); } @@ -659,9 +661,11 @@ template Foam::tmp Foam::heThermo::alphahe() const { - tmp alphaEff(this->CpByCpv()*this->alpha_); - alphaEff.ref().rename("alphahe"); - return alphaEff; + return volScalarField::New + ( + "alphahe", + this->CpByCpv()*this->alpha_ + ); } @@ -687,9 +691,11 @@ Foam::heThermo::kappaEff const volScalarField& alphat ) const { - tmp kappaEff(Cp()*(this->alpha_ + alphat)); - kappaEff.ref().rename("kappaEff"); - return kappaEff; + return volScalarField::New + ( + "kappaEff", + Cp()*(this->alpha_ + alphat) + ); } @@ -719,9 +725,11 @@ Foam::heThermo::alphaEff const volScalarField& alphat ) const { - tmp alphaEff(this->CpByCpv()*(this->alpha_ + alphat)); - alphaEff.ref().rename("alphaEff"); - return alphaEff; + return volScalarField::New + ( + "alphaEff", + this->CpByCpv()*(this->alpha_ + alphat) + ); }