Conversion from array to PETSc and from PETSc to array

You should never use dense matrices when you have systems of that size. Then you need to use CSR matrices, as explained in: Converting to SciPy sparse matrix without Eigen backend - #2 by MiroK

If you have a 100 000 by 100 000 means 10 000 000 000 nonzeros.