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:
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.
@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| Key | Alias | Type | Default |
|---|---|---|---|
$SimulationTitle | $SimTtl | string | — |
$UnitsOfLength | $LUnits | string | m |
$UnitsOfMass | $MUnits | string | kg |
$UnitsOfTime | $TUnits | string | s |
$UnitsOfEnergy | $EUnits | string | J |
$OpenMPThreads | $nOMP | int | — |
$MaxTimeStep | $nSteps | int | — |
$dt | — | double | — |
$RestartSwitch | $Restrt | bool | false |
$StartTimeStep / $RestartTimeStep | $tStart | int | — (required if restart) |
$CheckpointInterval | $tRstrt | int | — |
$VTKOutputInterval | $FTime | int | — |
$ConsoleOutputInterval | $STime | int | — |
$StopCheckInterval | — | double | 0.0 |
$LogScreen | — | bool | false |
$LogVTK | — | bool | false |
$LogScreenF | — | int | 1 |
$LogVTKF | — | int | 1 |
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
#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.