[petsc-users] Slepc reading distributed matrix from files

Jose E. Roman jroman at dsic.upv.es
Tue Jul 4 04:48:52 CDT 2017


> El 4 jul 2017, a las 11:22, errabii sohaib <errabiisohaib at gmail.com> escribió:
> 
> Hi, 
> 
> I am trying to use petsc4py and slepc4py to read a matrix that is distributed on several files, In which i save the non zero elements by specifiying three arrays (A, I, J) for Coeffs, rows and columns indices. 
> I am currently using MUMPS and i simply read a file and pass the A,I,J arrays to MUMPS with each process. I am trying to do the same, however i am still confused how matrices are structured in PETSc and if its even possible to read n files and pass the matrix to PETsc to solve with slepc4py using atleast n processes.
> 
> Thank you very much for your time,
> Sohaib.
> 
> 
> 

You can use createAIJWithArrays(), for instance

I = [0, 2, 5, 8, 11, 14, 16]
J = [0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5]
A = [2, -1, -1, 2, -1, -1, 2, -1, -1, 2, -1, -1, 2, -1, -1, 2]
M = PETSc.Mat();
M.createAIJWithArrays([6, 6], (I,J,A))
M.view()


Note that I is not the row index but the pointer to row start (according to the usual compressed sparse row format).

Jose



More information about the petsc-users mailing list