mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Function objects - ensure objects are up-to-date when writing
This commit is contained in:
@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user