Skip to content

Number of time steps for adjustableRunTime calculated not robust

The current logic to calculate the remaining number of time steps goes

    scalar nSteps = timeToNextWrite/deltaT_ - SMALL;
    label nStepsToNextWrite = label(nSteps) + 1;

which for e.g. deltaT=0.005, writeInterval 0.1 should go

   nSteps = 19.99999999;
  nStepsToNextWrite = 19+1

however the SMALL can fall in the truncation error and instead

   nSteps = 20.000000001;
  nStepsToNextWrite = 20+1

so replace logic with

    scalar nSteps = timeToNextWrite/deltaT_;
    // nSteps can be < 1 so make sure at least 1
    label nStepsToNextWrite = max(1, round(nSteps));