Commit c554dc7b authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: ensure written and evaluated values correspond (issue #311)

- Avoids possible discrepancy when the user selects non-coincidental
  values for executeInterval and writeInterval.

- zeroGradient and ddt2 function objects
parent cbf43acd
......@@ -112,6 +112,7 @@ Foam::functionObjects::ddt2::ddt2
)
:
fvMeshFunctionObject(name, runTime, dict),
prevTimeIndex_(-1),
selectFields_(),
resultName_(word::null),
blacklist_(),
......@@ -217,12 +218,20 @@ 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,6 +101,9 @@ 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,6 +100,7 @@ Foam::functionObjects::zeroGradient::zeroGradient
)
:
fvMeshFunctionObject(name, runTime, dict),
prevTimeIndex_(-1),
selectFields_(),
resultName_(string::null),
results_()
......@@ -174,12 +175,20 @@ 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,6 +95,9 @@ class zeroGradient
{
// Private data
//- Time at last execute, ensures write uses up-to-date values
label prevTimeIndex_;
//- Name of fields to process
wordReList selectFields_;
......
Markdown is supported
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