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

Merge branch 'feature-functionObject-consistentWrite' into 'develop'

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

See merge request !79
parents 59f4a137 0cdd0347
No related branches found
No related tags found
1 merge request!79Function objects - ensure objects are up-to-date when writing
......@@ -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
......
......@@ -112,7 +112,6 @@ Foam::functionObjects::ddt2::ddt2
)
:
fvMeshFunctionObject(name, runTime, dict),
prevTimeIndex_(-1),
selectFields_(),
resultName_(word::null),
blacklist_(),
......@@ -218,20 +217,12 @@ bool Foam::functionObjects::ddt2::execute()
<< "Unprocessed field " << ignored << endl;
}
// Update time index
prevTimeIndex_ = obr_.time().timeIndex();
return true;
}
bool Foam::functionObjects::ddt2::write()
{
if (prevTimeIndex_ < obr_.time().timeIndex())
{
// Ensure written results reflect the current state
execute();
}
if (results_.size())
{
Log << type() << ' ' << name() << " write:" << endl;
......
......@@ -101,9 +101,6 @@ class ddt2
{
// Private data
//- Time at last execute, ensures write uses up-to-date values
label prevTimeIndex_;
//- Name of fields to process
wordReList selectFields_;
......
......@@ -100,7 +100,6 @@ Foam::functionObjects::zeroGradient::zeroGradient
)
:
fvMeshFunctionObject(name, runTime, dict),
prevTimeIndex_(-1),
selectFields_(),
resultName_(string::null),
results_()
......@@ -175,20 +174,12 @@ bool Foam::functionObjects::zeroGradient::execute()
<< "Unprocessed field " << ignored << endl;
}
// Update time index
prevTimeIndex_ = obr_.time().timeIndex();
return true;
}
bool Foam::functionObjects::zeroGradient::write()
{
if (prevTimeIndex_ < obr_.time().timeIndex())
{
// Ensure written results reflect the current state
execute();
}
if (results_.size())
{
Log << type() << ' ' << name() << " write:" << endl;
......
......@@ -95,9 +95,6 @@ class zeroGradient
{
// Private data
//- Time at last execute, ensures write uses up-to-date values
label prevTimeIndex_;
//- Name of fields to process
wordReList selectFields_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment