mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
added clean restart option - defaults to false to recapture original behaviour
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
dictionary propsDict(dictionary::null, propsFile);
|
||||
|
||||
forAll(faItems_, i)
|
||||
else
|
||||
{
|
||||
const word& fieldName = faItems_[i].fieldName();
|
||||
if (propsDict.found(fieldName))
|
||||
{
|
||||
dictionary fieldDict(propsDict.subDict(fieldName));
|
||||
IFstream propsFile
|
||||
(
|
||||
obr_.time().path()/obr_.time().timeName()
|
||||
/"uniform"/"fieldAveragingProperties"
|
||||
);
|
||||
|
||||
totalIter_[i] = readLabel(fieldDict.lookup("totalIter"));
|
||||
totalTime_[i] = readScalar(fieldDict.lookup("totalTime"));
|
||||
if (!propsFile.good())
|
||||
{
|
||||
Info<< "fieldAverage: starting averaging at time "
|
||||
<< obr_.time().timeName() << nl << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
dictionary propsDict(dictionary::null, propsFile);
|
||||
|
||||
Info<< "fieldAverage: restarting averaging for fields:" << endl;
|
||||
forAll(faItems_, i)
|
||||
{
|
||||
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"));
|
||||
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_;
|
||||
|
||||
Reference in New Issue
Block a user