mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: allow specific restart time for field averaging (issue #282)
- Can currently have a periodic restart, but for simulations with a known run-up, it can be useful to have a specific time to restart the averaging. - Note that the restartTime acts as a 'single-shot'. If the restartTime is already in the past when a simulation is started, it is ignored. If, during a simulation, the restartTime is crossed, it will be triggered and then set itself to be ignored in the future.
This commit is contained in:
@ -141,12 +141,24 @@ void Foam::functionObjects::fieldAverage::calcAverages()
|
||||
prevTimeIndex_ = currentTimeIndex;
|
||||
}
|
||||
|
||||
bool doRestart = false;
|
||||
if (periodicRestart_ && currentTime > restartPeriod_*periodIndex_)
|
||||
{
|
||||
restart();
|
||||
doRestart = true;
|
||||
periodIndex_++;
|
||||
}
|
||||
|
||||
if (currentTime >= restartTime_)
|
||||
{
|
||||
doRestart = true; // Restart is overdue.
|
||||
restartTime_ = GREAT; // Avoid triggering again
|
||||
}
|
||||
|
||||
if (doRestart)
|
||||
{
|
||||
restart();
|
||||
}
|
||||
|
||||
Log
|
||||
<< type() << " " << name() << " write:" << nl
|
||||
<< " Calculating averages" << nl;
|
||||
@ -262,6 +274,7 @@ Foam::functionObjects::fieldAverage::fieldAverage
|
||||
restartOnOutput_(false),
|
||||
periodicRestart_(false),
|
||||
restartPeriod_(GREAT),
|
||||
restartTime_(GREAT),
|
||||
initialised_(false),
|
||||
faItems_(),
|
||||
totalIter_(),
|
||||
@ -296,6 +309,25 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
||||
if (periodicRestart_)
|
||||
{
|
||||
dict.lookup("restartPeriod") >> restartPeriod_;
|
||||
Log
|
||||
<< " Restart period " << restartPeriod_
|
||||
<< nl << endl;
|
||||
}
|
||||
|
||||
restartTime_ = GREAT;
|
||||
if (dict.readIfPresent("restartTime", restartTime_))
|
||||
{
|
||||
if (restartTime_ < obr_.time().value())
|
||||
{
|
||||
// The restart time is already in the past - ignore
|
||||
restartTime_ = GREAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log
|
||||
<< " Restart scheduled at time " << restartTime_
|
||||
<< nl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
readAveragingProperties();
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -106,6 +106,7 @@ Usage
|
||||
restartOnOutput | Restart the averaging on output | no | no
|
||||
periodicRestart | Periodically restart the averaging | no | no
|
||||
restartPeriod | Periodic restart period | conditional |
|
||||
restartTime | One-shot reset of the averaging | no | great
|
||||
fields | list of fields and averaging options | yes |
|
||||
\endtable
|
||||
|
||||
@ -166,6 +167,9 @@ protected:
|
||||
//- Restart period
|
||||
scalar restartPeriod_;
|
||||
|
||||
//- Specific restart time
|
||||
scalar restartTime_;
|
||||
|
||||
//- Initialised flag
|
||||
bool initialised_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user