Add the support for '.ic' and '.nodeset' instructions within KLU

This commit is contained in:
Francesco Lannutti 2017-09-19 09:51:15 +02:00 committed by rlar
parent 10a7add46a
commit 0098c008b1
2 changed files with 73 additions and 0 deletions

View File

@ -996,6 +996,40 @@ LoadGmin (SMPmatrix *eMatrix, double Gmin)
SMPelement *
SMPfindElt (SMPmatrix *eMatrix, int Row, int Col, int CreateIfMissing)
{
#ifdef KLU
if (eMatrix->CKTkluMODE) {
int *Ai, *Ap, i ;
double *Ax ;
Ai = eMatrix->CKTkluAi ;
Ap = eMatrix->CKTkluAp ;
Ax = eMatrix->CKTkluAx ;
Row = eMatrix->SPmatrix->ExtToIntRowMap [Row] ;
Col = eMatrix->SPmatrix->ExtToIntColMap [Col] ;
if ((Row > 0) && (Col > 0)) {
for (i = Ap [Col - 1] ; i < Ap [Col] ; i++) {
if (Ai [i] == Row - 1) {
return (SMPelement *)&(Ax [i]) ;
}
}
}
return NULL ;
} else {
MatrixPtr Matrix = eMatrix->SPmatrix ;
ElementPtr Element ;
/* Begin `SMPfindElt'. */
assert (IS_SPARSE (Matrix)) ;
Row = Matrix->ExtToIntRowMap [Row] ;
Col = Matrix->ExtToIntColMap [Col] ;
Element = Matrix->FirstInCol [Col] ;
Element = spcFindElementInCol (Matrix, &Element, Row, Col, CreateIfMissing) ;
return (SMPelement *)Element ;
}
#else
MatrixPtr Matrix = eMatrix->SPmatrix ;
ElementPtr Element ;
@ -1006,6 +1040,8 @@ SMPfindElt (SMPmatrix *eMatrix, int Row, int Col, int CreateIfMissing)
Element = Matrix->FirstInCol [Col] ;
Element = spcFindElementInCol (Matrix, &Element, Row, Col, CreateIfMissing) ;
return (SMPelement *)Element ;
#endif
}
/* XXX The following should probably be implemented in spUtils */

View File

@ -25,15 +25,52 @@ CKTic(CKTcircuit *ckt)
for(node = ckt->CKTnodes;node != NULL; node = node->next) {
if(node->nsGiven) {
#ifdef KLU
if (ckt->CKTmatrix->CKTkluMODE) {
if (node->number > 0) {
int i ;
for (i = node->number - 1 ; i < node->number ; i++) {
if (ckt->CKTmatrix->CKTkluAi [i] == node->number - 1) {
node->ptr = &(ckt->CKTmatrix->CKTkluAx [i]) ;
}
}
}
} else {
node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number,node->number);
}
#else
node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number,node->number);
#endif
if(node->ptr == NULL) return(E_NOMEM);
ckt->CKThadNodeset = 1;
ckt->CKTrhs[node->number] = node->nodeset;
}
if(node->icGiven) {
if(! ( node->ptr)) {
#ifdef KLU
if (ckt->CKTmatrix->CKTkluMODE) {
if (node->number > 0) {
int i ;
for (i = node->number - 1 ; i < node->number ; i++) {
if (ckt->CKTmatrix->CKTkluAi [i] == node->number - 1) {
node->ptr = &(ckt->CKTmatrix->CKTkluAx [i]) ;
}
}
}
} else {
node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number,
node->number);
}
#else
node->ptr = SMPmakeElt(ckt->CKTmatrix,node->number,
node->number);
#endif
if(node->ptr == NULL) return(E_NOMEM);
}
ckt->CKTrhs[node->number] = node->ic;