MFEM v4.7.0
Finite element discretization library
|
Interface to ARKode's ARKStep module – additive Runge-Kutta methods. More...
#include <sundials.hpp>
Public Types | |
enum | Type { EXPLICIT , IMPLICIT , IMEX } |
Types of ARKODE solvers. More... | |
Public Member Functions | |
ARKStepSolver (Type type=EXPLICIT) | |
Construct a serial wrapper to SUNDIALS' ARKode integrator. | |
ARKStepSolver (MPI_Comm comm, Type type=EXPLICIT) | |
Construct a parallel wrapper to SUNDIALS' ARKode integrator. | |
void | Init (TimeDependentOperator &f_) |
Initialize ARKode: calls ARKStepCreate() to create the ARKStep memory and set some defaults. | |
virtual void | Step (Vector &x, double &t, double &dt) |
Integrate the ODE with ARKode using the specified step mode. | |
void | UseMFEMLinearSolver () |
Attach the linear system setup and solve methods from the TimeDependentOperator i.e., SUNImplicitSetup() and SUNImplicitSolve() to ARKode. | |
void | UseSundialsLinearSolver () |
Attach a SUNDIALS GMRES linear solver to ARKode. | |
void | UseMFEMMassLinearSolver (int tdep) |
Attach mass matrix linear system setup, solve, and matrix-vector product methods from the TimeDependentOperator i.e., SUNMassSetup(), SUNMassSolve(), and SUNMassMult() to ARKode. | |
void | UseSundialsMassLinearSolver (int tdep) |
Attach the SUNDIALS GMRES linear solver and the mass matrix matrix-vector product method from the TimeDependentOperator i.e., SUNMassMult() to ARKode to solve mass matrix systems. | |
void | SetStepMode (int itask) |
Select the ARKode step mode: ARK_NORMAL (default) or ARK_ONE_STEP. | |
void | SetSStolerances (double reltol, double abstol) |
Set the scalar relative and scalar absolute tolerances. | |
void | SetMaxStep (double dt_max) |
Set the maximum time step. | |
void | SetOrder (int order) |
Chooses integration order for all explicit / implicit / IMEX methods. | |
void | SetERKTableNum (ARKODE_ERKTableID table_id) |
Choose a specific Butcher table for an explicit RK method. | |
void | SetIRKTableNum (ARKODE_DIRKTableID table_id) |
Choose a specific Butcher table for a diagonally implicit RK method. | |
void | SetIMEXTableNum (ARKODE_ERKTableID etable_id, ARKODE_DIRKTableID itable_id) |
Choose a specific Butcher table for an IMEX RK method. | |
void | SetFixedStep (double dt) |
Use a fixed time step size (disable temporal adaptivity). | |
void | PrintInfo () const |
Print various ARKStep statistics. | |
virtual | ~ARKStepSolver () |
Destroy the associated ARKode memory and SUNDIALS objects. | |
Public Member Functions inherited from mfem::ODESolver | |
ODESolver () | |
virtual void | Step (Vector &x, real_t &t, real_t &dt)=0 |
Perform a time step from time t [in] to time t [out] based on the requested step size dt [in]. | |
virtual void | Run (Vector &x, real_t &t, real_t &dt, real_t tf) |
Perform time integration from time t [in] to time tf [in]. | |
virtual int | GetMaxStateSize () |
Function for getting and setting the state vectors. | |
virtual int | GetStateSize () |
virtual const Vector & | GetStateVector (int i) |
virtual void | GetStateVector (int i, Vector &state) |
virtual void | SetStateVector (int i, Vector &state) |
virtual | ~ODESolver () |
Public Member Functions inherited from mfem::SundialsSolver | |
void * | GetMem () const |
Access the SUNDIALS memory structure. | |
int | GetFlag () const |
Returns the last flag returned by a call to a SUNDIALS function. | |
Static Protected Member Functions | |
static int | LinSysSetup (realtype t, N_Vector y, N_Vector fy, SUNMatrix A, SUNMatrix M, booleantype jok, booleantype *jcur, realtype gamma, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) |
Setup the linear system \( A x = b \). | |
static int | LinSysSolve (SUNLinearSolver LS, SUNMatrix A, N_Vector x, N_Vector b, realtype tol) |
Solve the linear system \( A x = b \). | |
static int | MassSysSetup (realtype t, SUNMatrix M, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) |
Setup the linear system \( M x = b \). | |
static int | MassSysSolve (SUNLinearSolver LS, SUNMatrix M, N_Vector x, N_Vector b, realtype tol) |
Solve the linear system \( M x = b \). | |
static int | MassMult1 (SUNMatrix M, N_Vector x, N_Vector v) |
Compute the matrix-vector product \( v = M x \). | |
static int | MassMult2 (N_Vector x, N_Vector v, realtype t, void *mtimes_data) |
Compute the matrix-vector product \(v = M_t x \) at time t. | |
Wrappers to compute the ODE RHS functions. | |
RHS1 is explicit RHS and RHS2 the implicit RHS for IMEX integration. When purely implicit or explicit only RHS1 is used. | |
static int | RHS1 (realtype t, const N_Vector y, N_Vector ydot, void *user_data) |
static int | RHS2 (realtype t, const N_Vector y, N_Vector ydot, void *user_data) |
Protected Attributes | |
Type | rk_type |
Runge-Kutta type. | |
int | step_mode |
ARKStep step mode (ARK_NORMAL or ARK_ONE_STEP). | |
bool | use_implicit |
True for implicit or imex integration. | |
Protected Attributes inherited from mfem::ODESolver | |
TimeDependentOperator * | f |
Pointer to the associated TimeDependentOperator. | |
MemoryType | mem_type |
Protected Attributes inherited from mfem::SundialsSolver | |
void * | sundials_mem |
SUNDIALS mem structure. | |
int | flag |
Last flag returned from a call to SUNDIALS. | |
bool | reinit |
Flag to signal memory reinitialization is need. | |
long | saved_global_size |
Global vector length on last initialization. | |
SundialsNVector * | Y |
State vector. | |
SUNMatrix | A |
SUNMatrix | M |
Mass matrix M. | |
SUNLinearSolver | LSA |
Linear solver for A. | |
SUNLinearSolver | LSM |
Linear solver for M. | |
SUNNonlinearSolver | NLS |
Nonlinear solver. | |
Additional Inherited Members | |
Protected Member Functions inherited from mfem::SundialsSolver | |
bool | Parallel () const |
bool | Parallel () const |
SundialsSolver () | |
Protected constructor: objects of this type should be constructed only as part of a derived class. | |
void | AllocateEmptyNVector (N_Vector &y) |
void | AllocateEmptyNVector (N_Vector &y, MPI_Comm comm) |
Static Protected Attributes inherited from mfem::SundialsSolver | |
static constexpr double | default_rel_tol = 1e-4 |
Default scalar relative tolerance. | |
static constexpr double | default_abs_tol = 1e-9 |
Default scalar absolute tolerance. | |
Interface to ARKode's ARKStep module – additive Runge-Kutta methods.
Definition at line 672 of file sundials.hpp.
Types of ARKODE solvers.
Enumerator | |
---|---|
EXPLICIT | Explicit RK method. |
IMPLICIT | Implicit RK method. |
IMEX | Implicit-explicit ARK method. |
Definition at line 676 of file sundials.hpp.
Construct a serial wrapper to SUNDIALS' ARKode integrator.
[in] | type | Specifies the RK method type:
|
Definition at line 1458 of file sundials.cpp.
Construct a parallel wrapper to SUNDIALS' ARKode integrator.
[in] | comm | The MPI communicator used to partition the ODE system. |
[in] | type | Specifies the RK method type:
|
Definition at line 1466 of file sundials.cpp.
|
virtual |
Destroy the associated ARKode memory and SUNDIALS objects.
Definition at line 1808 of file sundials.cpp.
|
virtual |
Initialize ARKode: calls ARKStepCreate() to create the ARKStep memory and set some defaults.
If the ARKStep has already been created, it checks if the problem size has changed since the last call to Init(). If the problem is the same then ARKStepReInit() will be called in the next call to Step(). If the problem size has changed, the ARKStep memory is freed and realloced for the new problem size.
[in] | f_ | The TimeDependentOperator that defines the ODE system |
Reimplemented from mfem::ODESolver.
Definition at line 1474 of file sundials.cpp.
|
staticprotected |
Setup the linear system \( A x = b \).
Definition at line 1381 of file sundials.cpp.
|
staticprotected |
Solve the linear system \( A x = b \).
Definition at line 1400 of file sundials.cpp.
|
staticprotected |
Compute the matrix-vector product \( v = M x \).
Definition at line 1436 of file sundials.cpp.
|
staticprotected |
Compute the matrix-vector product \(v = M_t x \) at time t.
Definition at line 1446 of file sundials.cpp.
|
staticprotected |
Setup the linear system \( M x = b \).
Definition at line 1415 of file sundials.cpp.
|
staticprotected |
Solve the linear system \( M x = b \).
Definition at line 1425 of file sundials.cpp.
void mfem::ARKStepSolver::PrintInfo | ( | ) | const |
Print various ARKStep statistics.
Definition at line 1756 of file sundials.cpp.
|
staticprotected |
Definition at line 1344 of file sundials.cpp.
|
staticprotected |
Definition at line 1364 of file sundials.cpp.
void mfem::ARKStepSolver::SetERKTableNum | ( | ARKODE_ERKTableID | table_id | ) |
Choose a specific Butcher table for an explicit RK method.
See ARKODE documentation for all possible options, stability regions, etc. For example, table_id = BOGACKI_SHAMPINE_4_2_3 is 4-stage 3rd order.
Definition at line 1731 of file sundials.cpp.
void mfem::ARKStepSolver::SetFixedStep | ( | double | dt | ) |
Use a fixed time step size (disable temporal adaptivity).
Use of this function is not recommended, since there is no assurance of the validity of the computed solutions. It is primarily provided for code-to-code verification testing purposes.
Definition at line 1750 of file sundials.cpp.
void mfem::ARKStepSolver::SetIMEXTableNum | ( | ARKODE_ERKTableID | etable_id, |
ARKODE_DIRKTableID | itable_id ) |
Choose a specific Butcher table for an IMEX RK method.
See ARKODE documentation for all possible options, stability regions, etc. For example, etable_id = ARK548L2SA_DIRK_8_4_5 and itable_id = ARK548L2SA_ERK_8_4_5 is 8-stage 5th order.
Definition at line 1743 of file sundials.cpp.
void mfem::ARKStepSolver::SetIRKTableNum | ( | ARKODE_DIRKTableID | table_id | ) |
Choose a specific Butcher table for a diagonally implicit RK method.
See ARKODE documentation for all possible options, stability regions, etc. For example, table_id = CASH_5_3_4 is 5-stage 4th order.
Definition at line 1737 of file sundials.cpp.
void mfem::ARKStepSolver::SetMaxStep | ( | double | dt_max | ) |
Set the maximum time step.
Definition at line 1719 of file sundials.cpp.
void mfem::ARKStepSolver::SetOrder | ( | int | order | ) |
Chooses integration order for all explicit / implicit / IMEX methods.
The default is 4, and the allowed ranges are: [2, 8] for explicit; [2, 5] for implicit; [3, 5] for IMEX.
Definition at line 1725 of file sundials.cpp.
void mfem::ARKStepSolver::SetSStolerances | ( | double | reltol, |
double | abstol ) |
Set the scalar relative and scalar absolute tolerances.
Definition at line 1713 of file sundials.cpp.
void mfem::ARKStepSolver::SetStepMode | ( | int | itask | ) |
Select the ARKode step mode: ARK_NORMAL (default) or ARK_ONE_STEP.
[in] | itask | The desired step mode |
Definition at line 1708 of file sundials.cpp.
|
virtual |
Integrate the ODE with ARKode using the specified step mode.
[in,out] | x | On output, the solution vector at the requested output time, tout = t + dt |
[in,out] | t | On output, the output time reached |
[in,out] | dt | On output, the last time step taken |
Definition at line 1570 of file sundials.cpp.
void mfem::ARKStepSolver::UseMFEMLinearSolver | ( | ) |
Attach the linear system setup and solve methods from the TimeDependentOperator i.e., SUNImplicitSetup() and SUNImplicitSolve() to ARKode.
Definition at line 1610 of file sundials.cpp.
void mfem::ARKStepSolver::UseMFEMMassLinearSolver | ( | int | tdep | ) |
Attach mass matrix linear system setup, solve, and matrix-vector product methods from the TimeDependentOperator i.e., SUNMassSetup(), SUNMassSolve(), and SUNMassMult() to ARKode.
[in] | tdep | An integer flag indicating if the mass matrix is time dependent (1) or time independent (0) |
Definition at line 1656 of file sundials.cpp.
void mfem::ARKStepSolver::UseSundialsLinearSolver | ( | ) |
Attach a SUNDIALS GMRES linear solver to ARKode.
Definition at line 1641 of file sundials.cpp.
void mfem::ARKStepSolver::UseSundialsMassLinearSolver | ( | int | tdep | ) |
Attach the SUNDIALS GMRES linear solver and the mass matrix matrix-vector product method from the TimeDependentOperator i.e., SUNMassMult() to ARKode to solve mass matrix systems.
[in] | tdep | An integer flag indicating if the mass matrix is time dependent (1) or time independent (0) |
Definition at line 1688 of file sundials.cpp.
|
protected |
Runge-Kutta type.
Definition at line 684 of file sundials.hpp.
|
protected |
ARKStep step mode (ARK_NORMAL or ARK_ONE_STEP).
Definition at line 685 of file sundials.hpp.
|
protected |
True for implicit or imex integration.
Definition at line 686 of file sundials.hpp.