Commit 5a8072e9 authored by Andrew Heather's avatar Andrew Heather
Browse files

added clean restart option - defaults to false to recapture original behaviour

parent 61aadcdb
......@@ -170,6 +170,7 @@ Foam::fieldAverage::fieldAverage
name_(name),
obr_(obr),
active_(true),
cleanRestart_(dict.lookupOrDefault<Switch>("cleanRestart", false)),
faItems_(dict.lookup("fields")),
meanScalarFields_(faItems_.size()),
meanVectorFields_(faItems_.size()),
......@@ -326,29 +327,44 @@ void Foam::fieldAverage::writeAveragingProperties() const
void Foam::fieldAverage::readAveragingProperties()
{
IFstream propsFile
(
obr_.time().path()/obr_.time().timeName()
/"uniform"/"fieldAveragingProperties"
);
if (!propsFile.good())
if (cleanRestart_)
{
return;
Info<< "fieldAverage: starting averaging at time "
<< obr_.time().timeName() << nl << endl;
}
else
{
IFstream propsFile
(
obr_.time().path()/obr_.time().timeName()
/"uniform"/"fieldAveragingProperties"
);
if (!propsFile.good())
{
Info<< "fieldAverage: starting averaging at time "
<< obr_.time().timeName() << nl << endl;
return;
}
dictionary propsDict(dictionary::null, propsFile);
dictionary propsDict(dictionary::null, propsFile);
forAll(faItems_, i)
{
const word& fieldName = faItems_[i].fieldName();
if (propsDict.found(fieldName))
Info<< "fieldAverage: restarting averaging for fields:" << endl;
forAll(faItems_, i)
{
dictionary fieldDict(propsDict.subDict(fieldName));
const word& fieldName = faItems_[i].fieldName();
if (propsDict.found(fieldName))
{
dictionary fieldDict(propsDict.subDict(fieldName));
totalIter_[i] = readLabel(fieldDict.lookup("totalIter"));
totalTime_[i] = readScalar(fieldDict.lookup("totalTime"));
totalIter_[i] = readLabel(fieldDict.lookup("totalIter"));
totalTime_[i] = readScalar(fieldDict.lookup("totalTime"));
Info<< " " << fieldName
<< " iters = " << totalIter_[i]
<< " time = " << totalTime_[i] << endl;
}
}
Info<< endl;
}
}
......
......@@ -37,6 +37,10 @@ Description
// Where to load it from (if not already in solver)
functionObjectLibs ("libfieldAverage.so");
// Whether to perform a clean restart, or start from previous
// averaging info if available
cleanRestart true;
// Fields to be probed. runTime modifiable!
fields
(
......@@ -80,6 +84,7 @@ SourceFiles
#include "volFieldsFwd.H"
#include "pointFieldFwd.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -114,6 +119,9 @@ protected:
//- On/off switch
bool active_;
//- Clean restart flag
Switch cleanRestart_;
//- List of field average items, describing waht averages to be
// calculated and output
List<fieldAverageItem> faItems_;
......
Supports Markdown
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