[petsc-users] petsc viewer

Barry Smith bsmith at mcs.anl.gov
Mon Jul 8 13:00:59 CDT 2013


On Jul 8, 2013, at 12:38 PM, "Shaohao Chen" <shchen at www.phys.lsu.edu> wrote:

> Dear all,
> 
> I can use VecView(vec, viewer) and correctly output a distributed vector. But when I use it in an 
> iteration, it doesn't work. My codes are like: 
> 
> PetscViewerCreate(PETSC_COMM_WORLD, &viewer1);
> ......  // modify values of vec
> VecView(vec, viewer1) ;  // correct
> 
> PetscViewerCreate(PETSC_COMM_WORLD, &viewer2);

You need to set the type of viewer here.

> for(i=0;i<n;i++){
>  ......  // modify values of vec
>  VecView(vec, viewer2) ;  // incorrect
> }
> 
> In viewer1, it outputs the whole correct vector. In viewer2, it just outputs part of the vector and 
> then stop at the first step of the iteration.

   What do you mean "stop"? Does it print an error message?

> And it becomes much slower when I add the VecView line 
> in the iteration. The same happens to MatView. What is the problem here? 

 calls to  VecView and MatView (especially) will slow down a code since it involves IO. In particular if the file you are saving to is on a slow file server it could slow it down a great deal. Best to save to a local disk.
 
   Barry

> 
> Thank you for your attention!
> 
> --
> Shaohao Chen
> Department of Physics & Astronomy, 
> Louisiana State University, 
> Baton Rouge, LA



More information about the petsc-users mailing list