Exemplo n.º 1
0
static void PrintFinalStats(void *cvode_mem)
{
  int flag;
  long int nst, nfe, nsetups, netf, nni, ncfn, njeB, nfeB;

  flag = CVodeGetNumSteps(cvode_mem, &nst);
  check_flag(&flag, "CVodeGetNumSteps", 1);
  flag = CVodeGetNumRhsEvals(cvode_mem, &nfe);
  check_flag(&flag, "CVodeGetNumRhsEvals", 1);
  flag = CVodeGetNumLinSolvSetups(cvode_mem, &nsetups);
  check_flag(&flag, "CVodeGetNumLinSolvSetups", 1);
  flag = CVodeGetNumErrTestFails(cvode_mem, &netf);
  check_flag(&flag, "CVodeGetNumErrTestFails", 1);
  flag = CVodeGetNumNonlinSolvIters(cvode_mem, &nni);
  check_flag(&flag, "CVodeGetNumNonlinSolvIters", 1);
  flag = CVodeGetNumNonlinSolvConvFails(cvode_mem, &ncfn);
  check_flag(&flag, "CVodeGetNumNonlinSolvConvFails", 1);

  flag = CVBandGetNumJacEvals(cvode_mem, &njeB);
  check_flag(&flag, "CVBandGetNumJacEvals", 1);
  flag = CVBandGetNumRhsEvals(cvode_mem, &nfeB);
  check_flag(&flag, "CVBandGetNumRhsEvals", 1);

  printf("\nFinal Statistics:\n");
  printf("nst = %-6ld nfe  = %-6ld nsetups = %-6ld nfeB = %-6ld njeB = %ld\n",
	 nst, nfe, nsetups, nfeB, njeB);
  printf("nni = %-6ld ncfn = %-6ld netf = %ld\n \n",
	 nni, ncfn, netf);

  return;
}
Exemplo n.º 2
0
static void PrintFinalStats(void *cvode_mem, int miter, realtype ero)
{
  long int lenrw, leniw, nst, nfe, nsetups, nni, ncfn, netf;
  long int lenrwL, leniwL, nje, nfeL;
  int flag;

  flag = CVodeGetWorkSpace(cvode_mem, &lenrw, &leniw);
  check_flag(&flag, "CVodeGetWorkSpace", 1);
  flag = CVodeGetNumSteps(cvode_mem, &nst);
  check_flag(&flag, "CVodeGetNumSteps", 1);
  flag = CVodeGetNumRhsEvals(cvode_mem, &nfe);
  check_flag(&flag, "CVodeGetNumRhsEvals", 1);
  flag = CVodeGetNumLinSolvSetups(cvode_mem, &nsetups);
  check_flag(&flag, "CVodeGetNumLinSolvSetups", 1);
  flag = CVodeGetNumErrTestFails(cvode_mem, &netf);
  check_flag(&flag, "CVodeGetNumErrTestFails", 1);
  flag = CVodeGetNumNonlinSolvIters(cvode_mem, &nni);
  check_flag(&flag, "CVodeGetNumNonlinSolvIters", 1);
  flag = CVodeGetNumNonlinSolvConvFails(cvode_mem, &ncfn);
  check_flag(&flag, "CVodeGetNumNonlinSolvConvFails", 1);

  printf("\n Final statistics for this run:\n\n");
  printf(" CVode real workspace length              = %4ld \n", lenrw);
  printf(" CVode integer workspace length           = %4ld \n", leniw);
  printf(" Number of steps                          = %4ld \n",  nst);
  printf(" Number of f-s                            = %4ld \n",  nfe);
  printf(" Number of setups                         = %4ld \n",  nsetups);
  printf(" Number of nonlinear iterations           = %4ld \n",  nni);
  printf(" Number of nonlinear convergence failures = %4ld \n",  ncfn);
  printf(" Number of error test failures            = %4ld \n\n",netf);
  
  if (miter != FUNC) {
    switch(miter) {
    case DENSE_USER :
    case DENSE_DQ   :
      flag = CVDenseGetNumJacEvals(cvode_mem, &nje);
      check_flag(&flag, "CVDenseGetNumJacEvals", 1);
      flag = CVDenseGetNumRhsEvals(cvode_mem, &nfeL);
      check_flag(&flag, "CVDenseGetNumRhsEvals", 1);
      flag = CVDenseGetWorkSpace(cvode_mem, &lenrwL, &leniwL);
      check_flag(&flag, "CVDenseGetWorkSpace", 1);
      break;
    case BAND_USER  :
    case BAND_DQ    :
      flag = CVBandGetNumJacEvals(cvode_mem, &nje);
      check_flag(&flag, "CVBandGetNumJacEvals", 1);
      flag = CVBandGetNumRhsEvals(cvode_mem, &nfeL);
      check_flag(&flag, "CVBandGetNumRhsEvals", 1);
      flag = CVBandGetWorkSpace(cvode_mem, &lenrwL, &leniwL);
      check_flag(&flag, "CVBandGetWorkSpace", 1);
      break;  
    case DIAG       :
      nje = nsetups;
      flag = CVDiagGetNumRhsEvals(cvode_mem, &nfeL);
      check_flag(&flag, "CVDiagGetNumRhsEvals", 1);
      flag = CVDiagGetWorkSpace(cvode_mem, &lenrwL, &leniwL);
      check_flag(&flag, "CVDiagGetWorkSpace", 1);
      break;
    }
    printf(" Linear solver real workspace length      = %4ld \n", lenrwL);
    printf(" Linear solver integer workspace length   = %4ld \n", leniwL);
    printf(" Number of Jacobian evaluations           = %4ld  \n", nje);
    printf(" Number of f-s evaluations                = %4ld \n\n", nfeL);
  }
  
#if defined(SUNDIALS_EXTENDED_PRECISION)
  printf(" Error overrun = %.3Lf \n", ero);
#else
  printf(" Error overrun = %.3f \n", ero);
#endif
}
Exemplo n.º 3
0
void FCV_CVODE(realtype *tout, realtype *t, realtype *y, int *itask, int *ier)
{
  realtype h0u;
  int qu, qcur;

  /* 
     tout      is the t value where output is desired
     F2C_vec   is the N_Vector containing the solution on return
     t         is the returned independent variable value
     itask     is the task indicator (1 = CV_NORMAL, 2 = CV_ONE_STEP, 
                                      3 = CV_NORMAL_TSTOP, 4 = CV_ONE_STEP_TSTOP) 
  */

  *ier = CVode(CV_cvodemem, *tout, F2C_vec, t, *itask);

  y = N_VGetArrayPointer(F2C_vec);

  /* Load optional outputs in iopt & ropt */
  if ( (CV_iopt != NULL) && (CV_ropt != NULL) ) {

    CVodeGetIntegratorStats(CV_cvodemem, 
                            &CV_iopt[3],  /* NST */
                            &CV_iopt[4],  /* NFE */ 
                            &CV_iopt[5],  /* NSETUPS */ 
                            &CV_iopt[8],  /* NETF */ 
                            &qu,
                            &qcur,
                            &h0u,
                            &CV_ropt[3],  /* HU */ 
                            &CV_ropt[4],  /* HCUR */ 
                            &CV_ropt[5]);  /* TCUR */ 
    CV_iopt[9]  = (long int)qu;  /* QU */ 
    CV_iopt[10] = (long int)qcur;  /* QCUR */ 
    CVodeGetTolScaleFactor(CV_cvodemem, &CV_ropt[6]);
    CVodeGetNonlinSolvStats(CV_cvodemem,
                            &CV_iopt[6],  /* NNI */
                            &CV_iopt[7]);  /* NCFN */
    CVodeGetWorkSpace(CV_cvodemem,
                      &CV_iopt[11],  /* LENRW */
                      &CV_iopt[12]);  /* LENIW */
    if (CV_optin && (CV_iopt[13] > 0))
      CVodeGetNumStabLimOrderReds(CV_cvodemem, &CV_iopt[14]);  /* NOR */

    /* Root finding is on */
    if (CV_nrtfn != 0)
      CVodeGetNumGEvals(CV_cvodemem, &CV_iopt[24]);

    switch(CV_ls) {
    case 1:
      CVDenseGetWorkSpace(CV_cvodemem, &CV_iopt[15], &CV_iopt[16]);  /* LRW and LIW */
      CVDenseGetNumJacEvals(CV_cvodemem, &CV_iopt[17]);  /* NJE */
      CVDenseGetLastFlag(CV_cvodemem, (int *) &CV_iopt[25]);  /* last linear solver flag */
      break;
    case 2:
      CVBandGetWorkSpace(CV_cvodemem, &CV_iopt[15], &CV_iopt[16]);  /* LRW and LIW */
      CVBandGetNumJacEvals(CV_cvodemem, &CV_iopt[17]);  /* NJE */
      CVBandGetLastFlag(CV_cvodemem, (int *) &CV_iopt[25]);  /* last linear solver flag */
      break;
    case 3:
      CVDiagGetWorkSpace(CV_cvodemem, &CV_iopt[15], &CV_iopt[16]);  /* LRW and LIW */
      CVDiagGetLastFlag(CV_cvodemem, (int *) &CV_iopt[25]);  /* last linear solver flag */
      break;
    case 4:
      CVSpgmrGetWorkSpace(CV_cvodemem, &CV_iopt[15], &CV_iopt[16]);  /* LRW and LIW */
      CVSpgmrGetNumPrecEvals(CV_cvodemem, &CV_iopt[17]);  /* NPE */
      CVSpgmrGetNumLinIters(CV_cvodemem, &CV_iopt[18]);  /* NLI */
      CVSpgmrGetNumPrecSolves(CV_cvodemem, &CV_iopt[19]);  /* NPS */
      CVSpgmrGetNumConvFails(CV_cvodemem, &CV_iopt[20]);  /* NCFL */
      CVSpgmrGetLastFlag(CV_cvodemem, (int *) &CV_iopt[25]);  /* last linear solver flag */
      break;
    }
  }
}