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
parent 6791e04601
commit 9e030f52ce
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 { } else {
if (Matrix->CKTkluCommon->status == KLU_SINGULAR) { if (Matrix->CKTkluCommon->status == KLU_SINGULAR) {
fprintf (stderr, "Warning: KLU Matrix is SINGULAR\n") ; fprintf (stderr, "Warning: KLU Matrix is SINGULAR\n") ;
return E_SINGULAR ;
} }
return 0 ; return 0 ;
} }
@ -614,6 +615,7 @@ SMPreorder (SMPmatrix *Matrix, double PivTol, double PivRel, double Gmin)
} else { } else {
if (Matrix->CKTkluCommon->status == KLU_SINGULAR) { if (Matrix->CKTkluCommon->status == KLU_SINGULAR) {
fprintf (stderr, "Warning: KLU Matrix is SINGULAR\n") ; fprintf (stderr, "Warning: KLU Matrix is SINGULAR\n") ;
return E_SINGULAR ;
} }
return 0 ; return 0 ;
} }
@ -673,6 +675,7 @@ SMPreorderKLUforCIDER (SMPmatrix *Matrix)
} else { } else {
if (Matrix->CKTkluCommon->status == KLU_SINGULAR) { if (Matrix->CKTkluCommon->status == KLU_SINGULAR) {
fprintf (stderr, "Warning (CIDER): KLU Matrix is SINGULAR\n") ; fprintf (stderr, "Warning (CIDER): KLU Matrix is SINGULAR\n") ;
return E_SINGULAR ;
} }
return 0 ; return 0 ;
} }

View File

@ -135,9 +135,20 @@ NIiter(CKTcircuit *ckt, int maxIter)
SPfrontEnd->IFseconds() - startTime; SPfrontEnd->IFseconds() - startTime;
if (error) { if (error) {
if (error == E_SINGULAR) { 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; ckt->CKTniState |= NISHOULDREORDER;
DEBUGMSG(" forced reordering....\n"); DEBUGMSG(" forced reordering....\n");
continue; continue;
#endif
} }
/* CKTload(ckt); */ /* CKTload(ckt); */
/* SMPprint(ckt->CKTmatrix, stdout); */ /* SMPprint(ckt->CKTmatrix, stdout); */