Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I collect all the values from a parallel PETSc vector into a sequential vector on each processor?

0
Posted

How do I collect all the values from a parallel PETSc vector into a sequential vector on each processor?

0

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.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123