Skip to content

Commit

Permalink
bugfixes for umfpack-binding
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21396 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Michael Kloeppel committed Jul 2, 2014
1 parent 662bb3a commit 83e92eb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions SimulationRuntime/cpp/Core/Math/SparseMatrix.cpp
Expand Up @@ -3,14 +3,14 @@
#ifdef USE_UMFPACK
void sparse_matrix::build(sparse_inserter& ins) {
if(n==-1) {
n=ins.content.rbegin()->first.first;
n=ins.content.rbegin()->first.first+1;
} else {
if(n-1!=ins.content.rbegin()->first.first) {
throw std::runtime_error("size doesn't match");
}
}
size_t n=ins.content.size();
Ap.resize(this->n+1,0);
Ap.assign(this->n+1,0);
Ai.resize(n);
Ax.resize(n);
unsigned int j=0;
Expand All @@ -29,7 +29,7 @@ void sparse_matrix::build(sparse_inserter& ins) {
}

int sparse_matrix::solve(const double* b, double * x) {
int status, sys;
int status, sys=0;
double Control [UMFPACK_CONTROL], Info [UMFPACK_INFO] ;
void *Symbolic, *Numeric ;
umfpack_di_defaults (Control) ;
Expand All @@ -38,7 +38,7 @@ int sparse_matrix::solve(const double* b, double * x) {
status = umfpack_di_solve (sys, &sparse_matrix::Ap[0], &sparse_matrix::Ai[0], &sparse_matrix::Ax[0], x, b, Numeric, Control, Info);
umfpack_di_free_symbolic (&Symbolic);
umfpack_di_free_numeric (&Numeric);
return 0;
return status;
}
#else
void sparse_matrix::build(sparse_inserter& ins) {
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/Include/Core/Math/SparseMatrix.h
Expand Up @@ -4,7 +4,7 @@
#include "Modelica.h"
#ifdef USE_UMFPACK
#include "umfpack.h"
#endif USE_UMFPACK
#endif

using std::map;
using std::pair;
Expand Down
3 changes: 2 additions & 1 deletion SimulationRuntime/cpp/Solver/UmfPack/UmfPack.cpp
Expand Up @@ -25,7 +25,8 @@ void UmfPack::initialize()
void UmfPack::solve()
{
#ifdef USE_UMFPACK

_algLoop->evaluate();
_algLoop->getRHS(_rhs);
_algLoop->getSystemMatrix(_jac);

int status=_jac->solve(_rhs,_x);
Expand Down

0 comments on commit 83e92eb

Please sign in to comment.