MFEM
v4.3.0
Finite element discretization library
|
Interface to the CVODE library – linear multi-step methods. More...
#include <sundials.hpp>
Public Member Functions | |
CVODESolver (int lmm) | |
Construct a serial wrapper to SUNDIALS' CVODE integrator. More... | |
CVODESolver (MPI_Comm comm, int lmm) | |
Construct a parallel wrapper to SUNDIALS' CVODE integrator. More... | |
void | Init (TimeDependentOperator &f_) |
Initialize CVODE: calls CVodeCreate() to create the CVODE memory and set some defaults. More... | |
virtual void | Step (Vector &x, double &t, double &dt) |
Integrate the ODE with CVODE 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 CVODE. More... | |
void | UseSundialsLinearSolver () |
Attach SUNDIALS GMRES linear solver to CVODE. More... | |
void | SetStepMode (int itask) |
Select the CVODE step mode: CV_NORMAL (default) or CV_ONE_STEP. More... | |
void | SetSStolerances (double reltol, double abstol) |
Set the scalar relative and scalar absolute tolerances. More... | |
void | SetSVtolerances (double reltol, Vector abstol) |
Set the scalar relative and vector of absolute tolerances. More... | |
void | SetRootFinder (int components, RootFunction func) |
Initialize Root Finder. More... | |
void | SetMaxStep (double dt_max) |
Set the maximum time step. More... | |
void | SetMaxNSteps (int steps) |
Set the maximum number of time steps. More... | |
long | GetNumSteps () |
Get the number of internal steps taken so far. More... | |
void | SetMaxOrder (int max_order) |
Set the maximum method order. More... | |
void | PrintInfo () const |
Print various CVODE statistics. More... | |
virtual | ~CVODESolver () |
Destroy the associated CVODE 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... | |
Protected Types | |
typedef std::function< int(realtype t, Vector y, Vector gout, CVODESolver *)> | RootFunction |
Typedef for root finding functions. More... | |
typedef std::function< int(Vector y, Vector w, CVODESolver *)> | EWTFunction |
Typedef declaration for error weight functions. More... | |
Static Protected Member Functions | |
static int | RHS (realtype t, const N_Vector y, N_Vector ydot, void *user_data) |
Number of components in gout. More... | |
static int | LinSysSetup (realtype t, N_Vector y, N_Vector fy, SUNMatrix A, 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 | root (realtype t, N_Vector y, realtype *gout, void *user_data) |
Prototype to define root finding for CVODE. More... | |
Protected Attributes | |
int | lmm_type |
Linear multistep method type. More... | |
int | step_mode |
CVODE step mode (CV_NORMAL or CV_ONE_STEP). More... | |
int | root_components |
RootFunction | root_func |
A class member to facilitate pointing to a user-specified root function. More... | |
EWTFunction | ewt_func |
A class member to facilitate pointing to a user-specified error weight function. 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 the CVODE library – linear multi-step methods.
Definition at line 252 of file sundials.hpp.
|
protected |
Typedef declaration for error weight functions.
Definition at line 283 of file sundials.hpp.
|
protected |
Typedef for root finding functions.
Definition at line 277 of file sundials.hpp.
mfem::CVODESolver::CVODESolver | ( | int | lmm | ) |
Construct a serial wrapper to SUNDIALS' CVODE integrator.
[in] | lmm | Specifies the linear multistep method, the options are:
|
Definition at line 518 of file sundials.cpp.
mfem::CVODESolver::CVODESolver | ( | MPI_Comm | comm, |
int | lmm | ||
) |
Construct a parallel wrapper to SUNDIALS' CVODE integrator.
[in] | comm | The MPI communicator used to partition the ODE system |
[in] | lmm | Specifies the linear multistep method, the options are:
|
Definition at line 525 of file sundials.cpp.
|
virtual |
Destroy the associated CVODE memory and SUNDIALS objects.
Definition at line 787 of file sundials.cpp.
long mfem::CVODESolver::GetNumSteps | ( | ) |
Get the number of internal steps taken so far.
Definition at line 728 of file sundials.cpp.
|
virtual |
Initialize CVODE: calls CVodeCreate() to create the CVODE memory and set some defaults.
If the CVODE memory 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 CVodeReInit() will be called in the next call to Step(). If the problem size has changed, the CVODE 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 532 of file sundials.cpp.
|
staticprotected |
Setup the linear system \( A x = b \).
Definition at line 494 of file sundials.cpp.
|
staticprotected |
Solve the linear system \( A x = b \).
Definition at line 508 of file sundials.cpp.
void mfem::CVODESolver::PrintInfo | ( | ) | const |
Print various CVODE statistics.
Definition at line 742 of file sundials.cpp.
|
staticprotected |
Number of components in gout.
Wrapper to compute the ODE rhs function.
Definition at line 457 of file sundials.cpp.
|
staticprotected |
Prototype to define root finding for CVODE.
Definition at line 474 of file sundials.cpp.
void mfem::CVODESolver::SetMaxNSteps | ( | int | steps | ) |
Set the maximum number of time steps.
Definition at line 722 of file sundials.cpp.
void mfem::CVODESolver::SetMaxOrder | ( | int | max_order | ) |
Set the maximum method order.
CVODE uses adaptive-order integration, based on the local truncation error. The default values for max_order are 12 for CV_ADAMS and 5 for CV_BDF. Use this if you know a priori that your system is such that higher order integration formulas are unstable.
Definition at line 736 of file sundials.cpp.
void mfem::CVODESolver::SetMaxStep | ( | double | dt_max | ) |
Set the maximum time step.
Definition at line 716 of file sundials.cpp.
void mfem::CVODESolver::SetRootFinder | ( | int | components, |
RootFunction | func | ||
) |
Initialize Root Finder.
Definition at line 486 of file sundials.cpp.
void mfem::CVODESolver::SetSStolerances | ( | double | reltol, |
double | abstol | ||
) |
Set the scalar relative and scalar absolute tolerances.
Definition at line 698 of file sundials.cpp.
void mfem::CVODESolver::SetStepMode | ( | int | itask | ) |
Select the CVODE step mode: CV_NORMAL (default) or CV_ONE_STEP.
[in] | itask | The desired step mode. |
Definition at line 693 of file sundials.cpp.
void mfem::CVODESolver::SetSVtolerances | ( | double | reltol, |
Vector | abstol | ||
) |
Set the scalar relative and vector of absolute tolerances.
Definition at line 704 of file sundials.cpp.
|
virtual |
Integrate the ODE with CVODE 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.
Reimplemented in mfem::CVODESSolver.
Definition at line 620 of file sundials.cpp.
void mfem::CVODESolver::UseMFEMLinearSolver | ( | ) |
Attach the linear system setup and solve methods from the TimeDependentOperator i.e., SUNImplicitSetup() and SUNImplicitSolve() to CVODE.
Definition at line 647 of file sundials.cpp.
void mfem::CVODESolver::UseSundialsLinearSolver | ( | ) |
Attach SUNDIALS GMRES linear solver to CVODE.
Definition at line 678 of file sundials.cpp.
|
protected |
A class member to facilitate pointing to a user-specified error weight function.
Definition at line 286 of file sundials.hpp.
|
protected |
Linear multistep method type.
Definition at line 255 of file sundials.hpp.
|
protected |
Definition at line 257 of file sundials.hpp.
|
protected |
A class member to facilitate pointing to a user-specified root function.
Definition at line 280 of file sundials.hpp.
|
protected |
CVODE step mode (CV_NORMAL or CV_ONE_STEP).
Definition at line 256 of file sundials.hpp.