Skip to content

Commit 0c85d9a

Browse files
Willi BraunOpenModelica-Hudson
authored andcommitted
add exception for ida solver if no sparsity available
1 parent 95e5e65 commit 0c85d9a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

SimulationRuntime/c/simulation/solver/ida_solver.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ ida_solver_initial(DATA* data, threadData_t *threadData, SOLVER_INFO* solverInfo
391391
}
392392

393393
/* selects the calculation method of the jacobian */
394-
/* in daeMode sparse pattern is already initialized in DAEMODE_DATA */
394+
/* in daeMode sparse pattern is already initialized in DAEMODE_DATA */
395395
if(!idaData->daeMode && (idaData->jacobianMethod == COLOREDNUMJAC ||
396396
idaData->jacobianMethod == COLOREDSYMJAC ||
397397
idaData->jacobianMethod == KLUSPARSE ||
@@ -401,6 +401,12 @@ ida_solver_initial(DATA* data, threadData_t *threadData, SOLVER_INFO* solverInfo
401401
{
402402
infoStreamPrint(LOG_STDOUT, 0, "Jacobian or SparsePattern is not generated or failed to initialize! Switch back to normal.");
403403
idaData->jacobianMethod = INTERNALNUMJAC;
404+
if (idaData->linearSolverMethod == IDA_LS_KLU)
405+
{
406+
idaData->linearSolverMethod = IDA_LS_DENSE;
407+
flag = IDADense(idaData->ida_mem, idaData->N);
408+
warningStreamPrint(LOG_STDOUT, 0, "IDA linear solver method also switched back to %s", IDA_LS_METHOD_DESC[idaData->linearSolverMethod]);
409+
}
404410
}
405411
}
406412

0 commit comments

Comments
 (0)