ENH: make resetOnRestart optional for valueAverage (issue #360)

ENH: ensure averaging flags are not 'sticky' (see issue #331)
This commit is contained in:
Mark Olesen
2016-12-22 13:00:05 +01:00
parent 9e645179ad
commit 3fc66cb710
3 changed files with 14 additions and 6 deletions

View File

@ -293,13 +293,19 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
// Make certain that the values are consistent with the defaults:
initialised_ = false;
restartOnRestart_ = false;
restartOnOutput_ = false;
periodicRestart_ = false;
restartPeriod_ = GREAT;
restartTime_ = GREAT;
Info<< type() << " " << name() << ":" << nl;
dict.readIfPresent("restartOnRestart", restartOnRestart_);
dict.readIfPresent("restartOnOutput", restartOnOutput_);
dict.readIfPresent("periodicRestart", periodicRestart_);
dict.readIfPresent("restartOnOutput", restartOnOutput_);
dict.readIfPresent("periodicRestart", periodicRestart_);
dict.lookup("fields") >> faItems_;
const scalar currentTime = obr().time().value();
@ -331,7 +337,6 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
}
}
restartTime_ = GREAT;
if (dict.readIfPresent("restartTime", restartTime_))
{
if (currentTime > restartTime_)

View File

@ -109,6 +109,9 @@ bool Foam::functionObjects::valueAverage::read(const dictionary& dict)
regionFunctionObject::read(dict);
writeFile::read(dict);
// Make certain that the values are consistent with the defaults:
resetOnRestart_ = false;
dict.lookup("functionObject") >> functionObjectName_;
dict.lookup("fields") >> fieldNames_;
window_ = dict.lookupOrDefault<scalar>("window", -1);
@ -119,7 +122,7 @@ bool Foam::functionObjects::valueAverage::read(const dictionary& dict)
totalTime_[i] = time_.deltaTValue();
}
resetOnRestart_ = readBool(dict.lookup("resetOnRestart"));
dict.readIfPresent("resetOnRestart", resetOnRestart_);
return true;
}

View File

@ -55,7 +55,7 @@ Usage
log | write average data to standard output | no | yes
fields | list of fields to process | yes |
functionObject | Name of function object to retrieve data from | yes |
resetOnRestart | Reset the averaging on restart | yes |
resetOnRestart | Reset the averaging on restart | no | no |
\endtable
Output data is written to the file \<timeDir\>/valueAverage.dat
@ -110,7 +110,7 @@ protected:
List<scalar> totalTime_;
//- Reset the averaging process on restart
bool resetOnRestart_;
Switch resetOnRestart_;
// Protected Member Functions