Commit c4e63c4c authored by Henry Weller's avatar Henry Weller
Browse files

functionObjects::functionObjects: Corrected initial totalTime for cases with variable time-step

Resolves bug-report https://bugs.openfoam.org/view.php?id=2459
parent f5e88d6e
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -67,6 +67,16 @@ void Foam::functionObjects::fieldAverage::resetFields()
void Foam::functionObjects::fieldAverage::initialize()
{
if (!totalIter_.size())
{
totalIter_.setSize(faItems_.size(), 1);
}
if (!totalTime_.size())
{
totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue());
}
resetFields();
// Add mean fields to the field lists
......@@ -95,15 +105,11 @@ void Foam::functionObjects::fieldAverage::initialize()
void Foam::functionObjects::fieldAverage::restart()
{
Log
<< " Restarting averaging at time " << obr_.time().timeName()
Log << " Restarting averaging at time " << obr_.time().timeName()
<< nl << endl;
totalIter_.clear();
totalIter_.setSize(faItems_.size(), 1);
totalTime_.clear();
totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue());
initialize();
}
......@@ -134,8 +140,7 @@ void Foam::functionObjects::fieldAverage::calcAverages()
periodIndex_++;
}
Log
<< type() << " " << name() << " write:" << nl
Log << type() << " " << name() << " write:" << nl
<< " Calculating averages" << nl;
addMeanSqrToPrime2Mean<scalar, scalar>();
......@@ -206,12 +211,6 @@ void Foam::functionObjects::fieldAverage::writeAveragingProperties() const
void Foam::functionObjects::fieldAverage::readAveragingProperties()
{
totalIter_.clear();
totalIter_.setSize(faItems_.size(), 1);
totalTime_.clear();
totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue());
if ((restartOnRestart_ || restartOnOutput_) && log)
{
Info<< " Starting averaging at time " << obr_.time().timeName()
......@@ -232,8 +231,7 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
if (!propsDictHeader.headerOk())
{
Log
<< " Starting averaging at time "
Log << " Starting averaging at time "
<< obr_.time().timeName() << nl;
return;
......@@ -243,6 +241,9 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
Log << " Restarting averaging for fields:" << nl;
totalIter_.setSize(faItems_.size(), 1);
totalTime_.setSize(faItems_.size());
forAll(faItems_, fieldi)
{
const word& fieldName = faItems_[fieldi].fieldName();
......@@ -253,8 +254,7 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
totalIter_[fieldi] = readLabel(fieldDict.lookup("totalIter"));
totalTime_[fieldi] = readScalar(fieldDict.lookup("totalTime"));
Log
<< " " << fieldName
Log << " " << fieldName
<< " iters = " << totalIter_[fieldi]
<< " time = " << totalTime_[fieldi] << nl;
}
......
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