Skip to content

Run Time Control

RunTimeControl governs the temporal schedule of a simulation: the size of the time step, how many steps to execute, when to write VTK output, when to echo to the screen, and when to checkpoint for restart. It also holds the unit block (UnitsOfLength, UnitsOfMass, UnitsOfTime, UnitsOfEnergy) used by reports and diagnostics. During the main loop, other modules query RunTimeControl via helper predicates such as WriteVTK(), WriteRawData(), and WriteToScreen() to decide whether the current step is an output step.

Key Classes and Concepts

  • RunTimeControl: the single class in the module. Owns the time-step counters (tStep, tStart, nSteps, dt), the output intervals, the restart toggle, the unit block, and the log-mode flags.

Output schedule

The three predicates follow the same integer-modulo rule:

(1)WriteVTK()  tStep0(modVTKOutputInterval)

(2)WriteToScreen()  tStep0(modConsoleOutputInterval)

(3)WriteRawData()  tStep0(modCheckpointInterval)

The raw-data predicate is intended for binary-format checkpoint/restart dumps, not VTK.

Usage

Input

Defined in the @RunTimeControl block. Every key supports a short alias (the second name in each row below); both forms are accepted and are equivalent.

text
@RunTimeControl

$SimulationTitle Simulation title                        : Normal grain growth
$nSteps          Number of time steps                    : 2000
$FTime           Output to disk every (tSteps)           : 100
$STime           Output to screen every (tSteps)         : 100
$tRstrt          Restart output every (tSteps)           : 10000

$dt              Initial time step                       : 1e-5
$nOMP            Number of OpenMP threads                : 1

$LUnits          Units of length                         : m
$TUnits          Units of time                           : s
$MUnits          Units of mass                           : kg
$EUnits          Energy units                            : J

$Restrt          Restart switch (Yes/No)                 : No
$tStart          Restart at time step                    : 0
KeyAliasTypeDefault
$SimulationTitle$SimTtlstring
$UnitsOfLength$LUnitsstringm
$UnitsOfMass$MUnitsstringkg
$UnitsOfTime$TUnitsstrings
$UnitsOfEnergy$EUnitsstringJ
$OpenMPThreads$nOMPint
$MaxTimeStep$nStepsint
$dtdouble
$RestartSwitch$Restrtboolfalse
$StartTimeStep / $RestartTimeStep$tStartint— (required if restart)
$CheckpointInterval$tRstrtint
$VTKOutputInterval$FTimeint
$ConsoleOutputInterval$STimeint
$StopCheckIntervaldouble0.0
$LogScreenboolfalse
$LogVTKboolfalse
$LogScreenFint1
$LogVTKFint1

Output

Console diagnostics go to the log file when $LogScreen = true; VTK diagnostics go to the log file when $LogVTK = true. Both log files are written at the factor-thinned cadences $LogScreenF and $LogVTKF respectively.

Example

cpp
#include "Settings.h"
#include "RunTimeControl.h"

using namespace openphase;

int main(int argc, char *argv[])
{
    std::string InputFile = (argc > 1) ? argv[1] : "ProjectInput.opi";

    Settings       OPSettings;
    OPSettings.ReadInput(InputFile);

    RunTimeControl RTC(OPSettings, InputFile);

    for(RTC.tStep = RTC.tStart; RTC.tStep <= RTC.nSteps; RTC.IncrementTimeStep())
    {
        // ... solver updates ...

        if (RTC.WriteVTK())      { /* module.WriteVTK(OPSettings, RTC.tStep); */ }
        if (RTC.WriteRawData())  { /* module.Write(OPSettings, RTC.tStep);    */ }
        if (RTC.WriteToScreen()) { /* ConsoleOutput::WriteTimeStep(RTC, ...); */ }
    }
}

Dependencies

  • Settings — used during construction.
  • ConsoleOutput — the typical target of WriteToScreen-gated messages.

Released under the GNU GPLv3 License.