ENH: Added onStart option to timeControl for function object control

Triggers function object to execute on the first time step.

Example usage:

    minMax1
    {
        type            fieldMinMax;
        libs            (fieldFunctionObjects);
        writeControl    onStart;
        fields          (".*");
    }

Ref: EP2608
This commit is contained in:
Andrew Heather 2025-04-04 12:48:38 +01:00
parent ad037ac744
commit e2e03fd70d
2 changed files with 10 additions and 2 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2019, 2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -47,6 +47,7 @@ Foam::timeControl::controlNames_
{ timeControl::ocAdjustableRunTime, "adjustableRunTime" },
{ timeControl::ocClockTime, "clockTime" },
{ timeControl::ocCpuTime, "cpuTime" },
{ timeControl::ocOnStart, "onStart" },
{ timeControl::ocOnEnd, "onEnd" },
});
@ -257,6 +258,12 @@ bool Foam::timeControl::execute()
break;
}
case ocOnStart:
{
return time_.timeIndex() == 1;
break;
}
case ocOnEnd:
{
scalar endTime = time_.endTime().value() - 0.5*time_.deltaTValue();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019, 2025 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -74,6 +74,7 @@ public:
ocAdjustableRunTime, //!< Currently identical to "runTime"
ocClockTime, //!< Use clock time for execution
ocCpuTime, //!< Use CPU time for execution
ocOnStart, //!< Execute on first step of run
ocOnEnd //!< Execute on end of run
};