static PetscErrorCode MatDestroy_UMFPACK(Mat A) { PetscErrorCode ierr; Mat_UMFPACK *lu=(Mat_UMFPACK*)A->spptr; PetscFunctionBegin; if (lu && lu->CleanUpUMFPACK) { umfpack_UMF_free_symbolic(&lu->Symbolic); umfpack_UMF_free_numeric(&lu->Numeric); ierr = PetscFree(lu->Wi);CHKERRQ(ierr); ierr = PetscFree(lu->W);CHKERRQ(ierr); ierr = PetscFree(lu->perm_c);CHKERRQ(ierr); } ierr = MatDestroy(&lu->A);CHKERRQ(ierr); ierr = PetscFree(A->spptr);CHKERRQ(ierr); ierr = MatDestroy_SeqAIJ(A);CHKERRQ(ierr); PetscFunctionReturn(0); }
static PetscErrorCode MatLUFactorNumeric_UMFPACK(Mat F,Mat A,const MatFactorInfo *info) { Mat_UMFPACK *lu = (Mat_UMFPACK*)(F)->spptr; Mat_SeqAIJ *a = (Mat_SeqAIJ*)A->data; PetscInt *ai = a->i,*aj=a->j,status; PetscScalar *av = a->a; PetscErrorCode ierr; PetscFunctionBegin; /* numeric factorization of A' */ /* ----------------------------*/ if (lu->flg == SAME_NONZERO_PATTERN && lu->Numeric) { umfpack_UMF_free_numeric(&lu->Numeric); } #if defined(PETSC_USE_COMPLEX) status = umfpack_UMF_numeric(ai,aj,(double*)av,NULL,lu->Symbolic,&lu->Numeric,lu->Control,lu->Info); #else status = umfpack_UMF_numeric(ai,aj,av,lu->Symbolic,&lu->Numeric,lu->Control,lu->Info); #endif if (status < 0) { umfpack_UMF_report_status(lu->Control, status); SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"umfpack_UMF_numeric failed"); } /* report numeric factorization of A' when Control[PRL] > 3 */ (void) umfpack_UMF_report_numeric(lu->Numeric, lu->Control); ierr = PetscObjectReference((PetscObject)A);CHKERRQ(ierr); ierr = MatDestroy(&lu->A);CHKERRQ(ierr); lu->A = A; lu->flg = SAME_NONZERO_PATTERN; lu->CleanUpUMFPACK = PETSC_TRUE; F->ops->solve = MatSolve_UMFPACK; F->ops->solvetranspose = MatSolveTranspose_UMFPACK; PetscFunctionReturn(0); }