MFEM  v4.1.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
mfem::CVODESolver Class Reference

Interface to the CVODE library – linear multi-step methods. More...

#include <sundials.hpp>

Inheritance diagram for mfem::CVODESolver:
[legend]
Collaboration diagram for mfem::CVODESolver:
[legend]

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 SetMaxStep (double dt_max)
 Set the maximum time step. 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 ~ODESolver ()
 
- Public Member Functions inherited from mfem::SundialsSolver
void * GetMem () const
 Access the SUNDIALS memory structure. More...
 
int GetFlag () const
 Returns the last flag retured by a call to a SUNDIALS function. More...
 

Static Protected Member Functions

static int RHS (realtype t, const N_Vector y, N_Vector ydot, void *user_data)
 Wrapper to compute the ODE rhs function. 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...
 

Protected Attributes

int lmm_type
 Linear multistep method type. More...
 
int step_mode
 CVODE step mode (CV_NORMAL or CV_ONE_STEP). More...
 
- Protected Attributes inherited from mfem::ODESolver
TimeDependentOperatorf
 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...
 
N_Vector y
 State vector. More...
 
SUNMatrix A
 Linear system A = I - gamma J, M - gamma J, or J. More...
 
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...
 
- 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...
 

Detailed Description

Interface to the CVODE library – linear multi-step methods.

Definition at line 92 of file sundials.hpp.

Constructor & Destructor Documentation

mfem::CVODESolver::CVODESolver ( int  lmm)

Construct a serial wrapper to SUNDIALS' CVODE integrator.

Parameters
[in]lmmSpecifies the linear multistep method, the options are:
  • CV_ADAMS - implicit methods for non-stiff systems,
  • CV_BDF - implicit methods for stiff systems.

Definition at line 120 of file sundials.cpp.

mfem::CVODESolver::CVODESolver ( MPI_Comm  comm,
int  lmm 
)

Construct a parallel wrapper to SUNDIALS' CVODE integrator.

Parameters
[in]commThe MPI communicator used to partition the ODE system
[in]lmmSpecifies the linear multistep method, the options are:
  • CV_ADAMS - implicit methods for non-stiff systems,
  • CV_BDF - implicit methods for stiff systems.

Definition at line 129 of file sundials.cpp.

mfem::CVODESolver::~CVODESolver ( )
virtual

Destroy the associated CVODE memory and SUNDIALS objects.

Definition at line 405 of file sundials.cpp.

Member Function Documentation

void mfem::CVODESolver::Init ( TimeDependentOperator f_)
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.

Parameters
[in]f_The TimeDependentOperator that defines the ODE system.
Note
All other methods must be called after Init().
If this method is called a second time with a different problem size, then any non-default user-set options will be lost and will need to be set again.

Reimplemented from mfem::ODESolver.

Definition at line 151 of file sundials.cpp.

int mfem::CVODESolver::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 
)
staticprotected

Setup the linear system \( A x = b \).

Definition at line 94 of file sundials.cpp.

int mfem::CVODESolver::LinSysSolve ( SUNLinearSolver  LS,
SUNMatrix  A,
N_Vector  x,
N_Vector  b,
realtype  tol 
)
staticprotected

Solve the linear system \( A x = b \).

Definition at line 109 of file sundials.cpp.

void mfem::CVODESolver::PrintInfo ( ) const

Print various CVODE statistics.

Definition at line 360 of file sundials.cpp.

int mfem::CVODESolver::RHS ( realtype  t,
const N_Vector  y,
N_Vector  ydot,
void *  user_data 
)
staticprotected

Wrapper to compute the ODE rhs function.

Definition at line 78 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.

Note
max_order can't be higher than the current maximum order.

Definition at line 354 of file sundials.cpp.

void mfem::CVODESolver::SetMaxStep ( double  dt_max)

Set the maximum time step.

Definition at line 348 of file sundials.cpp.

void mfem::CVODESolver::SetSStolerances ( double  reltol,
double  abstol 
)

Set the scalar relative and scalar absolute tolerances.

Definition at line 342 of file sundials.cpp.

void mfem::CVODESolver::SetStepMode ( int  itask)

Select the CVODE step mode: CV_NORMAL (default) or CV_ONE_STEP.

Parameters
[in]itaskThe desired step mode.

Definition at line 337 of file sundials.cpp.

void mfem::CVODESolver::Step ( Vector x,
double &  t,
double &  dt 
)
virtual

Integrate the ODE with CVODE using the specified step mode.

Parameters
[in,out]xOn output, the solution vector at the requested output time tout = t + dt.
[in,out]tOn output, the output time reached.
[in,out]dtOn output, the last time step taken.
Note
On input, the values of t and dt are used to compute desired output time for the integration, tout = t + dt.

Implements mfem::ODESolver.

Definition at line 256 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 291 of file sundials.cpp.

void mfem::CVODESolver::UseSundialsLinearSolver ( )

Attach SUNDIALS GMRES linear solver to CVODE.

Definition at line 322 of file sundials.cpp.

Member Data Documentation

int mfem::CVODESolver::lmm_type
protected

Linear multistep method type.

Definition at line 95 of file sundials.hpp.

int mfem::CVODESolver::step_mode
protected

CVODE step mode (CV_NORMAL or CV_ONE_STEP).

Definition at line 96 of file sundials.hpp.


The documentation for this class was generated from the following files: