functionObject: Added executeAtStart

By default most functionObjects now execute and write at the start-time except
those that perform averaging (fieldAverage, dsmcFields) which cannot be executed
until the end of the first time-step.  There is also a new optional
functionObject dictionary entry "executeAtStart" which defaults to true but can
be set false if the execution and results of the functionObject are not required
or appropriate at the start-time.

A result of this change is that time logs of forces, sampling etc. now include a
values for time 0.
This commit is contained in:
Henry Weller
2019-09-30 11:03:20 +01:00
parent 6f1c3362a6
commit 2ebed5ec71
8 changed files with 97 additions and 31 deletions

View File

@ -93,9 +93,23 @@ Foam::functionObjects::timeControl::timeControl
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::timeControl::executeAtStart() const
{
return foPtr_->executeAtStart();
}
bool Foam::functionObjects::timeControl::execute()
{
if (active() && (postProcess || executeControl_.execute()))
if
(
active()
&& (
postProcess
|| executeControl_.execute()
|| (executeAtStart() && time_.timeIndex() == time_.startTimeIndex())
)
)
{
foPtr_->execute();
}
@ -106,7 +120,15 @@ bool Foam::functionObjects::timeControl::execute()
bool Foam::functionObjects::timeControl::write()
{
if (active() && (postProcess || writeControl_.execute()))
if
(
active()
&& (
postProcess
|| writeControl_.execute()
|| (executeAtStart() && time_.timeIndex() == time_.startTimeIndex())
)
)
{
foPtr_->write();
}