1919
2020/* Header files with a description of contents used */
2121
22- //#define USE_JACOBIAN
23- //#ifdef USE_JACOBIAN
22+ // #define USE_JACOBIAN
23+ // #ifdef USE_JACOBIAN
2424#include <ida/ida_klu.h> /* prototype for CVSUPERLUMT */
2525#include <sundials/sundials_sparse.h> /* definitions SlsMat */
26- //#endif
26+ // #endif
2727
2828#include <ida/ida.h>
2929#include <ida/ida_dense.h>
@@ -52,7 +52,7 @@ static CLC_model clcModel = NULL;
5252
5353static SD_output simOutput = NULL ;
5454
55- //#ifdef USE_JACOBIAN
55+ // #ifdef USE_JACOBIAN
5656/* Test jacobian */
5757static int IDA_Jac (realtype t , realtype cj , N_Vector y , N_Vector fy , N_Vector resvec , SlsMat JacMat , void * user_data , N_Vector tmp1 ,
5858 N_Vector tmp2 , N_Vector tmp3 )
@@ -81,7 +81,7 @@ static int IDA_Jac(realtype t, realtype cj, N_Vector y, N_Vector fy, N_Vector re
8181
8282 return 0 ;
8383}
84- //#endif
84+ // #endif
8585
8686/* Test jacobian */
8787static int check_flag (void * flagvalue , const char * funcname , int opt , CLC_simulator simulator )
@@ -200,11 +200,7 @@ void IDA_integrate(SIM_simulator simulate)
200200 flag = IDARootInit (mem , clcData -> events , IDA_events );
201201 if (check_flag (& flag , "IDARootInit" , 1 , simulator )) return ;
202202
203- //#ifndef USE_JACOBIAN
204203 if (simulator -> data -> params -> jacobian == 1 ) {
205- flag = IDADense (mem , size );
206- if (check_flag (& flag , "IDADense" , 1 , simulator )) return ;
207- } else {
208204 nnz = 0 ;
209205 for (i = 0 ; i < size ; i ++ ) {
210206 nnz += clcData -> nSD [i ];
@@ -217,9 +213,11 @@ void IDA_integrate(SIM_simulator simulate)
217213
218214 flag = IDASlsSetSparseJacFn (mem , IDA_Jac );
219215 if (check_flag (& flag , "IDASlsSetSparseJacFn" , 1 , simulator )) return ;
216+ } else {
217+ flag = IDADense (mem , size );
218+ if (check_flag (& flag , "IDADense" , 1 , simulator )) return ;
220219 }
221220
222- //#endif
223221 double * res = malloc (sizeof (double ) * size );
224222 IDASetUserData (mem , res );
225223 getTime (simulator -> stats -> sTime );
0 commit comments