int IDABBDPrecSetup(realtype tt,
		    N_Vector yy, N_Vector yp, N_Vector rr,
		    realtype c_j, void *prec_data,
		    N_Vector tempv1, N_Vector tempv2, N_Vector tempv3)
{
  long int retfac;
  int retval;
  IBBDPrecData pdata;
  IDAMem IDA_mem;

  pdata =(IBBDPrecData) prec_data;

  IDA_mem = (IDAMem) pdata->ida_mem;

  /* Call IBBDDQJac for a new Jacobian calculation and store in PP. */
  BandZero(PP);
  retval = IBBDDQJac(pdata, tt, c_j, yy, yp,
                     tempv1, tempv2, tempv3, pdata->tempv4);
  if (retval < 0) {
    IDAProcessError(IDA_mem, IDABBDPRE_FUNC_UNRECVR, "IDABBDPRE", "IDABBDPrecSetup", MSGBBD_FUNC_FAILED);
    return(-1);
  }
  if (retval > 0) {
    return(+1);
  } 

  /* Do LU factorization of preconditioner block in place (in PP). */
  retfac = BandGBTRF(PP, pivots);

  /* Return 0 if the LU was complete, or +1 otherwise. */
  if (retfac > 0) return(+1);
  return(0);
}
Example #2
0
/*---------------------------------------------------------------
  IDABBDPrecSetup:

  IDABBDPrecSetup generates a band-block-diagonal preconditioner
  matrix, where the local block (on this processor) is a band
  matrix. Each local block is computed by a difference quotient
  scheme via calls to the user-supplied routines glocal, gcomm.
  After generating the block in the band matrix PP, this routine
  does an LU factorization in place in PP.
 
  The IDABBDPrecSetup parameters used here are as follows:
 
  tt is the current value of the independent variable t.
 
  yy is the current value of the dependent variable vector,
     namely the predicted value of y(t).
 
  yp is the current value of the derivative vector y',
     namely the predicted value of y'(t).
 
  c_j is the scalar in the system Jacobian, proportional to 1/hh.
 
  bbd_data is the pointer to BBD memory set by IDABBDInit
 
  The argument rr is not used.
 
  Return value:
  The value returned by this IDABBDPrecSetup function is a int
  flag indicating whether it was successful. This value is
     0    if successful,
   > 0    for a recoverable error (step will be retried), or
   < 0    for a nonrecoverable error (step fails).
 ----------------------------------------------------------------*/
static int IDABBDPrecSetup(realtype tt, N_Vector yy, N_Vector yp,
                           N_Vector rr, realtype c_j, void *bbd_data)
{
  sunindextype ier;
  IBBDPrecData pdata;
  IDAMem IDA_mem;
  int retval;

  pdata =(IBBDPrecData) bbd_data;

  IDA_mem = (IDAMem) pdata->ida_mem;

  /* Call IBBDDQJac for a new Jacobian calculation and store in PP. */
  retval = SUNMatZero(pdata->PP);
  retval = IBBDDQJac(pdata, tt, c_j, yy, yp, pdata->tempv1,
                     pdata->tempv2, pdata->tempv3, pdata->tempv4);
  if (retval < 0) {
    IDAProcessError(IDA_mem, -1, "IDASBBDPRE", "IDABBDPrecSetup",
                    MSGBBD_FUNC_FAILED);
    return(-1);
  }
  if (retval > 0) {
    return(+1);
  } 
 
  /* Do LU factorization of matrix and return error flag */
  ier = SUNLinSolSetup_Band(pdata->LS, pdata->PP);
  return(ier);
}