/[ascend]/trunk/solvers/ida/ida.c
ViewVC logotype

Diff of /trunk/solvers/ida/ida.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2110 by jpye, Tue Dec 1 10:18:17 2009 UTC revision 2111 by jpye, Tue Dec 8 03:05:36 2009 UTC
# Line 353  static void integrator_ida_free(void *en Line 353  static void integrator_ida_free(void *en
353          (d->pfree)(enginedata);          (d->pfree)(enginedata);
354      }      }
355    
356      ASC_FREE(d->rellist);        ASC_FREE(d->rellist);
357    
358  #ifdef DESTROY_DEBUG  #ifdef DESTROY_DEBUG
359      CONSOLE_DEBUG("Now destroying the enginedata");      CONSOLE_DEBUG("Now destroying the enginedata");
# Line 1060  static int integrator_ida_solve( Line 1060  static int integrator_ida_solve(
1060                      IDAReInit(ida_mem, tret, yret, ypret);                      IDAReInit(ida_mem, tret, yret, ypret);
1061  #elif SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR<3  #elif SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR<3
1062                      /* TODO find out what version needs the following line... not sure. */                      /* TODO find out what version needs the following line... not sure. */
1063                      IDAReInit(ida_mem, &integrator_ida_fex, tret, yret, ypret);                      //IDAReInit(ida_mem, &integrator_ida_fex, tret, yret, ypret);
1064    
1065                        // FIXME this stuff has not been tested yet, and is very incomplete.
1066    
1067                        if(SLV_PARAM_BOOL(&(sys->params),IDA_PARAM_ATOLVECT)){
1068                            /* vector of absolute tolerances */
1069                            CONSOLE_DEBUG("USING VECTOR OF ATOL VALUES");
1070                            abstolvect = N_VNew_Serial(sys->n_y);
1071                            integrator_get_atol(sys,NV_DATA_S(abstolvect));
1072                            flag = IDAReInit(ida_mem, &integrator_ida_fex, tret, yret, ypret, IDA_SV, reltol, abstolvect);
1073                            N_VDestroy_Serial(abstolvect);
1074                        }else{
1075                            /* scalar absolute tolerance (one value for all) */
1076                            abstol = SLV_PARAM_REAL(&(sys->params),IDA_PARAM_ATOL);
1077                            CONSOLE_DEBUG("USING SCALAR ATOL VALUE = %8.2e",abstol);
1078                            flag = IDAReInit(ida_mem, &integrator_ida_fex, tret, yret, ypret, IDA_SS, reltol, &abstol);
1079                        }
1080  #else  #else
1081                      /* allocate internal memory */                      /* allocate internal memory */
1082                      if(SLV_PARAM_BOOL(&(sys->params),IDA_PARAM_ATOLVECT)){                      if(SLV_PARAM_BOOL(&(sys->params),IDA_PARAM_ATOLVECT)){
# Line 1084  static int integrator_ida_solve( Line 1100  static int integrator_ida_solve(
1100                  ERROR_REPORTER_HERE(ASC_PROG_ERR,"Unable to fetch boundary-crossing info");                  ERROR_REPORTER_HERE(ASC_PROG_ERR,"Unable to fetch boundary-crossing info");
1101              }              }
1102              ASC_FREE(rootsfound);              ASC_FREE(rootsfound);
1103          }                    }
1104    
1105    
1106          /* pass the values of everything back to the compiler */          /* pass the values of everything back to the compiler */
# Line 1261  static int integrator_ida_fex(realtype t Line 1277  static int integrator_ida_fex(realtype t
1277              CONSOLE_DEBUG("Calc OK");              CONSOLE_DEBUG("Calc OK");
1278          }*/          }*/
1279      }      }
1280        
1281      if(!is_error){      if(!is_error){
1282          for(i=0;i< enginedata->nrels; ++i){          for(i=0;i< enginedata->nrels; ++i){
1283              if(isnan(NV_Ith_S(rr,i))){              if(isnan(NV_Ith_S(rr,i))){
# Line 1698  int integrator_ida_rootfn(realtype tt, N Line 1714  int integrator_ida_rootfn(realtype tt, N
1714      asc_assert(g_data!=NULL);      asc_assert(g_data!=NULL);
1715      sys = (IntegratorSystem *)g_data;      sys = (IntegratorSystem *)g_data;
1716      enginedata = integrator_ida_enginedata(sys);      enginedata = integrator_ida_enginedata(sys);
1717        
1718      /* pass the values of everything back to the compiler */      /* pass the values of everything back to the compiler */
1719      integrator_set_t(sys, (double)tt);      integrator_set_t(sys, (double)tt);
1720      integrator_set_y(sys, NV_DATA_S(yy));      integrator_set_y(sys, NV_DATA_S(yy));
# Line 1886  static int integrator_ida_psolve_jacobia Line 1902  static int integrator_ida_psolve_jacobia
1902    
1903      linsolqr_add_rhs(L,NV_DATA_S(rvec),FALSE);      linsolqr_add_rhs(L,NV_DATA_S(rvec),FALSE);
1904    
1905      mtx_region_t R;      mtx_region_t R;
1906      R.row.low = R.col.low = 0;      R.row.low = R.col.low = 0;
1907      R.row.high = R.col.high = mtx_order(linsolqr_get_matrix(L)) - 1;      R.row.high = R.col.high = mtx_order(linsolqr_get_matrix(L)) - 1;
1908      linsolqr_set_region(L,R);      linsolqr_set_region(L,R);
1909    
1910      linsolqr_prep(L,linsolqr_fmethod_to_fclass(linsolqr_fmethod(L)));      linsolqr_prep(L,linsolqr_fmethod_to_fclass(linsolqr_fmethod(L)));
1911      linsolqr_reorder(L, &R, linsolqr_rmethod(L));            linsolqr_reorder(L, &R, linsolqr_rmethod(L));
1912    
1913      /// @TODO more here      /// @TODO more here
1914    
# Line 2050  static int integrator_ida_stats(void *id Line 2066  static int integrator_ida_stats(void *id
2066    
2067      int res;      int res;
2068    
2069      /*      /*
2070          There is an error in the documentation for this function in Sundials 2.2.          There is an error in the documentation for this function in Sundials 2.2.
2071          According the the header file, the hinused stat is not provided.          According the the header file, the hinused stat is not provided.
2072      */      */
# Line 2061  static int integrator_ida_stats(void *id Line 2077  static int integrator_ida_stats(void *id
2077    
2078      /* get the missing statistic */      /* get the missing statistic */
2079      IDAGetActualInitStep(ida_mem, &s->hinused);      IDAGetActualInitStep(ida_mem, &s->hinused);
2080        
2081      return res;      return res;
2082  #else  #else
2083    
# Line 2123  static int integrator_ida_transfer_matri Line 2139  static int integrator_ida_transfer_matri
2139      };      };
2140    
2141      struct SystemJacobianStruct D[II_NUM];      struct SystemJacobianStruct D[II_NUM];
2142        
2143      for(i=0;i<II_NUM;++i){      for(i=0;i<II_NUM;++i){
2144          res = system_jacobian(sys->system, matrf[i], matvf[i], 1/*safe*/ ,&(D[i]));          res = system_jacobian(sys->system, matrf[i], matvf[i], 1/*safe*/ ,&(D[i]));
2145      }      }
# Line 2220  static int integrator_ida_write_matrix(c Line 2236  static int integrator_ida_write_matrix(c
2236      if(J.vars)ASC_FREE(J.vars);      if(J.vars)ASC_FREE(J.vars);
2237      if(J.rels)ASC_FREE(J.rels);      if(J.rels)ASC_FREE(J.rels);
2238      if(J.M)mtx_destroy(J.M);      if(J.M)mtx_destroy(J.M);
2239        
2240      return status;      return status;
2241  }  }
2242    

Legend:
Removed from v.2110  
changed lines
  Added in v.2111

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22