Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
Example 6: Introduce TimeStepControl

This example introduces Tempus::TimeStepControl, which manages timestep-size selection independently of the stepper and application time loop. The van der Pol model is still provided through a Thyra::ModelEvaluator, the Forward Euler step is still performed by Tempus::StepperForwardEuler, and the application still manages the overall time loop and Tempus::SolutionHistory. However, timestep-size selection is now delegated to a Tempus::TimeStepControl object rather than being hardcoded directly in the application.

The main purpose of this step is to separate timestep-selection policy from both the stepping algorithm and the surrounding application logic. It should be noted that a Tempus::Stepper may suggest a future timestep size, but the final timestep-size selection occurs in Tempus::TimeStepControl.

Relative to Example 5: Introduce Stepper:

  • timestep control is moved into Tempus::TimeStepControl
  • the application initializes a dedicated timestep-control object
  • the time loop uses the control object to determine whether the current time and step index remain in range
  • timestep metadata for each new working state is assigned through the control object rather than directly in the application
  • the stepper and solution-history logic remain essentially unchanged

The central idea behind Tempus::TimeStepControl is that timestep size should be managed by a dedicated object that can enforce integration limits, policies, and strategies independently of the stepper itself.

This example uses only part of the full Tempus::TimeStepControl capability:

  • setting the final integration time
  • setting the number of time steps for constant-timestep control
  • using the control object to determine timestep metadata for each step
  • using the control object to test whether time and step index remain in range

The example continues to print the evolving solution in a simple table with columns for step index, time, $x_0$, and $x_1$. As in the previous examples, overall tutorial success should require both a successful integration status and a passing regression comparison of the final solution.


Transition notes
See Transition from Example 5 to Example 6 for a detailed explanation of what changed from Example 5: Introduce Stepper.

← Previous Example | Tutorial Overview | Next Example →