Skip to content

Commit

Permalink
Fix for using default sparse linear solver
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - OpenModelica/OMCompiler#1918
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Oct 17, 2017
1 parent 3486958 commit f55d7d6
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions SimulationRuntime/c/simulation/solver/linearSystem.c
Expand Up @@ -73,6 +73,14 @@ int initializeLinearSystems(DATA *data, threadData_t *threadData)
infoStreamPrint(LOG_LS, 1, "initialize linear system solvers");
infoStreamPrint(LOG_LS, 0, "%ld linear systems", data->modelData->nLinearSystems);

if (LSS_DEFAULT == data->simulationInfo->lssMethod) {
#ifdef WITH_UMFPACK
data->simulationInfo->lssMethod = LSS_KLU;
#elif !defined(OMC_MINIMAL_RUNTIME)
data->simulationInfo->lssMethod = LSS_LIS;
#endif
}

for(i=0; i<data->modelData->nLinearSystems; ++i)
{
size = linsys[i].size;
Expand Down Expand Up @@ -126,7 +134,6 @@ int initializeLinearSystems(DATA *data, threadData_t *threadData)
linsys[i].setBElement = setBElement;
allocateUmfPackData(size, size, nnz, linsys[i].solverData);
break;
case LSS_DEFAULT:
case LSS_KLU:
linsys[i].setAElement = setAElementKlu;
linsys[i].setBElement = setBElement;
Expand All @@ -139,25 +146,27 @@ int initializeLinearSystems(DATA *data, threadData_t *threadData)
break;
#endif
#if !defined(OMC_MINIMAL_RUNTIME)
#if !defined(WITH_UMFPACK)
case LSS_DEFAULT:
#endif
case LSS_LIS:
linsys[i].setAElement = setAElementLis;
linsys[i].setBElement = setBElementLis;
allocateLisData(size, size, nnz, linsys[i].solverData);
break;
#else
case LSS_LIS:
throwStreamPrint(threadData, "OMC is compiled without sparse linear solver Lis.");
break;
#endif
#if defined(OMC_MINIMAL_RUNTIME) && !defined(WITH_UMFPACK)
case LSS_DEFAULT:
{
int indexes[2] = {1, linsys[i].equationIndex};
infoStreamPrintWithEquationIndexes(LOG_STDOUT, 0, indexes, "The simulation runtime does not have access to sparse solvers. Defaulting to a dense linear system solver instead.");
linsys[i].useSparseSolver = 0;
break;
}
#endif
default:
throwStreamPrint(threadData, "unrecognized linear solver");
throwStreamPrint(threadData, "unrecognized sparse linear solver (%d)", data->simulationInfo->lssMethod);
}
}
if(linsys[i].useSparseSolver == 0) { /* Not an else-statement because there might not be a sparse linear solver available */
Expand Down Expand Up @@ -212,7 +221,7 @@ int initializeLinearSystems(DATA *data, threadData_t *threadData)
break;

default:
throwStreamPrint(threadData, "unrecognized linear solver");
throwStreamPrint(threadData, "unrecognized dense linear solver (%d)", data->simulationInfo->lsMethod);
}
}
}
Expand Down Expand Up @@ -315,7 +324,7 @@ int freeLinearSystems(DATA *data, threadData_t *threadData)
#endif

default:
throwStreamPrint(threadData, "unrecognized linear solver");
throwStreamPrint(threadData, "unrecognized sparse linear solver (%d)", data->simulationInfo->lssMethod);
}
}

Expand Down Expand Up @@ -358,7 +367,7 @@ int freeLinearSystems(DATA *data, threadData_t *threadData)
break;

default:
throwStreamPrint(threadData, "unrecognized linear solver");
throwStreamPrint(threadData, "unrecognized dense linear solver (data->simulationInfo->lsMethod)");
}
}

Expand Down

0 comments on commit f55d7d6

Please sign in to comment.