MFEM
v4.2.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. More... | |
ARKStepSolver (MPI_Comm comm, Type type=EXPLICIT) | |
Construct a parallel wrapper to SUNDIALS' ARKode integrator. More... | |
void | Init (TimeDependentOperator &f_) |
Initialize ARKode: calls ARKStepCreate() to create the ARKStep memory and set some defaults. More... | |
virtual void | Step (Vector &x, double &t, double &dt) |
Integrate the ODE with ARKode using the specified step mode. More... | |
void | UseMFEMLinearSolver () |
Attach the linear system setup and solve methods from the TimeDependentOperator i.e., SUNImplicitSetup() and SUNImplicitSolve() to ARKode. More... | |
void | UseSundialsLinearSolver () |
Attach a SUNDIALS GMRES linear solver to ARKode. More... | |
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. More... | |
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. More... | |
void | SetStepMode (int itask) |
Select the ARKode step mode: ARK_NORMAL (default) or ARK_ONE_STEP. More... | |
void | SetSStolerances (double reltol, double abstol) |
Set the scalar relative and scalar absolute tolerances. More... | |
void | SetMaxStep (double dt_max) |
Set the maximum time step. More... | |
void | SetOrder (int order) |
Chooses integration order for all explicit / implicit / IMEX methods. More... | |
void | SetERKTableNum (int table_num) |
Choose a specific Butcher table for an explicit RK method. More... | |
void | SetIRKTableNum (int table_num) |
Choose a specific Butcher table for a diagonally implicit RK method. More... | |
void | SetIMEXTableNum (int etable_num, int itable_num) |
Choose a specific Butcher table for an IMEX RK method. More... | |
void | SetFixedStep (double dt) |
Use a fixed time step size (disable temporal adaptivity). More... | |
void | PrintInfo () const |
Print various ARKStep statistics. More... | |
virtual | ~ARKStepSolver () |
Destroy the associated ARKode memory and SUNDIALS objects. More... | |
Public Member Functions inherited from mfem::ODESolver | |
ODESolver () | |
virtual void | Run (Vector &x, double &t, double &dt, double tf) |
Perform time integration from time t [in] to time tf [in]. More... | |
virtual int | GetMaxStateSize () |
Function for getting and setting the state vectors. More... | |
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. More... | |
int | GetFlag () const |
Returns the last flag returned by a call to a SUNDIALS function. More... | |
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 \). More... | |
static int | LinSysSolve (SUNLinearSolver LS, SUNMatrix A, N_Vector x, N_Vector b, realtype tol) |
Solve the linear system \( A x = b \). More... | |
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 \). More... | |
static int | MassSysSolve (SUNLinearSolver LS, SUNMatrix M, N_Vector x, N_Vector b, realtype tol) |
Solve the linear system \( M x = b \). More... | |
static int | MassMult1 (SUNMatrix M, N_Vector x, N_Vector v) |
Compute the matrix-vector product \( v = M x \). More... | |
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. More... | |
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. More... | |
int | step_mode |
ARKStep step mode (ARK_NORMAL or ARK_ONE_STEP). More... | |
bool | use_implicit |
True for implicit or imex integration. More... | |
Protected Attributes inherited from mfem::ODESolver | |
TimeDependentOperator * | f |
Pointer to the associated TimeDependentOperator. More... | |
MemoryType | mem_type |
Protected Attributes inherited from mfem::SundialsSolver | |
void * | sundials_mem |
SUNDIALS mem structure. More... | |
int | flag |
Last flag returned from a call to SUNDIALS. More... | |
bool | reinit |
Flag to signal memory reinitialization is need. More... | |
long | saved_global_size |
Global vector length on last initialization. More... | |
SundialsNVector * | Y |
State vector. More... | |
SUNMatrix | A |
SUNMatrix | M |
Mass matrix M. More... | |
SUNLinearSolver | LSA |
Linear solver for A. More... | |
SUNLinearSolver | LSM |
Linear solver for M. More... | |
SUNNonlinearSolver | NLS |
Nonlinear solver. More... | |
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. More... | |
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. More... | |
static constexpr double | default_abs_tol = 1e-9 |
Default scalar absolute tolerance. More... | |
Interface to ARKode's ARKStep module – additive Runge-Kutta methods.
Definition at line 539 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 543 of file sundials.hpp.
Construct a serial wrapper to SUNDIALS' ARKode integrator.
[in] | type | Specifies the RK method type:
|
Definition at line 1281 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 1289 of file sundials.cpp.
|
virtual |
Destroy the associated ARKode memory and SUNDIALS objects.
Definition at line 1628 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 1297 of file sundials.cpp.
|
staticprotected |
Setup the linear system \( A x = b \).
Definition at line 1204 of file sundials.cpp.
|
staticprotected |
Solve the linear system \( A x = b \).
Definition at line 1223 of file sundials.cpp.
|
staticprotected |
Compute the matrix-vector product \( v = M x \).
Definition at line 1259 of file sundials.cpp.
|
staticprotected |
Compute the matrix-vector product \(v = M_t x \) at time t.
Definition at line 1269 of file sundials.cpp.
|
staticprotected |
Setup the linear system \( M x = b \).
Definition at line 1238 of file sundials.cpp.
|
staticprotected |
Solve the linear system \( M x = b \).
Definition at line 1248 of file sundials.cpp.
void mfem::ARKStepSolver::PrintInfo | ( | ) | const |
Print various ARKStep statistics.
Definition at line 1576 of file sundials.cpp.
|
staticprotected |
Definition at line 1167 of file sundials.cpp.
|
staticprotected |
Definition at line 1187 of file sundials.cpp.
void mfem::ARKStepSolver::SetERKTableNum | ( | int | table_num | ) |
Choose a specific Butcher table for an explicit RK method.
See ARKODE documentation for all possible options, stability regions, etc. For example, table_num = BOGACKI_SHAMPINE_4_2_3 is 4-stage 3rd order.
Definition at line 1552 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 1570 of file sundials.cpp.
void mfem::ARKStepSolver::SetIMEXTableNum | ( | int | etable_num, |
int | itable_num | ||
) |
Choose a specific Butcher table for an IMEX RK method.
See ARKODE documentation for all possible options, stability regions, etc. For example, etable_num = ARK548L2SA_DIRK_8_4_5 and itable_num = ARK548L2SA_ERK_8_4_5 is 8-stage 5th order.
Definition at line 1564 of file sundials.cpp.
void mfem::ARKStepSolver::SetIRKTableNum | ( | int | table_num | ) |
Choose a specific Butcher table for a diagonally implicit RK method.
See ARKODE documentation for all possible options, stability regions, etc. For example, table_num = CASH_5_3_4 is 5-stage 4th order.
Definition at line 1558 of file sundials.cpp.
void mfem::ARKStepSolver::SetMaxStep | ( | double | dt_max | ) |
Set the maximum time step.
Definition at line 1540 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 1546 of file sundials.cpp.
void mfem::ARKStepSolver::SetSStolerances | ( | double | reltol, |
double | abstol | ||
) |
Set the scalar relative and scalar absolute tolerances.
Definition at line 1534 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 1529 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 |
Implements mfem::ODESolver.
Definition at line 1391 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 1431 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 1477 of file sundials.cpp.
void mfem::ARKStepSolver::UseSundialsLinearSolver | ( | ) |
Attach a SUNDIALS GMRES linear solver to ARKode.
Definition at line 1462 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 1509 of file sundials.cpp.
|
protected |
Runge-Kutta type.
Definition at line 551 of file sundials.hpp.
|
protected |
ARKStep step mode (ARK_NORMAL or ARK_ONE_STEP).
Definition at line 552 of file sundials.hpp.
|
protected |
True for implicit or imex integration.
Definition at line 553 of file sundials.hpp.