5.3. Time Integration LoopsΒΆ

Helper functions for advancing a gas state.

mirgecom.steppers.advance_state(rhs, timestepper, state, t_final, t=0, istep=0, dt=0, max_steps=None, component_id='state', pre_step_callback=None, post_step_callback=None, force_eval=None, local_dt=False, compile_rhs=True)[source]ΒΆ

Determine what stepper to use and advance the state from (t) to (t_final).

Parameters:
  • rhs – Function that should return the time derivative of the state. This function should take time and state as arguments, with a call with signature``rhs(t, state)``.

  • timestepper – This is either a user-defined function that advances the state from t=time to t=(time+dt) and returns the advanced state with call signature timestepper(state, t, dt, rhs), or an instance of leap.MethodBuilder. If it’s the latter, we are responsible for generating timestepper code from the method instructions before using it, as well as providing context in the form of the state to be integrated, the initial time and timestep, and the RHS function.

  • component_id – State id (required input for leap method generation)

  • state (numpy.ndarray) – Agglomerated object array containing at least the state variables that will be advanced by this stepper

  • t_final (float) – Simulated time at which to stop

  • t (float) – Time at which to start

  • dt (float) – Initial timestep size to use, optional if dt is adaptive

  • istep (int) – Step number from which to start

  • max_steps (int) – Optional parameter indicating maximum number of steps to take

  • pre_step_callback – An optional user-defined function, with signature: state, dt = pre_step_callback(step, t, dt, state), to be called before the timestepper is called for that particular step.

  • post_step_callback – An optional user-defined function, with signature: state, dt = post_step_callback(step, t, dt, state), to be called after the timestepper is called for that particular step.

  • force_eval – An optional boolean indicating whether to force lazy evaluation between timesteps. By default, attempts to deduce whether this is necessary based on the behavior of the timestepper.

  • local_dt – An optional boolean indicating whether dt is uniform or cell-local in the domain.

  • compile_rhs – An optional boolean indicating whether rhs can be compiled.

Returns:

  • istep (int) – the current step number

  • t (float) – the current time

  • state (numpy.ndarray)

mirgecom.steppers.generate_singlerate_leap_advancer(timestepper, component_id, rhs, t, dt, state)[source]ΒΆ

Generate Leap code to advance all states with uniform dt, without substepping.

Parameters:
  • timestepper – An instance of leap.MethodBuilder that advances the state from t=time to t=(time+dt), and returns the advanced state.

  • component_id – State id (required input for leap method generation)

  • rhs – Function that should return the time derivative of the state. This function should take time and state as arguments, with a call looking like rhs(t, state).

  • t (float) – Time at which to start

  • dt (float) – Initial timestep to be set by leap method

  • state (numpy.ndarray) – Agglomerated object array containing at least the state variables that will be advanced by this stepper

Returns:

Python class implementing leap method, and generated by dagrt

Return type:

dagrt.codegen.python.StepperInterface