Block-Structured AMR Software Framework
amrex::RungeKutta Namespace Reference

Functions for Runge-Kutta methods. More...

Namespaces

 detail
 

Classes

struct  PostStageNoOp
 

Functions

template<typename MF , typename F , typename FB , typename P = PostStageNoOp>
void RK2 (MF &Uold, MF &Unew, Real time, Real dt, F const &frhs, FB const &fillbndry, P const &post_stage=PostStageNoOp())
 Time stepping with RK2. More...
 
template<typename MF , typename F , typename FB , typename R , typename P = PostStageNoOp>
void RK3 (MF &Uold, MF &Unew, Real time, Real dt, F const &frhs, FB const &fillbndry, R const &store_crse_data, P const &post_stage=PostStageNoOp())
 Time stepping with RK3. More...
 
template<typename MF , typename F , typename FB , typename R , typename P = PostStageNoOp>
void RK4 (MF &Uold, MF &Unew, Real time, Real dt, F const &frhs, FB const &fillbndry, R const &store_crse_data, P const &post_stage=PostStageNoOp())
 Time stepping with RK4. More...
 

Detailed Description

Functions for Runge-Kutta methods.

This namespace RungeKutta has functions for a number RK methods, RK2, RK3 and RK4. Here, RK2 refers to the explicit trapezoid rule, RK3 refers to the SSPRK3 (https://en.wikipedia.org/wiki/List_of_Runge%E2%80%93Kutta_methods#Third-order_Strong_Stability_Preserving_Runge-Kutta_(SSPRK3)), and RK4 is the classical fourth-order method (https://en.wikipedia.org/wiki/List_of_Runge%E2%80%93Kutta_methods#Classic_fourth-order_method). The function templates take the old data in FabArray/MultiFab as input, and evolve the system for one time step. The result is stored in another FabArray/MultiFab. These two FabArrays must have ghost cells if they are needed for evaluating the right-hand side. The functions take three callable objects for computing the right-hand side, filling ghost cells, and optionally post-processing RK stage results. For RK3 and RK4, they also need a callable object for storing the data needed for filling coarse/fine boundaries in AMR simulations.

The callable object for right-hand side has the signature of void(int stage, MF& dudt, MF const& u, Real t, Real dt), where stage is the RK stage number starting from 1, dudt is the output, u is the input, t is the first-order approximate time of the stage, and dt is the sub-time step, which can be used for reflux operations in AMR simulations.

The callable object for filling ghost cells has the signature of void(int stage, MF& u, Real t), where stage is the RK stage number starting from 1, u is a FabArray/MultiFab whose ghost cells need to be filled, and t is the first-order approximate time of the data at that stage. The FillPatcher class can be useful for implementing such a callable. See AmrLevel::RK for an example.

The callable object for post-processing stage results is optional. It's no-op by default. Its function signature is void(int stage, MF& u), where stage is the RK stage number and u is the result of that stage.

For RK3 and RK4, one must also provide a callable object with the signature of void(Array<MF,order> const& rkk), where order is the RK order and rkk contains the right-hand side at all the RK stages. The FillPatcher class can be useful for implementing such a callable. See AmrLevel::RK for an example.

Function Documentation

◆ RK2()

template<typename MF , typename F , typename FB , typename P = PostStageNoOp>
void amrex::RungeKutta::RK2 ( MF &  Uold,
MF &  Unew,
Real  time,
Real  dt,
F const &  frhs,
FB const &  fillbndry,
P const &  post_stage = PostStageNoOp() 
)

Time stepping with RK2.

Parameters
Uoldinput FabArray/MultiFab data at time
Unewoutput FabArray/MultiFab data at time+dt
timetime at the beginning of the step
dttime step
frhscomputing the right-hand side
fillbndryfilling ghost cells
post_stagepost-processing stage results

◆ RK3()

template<typename MF , typename F , typename FB , typename R , typename P = PostStageNoOp>
void amrex::RungeKutta::RK3 ( MF &  Uold,
MF &  Unew,
Real  time,
Real  dt,
F const &  frhs,
FB const &  fillbndry,
R const &  store_crse_data,
P const &  post_stage = PostStageNoOp() 
)

Time stepping with RK3.

Parameters
Uoldinput FabArray/MultiFab data at time
Unewoutput FabArray/MultiFab data at time+dt
timetime at the beginning of the step
dttime step
frhscomputing the right-hand side
fillbndryfilling ghost cells
store_crse_datastoring right-hand side data for AMR
post_stagepost-processing stage results

◆ RK4()

template<typename MF , typename F , typename FB , typename R , typename P = PostStageNoOp>
void amrex::RungeKutta::RK4 ( MF &  Uold,
MF &  Unew,
Real  time,
Real  dt,
F const &  frhs,
FB const &  fillbndry,
R const &  store_crse_data,
P const &  post_stage = PostStageNoOp() 
)

Time stepping with RK4.

Parameters
Uoldinput FabArray/MultiFab data at time
Unewoutput FabArray/MultiFab data at time+dt
timetime at the beginning of the step
dttime step
frhscomputing the right-hand side
fillbndryfilling ghost cells
store_crse_datastoring right-hand side data for AMR
post_stagepost-processing stage results