ENH: Function objects - ensure objects are up-to-date when writing

This commit is contained in:
Andrew Heather
2016-11-24 12:36:52 +00:00
parent 7734d7ffd7
commit fb78378959
2 changed files with 13 additions and 1 deletions

View File

@ -77,7 +77,8 @@ Foam::functionObjects::timeControl::timeControl
),
executeControl_(t, dict, "execute"),
writeControl_(t, dict, "write"),
foPtr_(functionObject::New(name, t, dict_))
foPtr_(functionObject::New(name, t, dict_)),
executeTimeIndex_(-1)
{
readControls();
}
@ -89,6 +90,7 @@ bool Foam::functionObjects::timeControl::execute()
{
if (active() && (postProcess || executeControl_.execute()))
{
executeTimeIndex_ = time_.timeIndex();
foPtr_->execute();
}
@ -100,6 +102,13 @@ bool Foam::functionObjects::timeControl::write()
{
if (active() && (postProcess || writeControl_.execute()))
{
// Ensure written results reflect the current state
if (executeTimeIndex_ != time_.timeIndex())
{
executeTimeIndex_ = time_.timeIndex();
foPtr_->execute();
}
foPtr_->write();
}