Fixed KLU returns values so that NIiter can Factor again, if the matrix is numerically singular from the refactorization

Fixed the NIiter code to perform a factorization without reloading the matrix
This commit is contained in:
Francesco Lannutti 2020-06-16 15:35:37 +02:00 committed by Holger Vogt
parent 72d78a2053
commit 710341bbfd
2 changed files with 14 additions and 0 deletions

View File

@ -568,6 +568,7 @@ SMPcReorder (SMPmatrix *Matrix, double PivTol, double PivRel, int *NumSwaps)
} else {
if (Matrix->CKTkluCommon->status == KLU_SINGULAR) {
fprintf (stderr, "Warning: KLU Matrix is SINGULAR\n") ;
return E_SINGULAR ;
}
return 0 ;
}
@ -614,6 +615,7 @@ SMPreorder (SMPmatrix *Matrix, double PivTol, double PivRel, double Gmin)
} else {
if (Matrix->CKTkluCommon->status == KLU_SINGULAR) {
fprintf (stderr, "Warning: KLU Matrix is SINGULAR\n") ;
return E_SINGULAR ;
}
return 0 ;
}
@ -673,6 +675,7 @@ SMPreorderKLUforCIDER (SMPmatrix *Matrix)
} else {
if (Matrix->CKTkluCommon->status == KLU_SINGULAR) {
fprintf (stderr, "Warning (CIDER): KLU Matrix is SINGULAR\n") ;
return E_SINGULAR ;
}
return 0 ;
}

View File

@ -145,9 +145,20 @@ NIiter(CKTcircuit *ckt, int maxIter)
SPfrontEnd->IFseconds() - startTime;
if (error) {
if (error == E_SINGULAR) {
#ifdef KLU
error = SMPreorder(ckt->CKTmatrix, ckt->CKTpivotAbsTol, ckt->CKTpivotRelTol, ckt->CKTdiagGmin);
ckt->CKTstat->STATreorderTime += SPfrontEnd->IFseconds() - startTime;
if (error) {
SMPgetError(ckt->CKTmatrix, &i, &j);
SPfrontEnd->IFerrorf (ERR_WARNING, "singular matrix: check nodes %s and %s\n", NODENAME(ckt, i), NODENAME(ckt, j));
}
#else
ckt->CKTniState |= NISHOULDREORDER;
DEBUGMSG(" forced reordering....\n");
continue;
#endif
}
/* CKTload(ckt); */
/* SMPprint(ckt->CKTmatrix, stdout); */