[petsc-users] questions about parallel vectors

Xiangdong Liang xdliang at gmail.com
Fri Apr 29 10:50:06 CDT 2011


Hello everyone,

I am trying to create a sparse matrix A, which depends on a parallel
vector v. For example, my function looks like this:  Mat
myfun(MPI_Comm comm, Vec v, other parameters). When I set the value
A(i,j) = v[k], v[k] may not be obtained by VecGetValues since that
operation can only get values on the same processor. I am thinking

1) create v as an array and pass this array into myfun.
2)  create another vector v2, which is a full copy of parallel v
through VecScatter.
3)  when I first create the initial vec v, using
VecCreate(PETSC_COMM_SELF,v) or VecCreateSeq. Does this guarantee that
all the processors creating matrix A have all the components of vector
v?

I think 1) and 2) are going to work, but not sure about option 3). I
have no idea which would have better performance. Can you give me some
suggestions on how to handle this problem? Thanks.

Another quick question, what is the difference between
PetscViewerSetFormat and PetscViewerPushFormat?

Best,
Xiangdong


More information about the petsc-users mailing list