I have an example code in python which uses PETSC:
import petsc4py,sys from petsc4py import PETSc petsc4py.init(sys.argv) # grid size and spacing m,n=32,32