objectRegistry: Improvements to caching of temporary objects
Cached temporary objects are now registered from the moment of construction. This means it is possible to use them before they go out of scope. Non-cached temporaries are not registered, as before. The check for the existence of requested cached objects is now done after function object evaluation. This means that caching can be done on fields generated by the function objects themselves without generating warning messages. The above, however, means that if an object isn't successfully cached and it's lookup in a function fails, then the warning will not be generated before the lookup raises an error. This could make diagnosing the reason for such a failure more difficult. To remedy this the content of the warning (i.e., the list of objects that are available for caching) has been added to the lookup error message if the looked up name is on the caching list. The same level of logged information is therefore retained in the event of caching and lookup failures.
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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<Type>()
|
||||
<< names<Type>();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -283,7 +283,7 @@ DimensionedField<Type, GeoMesh>::New
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
mesh.cacheTemporaryObject(name)
|
||||
),
|
||||
mesh,
|
||||
ds,
|
||||
@ -313,7 +313,7 @@ DimensionedField<Type, GeoMesh>::New
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
mesh.cacheTemporaryObject(name)
|
||||
),
|
||||
mesh,
|
||||
dt,
|
||||
@ -343,7 +343,7 @@ DimensionedField<Type, GeoMesh>::New
|
||||
df.db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
df.db().cacheTemporaryObject(newName)
|
||||
),
|
||||
df
|
||||
)
|
||||
@ -371,7 +371,7 @@ DimensionedField<Type, GeoMesh>::New
|
||||
tdf().db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
tdf().db().cacheTemporaryObject(newName)
|
||||
),
|
||||
tdf
|
||||
)
|
||||
|
||||
@ -763,7 +763,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||
diField.mesh().thisDb(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
diField.mesh().thisDb().cacheTemporaryObject(name)
|
||||
),
|
||||
diField,
|
||||
ptfl
|
||||
@ -793,7 +793,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||
mesh.thisDb(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
mesh.thisDb().cacheTemporaryObject(name)
|
||||
),
|
||||
mesh,
|
||||
ds,
|
||||
@ -824,7 +824,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||
mesh.thisDb(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
mesh.thisDb().cacheTemporaryObject(name)
|
||||
),
|
||||
mesh,
|
||||
dt,
|
||||
@ -857,7 +857,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||
mesh.thisDb(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
mesh.thisDb().cacheTemporaryObject(name)
|
||||
),
|
||||
mesh,
|
||||
dt,
|
||||
@ -888,7 +888,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||
tgf().db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
tgf().db().cacheTemporaryObject(newName)
|
||||
),
|
||||
tgf
|
||||
)
|
||||
@ -918,7 +918,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||
tgf().db(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
tgf().db().cacheTemporaryObject(newName)
|
||||
),
|
||||
tgf,
|
||||
patchFieldTypes,
|
||||
|
||||
@ -142,7 +142,11 @@ public:
|
||||
// of mixture [W/m/K]
|
||||
virtual tmp<volScalarField> 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<volScalarField> alphaEff() const
|
||||
{
|
||||
return this->transport_.alphahe();
|
||||
return volScalarField::New
|
||||
(
|
||||
"alphaEff",
|
||||
this->transport_.alphahe()
|
||||
);
|
||||
}
|
||||
|
||||
//- Effective thermal turbulent diffusivity of mixture
|
||||
|
||||
@ -172,7 +172,7 @@ bool Foam::functionObjects::scalarTransport::execute()
|
||||
mesh_.lookupObject<surfaceScalarField>(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_ + ")");
|
||||
|
||||
@ -633,9 +633,11 @@ template<class BasicThermo, class MixtureType>
|
||||
Foam::tmp<Foam::volScalarField>
|
||||
Foam::heThermo<BasicThermo, MixtureType>::kappa() const
|
||||
{
|
||||
tmp<Foam::volScalarField> kappa(Cp()*this->alpha_);
|
||||
kappa.ref().rename("kappa");
|
||||
return kappa;
|
||||
return volScalarField::New
|
||||
(
|
||||
"kappa",
|
||||
Cp()*this->alpha_
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -659,9 +661,11 @@ template<class BasicThermo, class MixtureType>
|
||||
Foam::tmp<Foam::volScalarField>
|
||||
Foam::heThermo<BasicThermo, MixtureType>::alphahe() const
|
||||
{
|
||||
tmp<Foam::volScalarField> 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<BasicThermo, MixtureType>::kappaEff
|
||||
const volScalarField& alphat
|
||||
) const
|
||||
{
|
||||
tmp<Foam::volScalarField> 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<BasicThermo, MixtureType>::alphaEff
|
||||
const volScalarField& alphat
|
||||
) const
|
||||
{
|
||||
tmp<Foam::volScalarField> alphaEff(this->CpByCpv()*(this->alpha_ + alphat));
|
||||
alphaEff.ref().rename("alphaEff");
|
||||
return alphaEff;
|
||||
return volScalarField::New
|
||||
(
|
||||
"alphaEff",
|
||||
this->CpByCpv()*(this->alpha_ + alphat)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user