#include #include /* MatDumpSPAI - Dumps a PETSc matrix to a file in an ASCII format suitable for the SPAI code of Stephen Barnard to solve. This routine is simply here to allow testing of matrices directly with the SPAI code, rather then through the PETSc interface. */ PetscErrorCode MatDumpSPAI(Mat A,FILE *file) { const PetscScalar *vals; PetscErrorCode ierr; int i,j,n,size,nz; const int *cols; MPI_Comm comm; PetscObjectGetComm((PetscObject)A,&comm); MPI_Comm_size(comm,&size); if (size > 1) SETERRQ(PetscObjectComm((PetscObject)A),PETSC_ERR_SUP,"Only single processor dumps"); ierr = MatGetSize(A,&n,&n);CHKERRQ(ierr); /* print the matrix */ fprintf(file,"%d\n",n); for (i=0; i