Skip to content
Snippets Groups Projects
Commit fb783789 authored by Andrew Heather's avatar Andrew Heather
Browse files

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

parent 7734d7ff
Branches
Tags
No related merge requests found
......@@ -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();
}
......
......@@ -99,6 +99,9 @@ class timeControl
//- The functionObject to execute
autoPtr<functionObject> foPtr_;
//- Time index of the last execute call
label executeTimeIndex_;
// Private Member Functions
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment