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:
Will Bainbridge
2019-09-30 11:20:16 +01:00
parent 54f379f668
commit 1bbac95448
7 changed files with 59 additions and 31 deletions

View File

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