Cantera  2.5.1
Classes | Namespaces | Typedefs | Functions
IDA_Solver.cpp File Reference
#include "cantera/numerics/IDA_Solver.h"
#include "cantera/base/stringUtils.h"
#include "sundials/sundials_types.h"
#include "sundials/sundials_math.h"
#include "ida/ida.h"
#include "ida/ida_dense.h"
#include "ida/ida_spgmr.h"
#include "ida/ida_band.h"
#include "nvector/nvector_serial.h"
Include dependency graph for IDA_Solver.cpp:

Go to the source code of this file.

Classes

class  ResidData
 A simple class to hold an array of parameter values and a pointer to an instance of a subclass of ResidEval. More...
 

Namespaces

 Cantera
 Namespace for the Cantera kernel.
 

Typedefs

typedef int sd_size_t
 

Functions

static int ida_resid (realtype t, N_Vector y, N_Vector ydot, N_Vector r, void *f_data)
 Function called by IDA to evaluate the residual, given y and ydot. More...
 
static int ida_jacobian (sd_size_t nrows, realtype t, realtype c_j, N_Vector y, N_Vector ydot, N_Vector r, DlsMat Jac, void *f_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3)
 Function called by by IDA to evaluate the Jacobian, given y and ydot. More...
 

Function Documentation

◆ ida_resid()

static int ida_resid ( realtype  t,
N_Vector  y,
N_Vector  ydot,
N_Vector  r,
void *  f_data 
)
static

Function called by IDA to evaluate the residual, given y and ydot.

IDA allows passing in a void* pointer to access external data. Instead of requiring the user to provide a residual function directly to IDA (which would require using the sundials data types N_Vector, etc.), we define this function as the single function that IDA always calls. The real evaluation of the residual is done by an instance of a subclass of ResidEval, passed in to this function as a pointer in the parameters.

FROM IDA WRITEUP -> What the IDA solver expects as a return flag from its residual routines:

A IDAResFn res should return a value of 0 if successful, a positive value if a recoverable error occured (e.g. yy has an illegal value), or a negative value if a nonrecoverable error occured. In the latter case, the program halts. If a recoverable error occured, the integrator will attempt to correct and retry.

Definition at line 78 of file IDA_Solver.cpp.

References ResidJacEval::evalResidNJ(), and IDA_Solver::getCurrentStepFromIDA().

◆ ida_jacobian()

static int ida_jacobian ( sd_size_t  nrows,
realtype  t,
realtype  c_j,
N_Vector  y,
N_Vector  ydot,
N_Vector  r,
DlsMat  Jac,
void *  f_data,
N_Vector  tmp1,
N_Vector  tmp2,
N_Vector  tmp3 
)
static

Function called by by IDA to evaluate the Jacobian, given y and ydot.

typedef int (*IDADlsDenseJacFn)(sd_size_t N, realtype t, realtype c_j, N_Vector y, N_Vector yp, N_Vector r, DlsMat Jac, void *user_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);

A IDADlsDenseJacFn should return

  • 0 if successful,
  • a positive int if a recoverable error occurred, or
  • a negative int if a nonrecoverable error occurred.

In the case of a recoverable error return, the integrator will attempt to recover by reducing the stepsize (which changes cj).

Definition at line 132 of file IDA_Solver.cpp.

References ResidJacEval::evalJacobianDP(), and IDA_Solver::getCurrentStepFromIDA().

Referenced by IDA_Solver::setJacobianType().