[petsc-users] output

Kharche, Sanjay Sanjay.Kharche at liverpool.ac.uk
Wed Jan 23 14:18:36 CST 2013


Dear All

I am an absolute beginner to PetSc. I am trying to output PetSc vectors in a specific format. This may have been discussed before, but I have so far not found a solution.

For 2 or 3 vectors, I do this:

/*
now write it to file.
I would like row 1 to be u, row 2 to be b, and row 3 to be u. that way I can use
gnuplots surf, and also all my existin matlab code for plotting/analysis.
*/
PetscViewer viewer; // a Petsc file pointer.
PetscViewerASCIIOpen(PETSC_COMM_WORLD,"ubx.dat",&viewer);
VecView(u,viewer); // this comes out with information that I dont want, and in a column - I need to put it as a row.
VecView(b,viewer);
VecView(x,viewer);
PetscViewerDestroy( &viewer );

However, I have not been able to get rid of the information about procs, and also the vectors u, b, and u need to be in row format as:
1 2 1 1 1
0 0 0 1 0
-1 2 -1 0

rather than what I have now:

Vector Object: 1 MPI processes
  type: seq
1
2
1
1
1
etc....


Any suggestions on how to do this will be appreciated.

thanks
Sanjay


More information about the petsc-users mailing list