[petsc-users] Getting a sequential copy of a parallel vector

Barry Smith bsmith at mcs.anl.gov
Wed Jan 12 17:07:40 CST 2011


  To save the vector in binary format for later processing you should use VecView() with a PetscViewerOpenBinary() viewer, it saves all the monkeying around of moving a vector to one process. 

  If you want the zeroth process or all processes to have the entire Vector you can use VecScatterCreateToAll() or VecScatterCreateToZero(), this handles all the business of building the IS and scatter for you. You just call the VecScatterBegin/End()

   Barry

On Jan 12, 2011, at 4:03 PM, Ormiston, Scott J. wrote:

> We are new to PETSc and are testing the KSP solvers.
> 
> We think we can fill a PETSc matrix and right hand side vector and get a parallel solution vector, but we are not sure how to get a copy of the solution vector that we can use in other calculations and to write results to a file.
> We are using Fortran 95.
> 
> We are looking at a sequence of calls involving
> 
> ISCreateGeneral()
> VecScatterCreate()
> VecScatterBegin()
> VecScatterEnd()
> 
> along with
> ISDestroy()
> VecScatterDestroy().
> 
> Is this the correct approach?
> 
> We can only find ex30f.F as an example. Is there a better fortran example somewhere that shows how to do this?
> Thanks.
> 
> Scott J. Ormiston  Ph.D., Professor
> University of Manitoba
> 



More information about the petsc-users mailing list