How do I collect all the values from a parallel PETSc vector into a sequential vector on each processor?
You can do this by first creating a SEQ vector on each processor with as many entries as the global vector. Say mpivec is your parallel vector and seqvec a sequential vector where you want to store all the values from mpivec, but on a single node. int N; ierr = VecGetSize(mpivec,&N); Vec seqvec; ierr = VecCreateSeq(PETSC_COMM_SELF,N,&segvec); or ierr = VecCreateSeqWithArray(PETSC_COMM_SELF,N,array,&segvec); then create a vector scatter that gathers together the values from all processors into the large sequential vector on each processor.