int CVSpilsSetDeltB(void *cvadj_mem, realtype deltB) { CVadjMem ca_mem; CVodeMem cvB_mem; int flag; if (cvadj_mem == NULL) { CVProcessError(NULL, CVSPILS_ADJMEM_NULL, "CVSPILS", "CVSpilsSetDeltB", MSGS_CAMEM_NULL); return(CVSPILS_ADJMEM_NULL); } ca_mem = (CVadjMem) cvadj_mem; cvB_mem = ca_mem->cvb_mem; flag = CVSpilsSetDelt(cvB_mem,deltB); return(flag); }
void FCV_BPSPBCG(int *pretype, int *maxl, realtype *delt, int *ier) { /* Call CVBPSpbcg to specify the SPBCG linear solver: CV_cvodemem is the pointer to the CVODE memory block pretype is the preconditioner type maxl is the maximum Krylov dimension delt is the linear convergence tolerance factor */ *ier = CVBPSpbcg(CV_cvodemem, *pretype, *maxl, CVBP_Data); if (*ier != CVSPILS_SUCCESS) return; *ier = CVSpilsSetDelt(CV_cvodemem, *delt); if (*ier != CVSPILS_SUCCESS) return; CV_ls = CV_LS_SPBCG; }
void FCV_BPSPGMR(int *pretype, int *gstype, int *maxl, realtype *delt, int *ier) { /* Call CVBPSpgmr to specify the SPGMR linear solver: CV_cvodemem is the pointer to the CVODE memory block pretype is the preconditioner type gstype is the Gram-Schmidt process type maxl is the maximum Krylov dimension delt is the linear convergence tolerance factor */ *ier = CVBPSpgmr(CV_cvodemem, *pretype, *maxl, CVBP_Data); if (*ier != CVSPILS_SUCCESS) return; *ier = CVSpilsSetGSType(CV_cvodemem, *gstype); if (*ier != CVSPILS_SUCCESS) return; *ier = CVSpilsSetDelt(CV_cvodemem, *delt); if (*ier != CVSPILS_SUCCESS) return; CV_ls = CV_LS_SPGMR; }
int main() { realtype abstol=ATOL, reltol=RTOL, t, tout; N_Vector c; WebData wdata; void *cvode_mem; booleantype firstrun; int jpre, gstype, flag; int ns, mxns, iout; c = NULL; wdata = NULL; cvode_mem = NULL; /* Initializations */ c = N_VNew_Serial(NEQ); if(check_flag((void *)c, "N_VNew_Serial", 0)) return(1); wdata = AllocUserData(); if(check_flag((void *)wdata, "AllocUserData", 2)) return(1); InitUserData(wdata); ns = wdata->ns; mxns = wdata->mxns; /* Print problem description */ PrintIntro(); /* Loop over jpre and gstype (four cases) */ for (jpre = PREC_LEFT; jpre <= PREC_RIGHT; jpre++) { for (gstype = MODIFIED_GS; gstype <= CLASSICAL_GS; gstype++) { /* Initialize c and print heading */ CInit(c, wdata); PrintHeader(jpre, gstype); /* Call CVodeMalloc or CVodeReInit, then CVSpgmr to set up problem */ firstrun = (jpre == PREC_LEFT) && (gstype == MODIFIED_GS); if (firstrun) { cvode_mem = CVodeCreate(CV_BDF, CV_NEWTON); if(check_flag((void *)cvode_mem, "CVodeCreate", 0)) return(1); wdata->cvode_mem = cvode_mem; flag = CVodeSetFdata(cvode_mem, wdata); if(check_flag(&flag, "CVodeSetFdata", 1)) return(1); flag = CVodeMalloc(cvode_mem, f, T0, c, CV_SS, reltol, &abstol); if(check_flag(&flag, "CVodeMalloc", 1)) return(1); flag = CVSpgmr(cvode_mem, jpre, MAXL); if(check_flag(&flag, "CVSpgmr", 1)) return(1); flag = CVSpilsSetGSType(cvode_mem, gstype); if(check_flag(&flag, "CVSpilsSetGSType", 1)) return(1); flag = CVSpilsSetDelt(cvode_mem, DELT); if(check_flag(&flag, "CVSpilsSetDelt", 1)) return(1); flag = CVSpilsSetPreconditioner(cvode_mem, Precond, PSolve, wdata); if(check_flag(&flag, "CVSpilsSetPreconditioner", 1)) return(1); } else { flag = CVodeReInit(cvode_mem, f, T0, c, CV_SS, reltol, &abstol); if(check_flag(&flag, "CVodeReInit", 1)) return(1); flag = CVSpilsSetPrecType(cvode_mem, jpre); check_flag(&flag, "CVSpilsSetPrecType", 1); flag = CVSpilsSetGSType(cvode_mem, gstype); if(check_flag(&flag, "CVSpilsSetGSType", 1)) return(1); } /* Print initial values */ if (firstrun) PrintAllSpecies(c, ns, mxns, T0); /* Loop over output points, call CVode, print sample solution values. */ tout = T1; for (iout = 1; iout <= NOUT; iout++) { flag = CVode(cvode_mem, tout, c, &t, CV_NORMAL); PrintOutput(cvode_mem, t); if (firstrun && (iout % 3 == 0)) PrintAllSpecies(c, ns, mxns, t); if(check_flag(&flag, "CVode", 1)) break; if (tout > RCONST(0.9)) tout += DTOUT; else tout *= TOUT_MULT; } /* Print final statistics, and loop for next case */ PrintFinalStats(cvode_mem); } } /* Free all memory */ CVodeFree(&cvode_mem); N_VDestroy_Serial(c); FreeUserData(wdata); return(0); }