[petsc-users] Some help for partitioning a vector

Barry Smith bsmith at mcs.anl.gov
Tue Jun 28 11:22:12 CDT 2016


  Only parallel vectors can be multiplied with parallel matrices and the vector and matrix must exist on the same MPI communicator. In your case you are trying to multiple a sequential vector by a parallel matrix.  You should use VecCreateMPI(PETSC_COMM_WORLD, PETSC_DECIDE, size_,&vol_);
                                                                                                                                         ^^^^^^ 
                      use PETSC_COMM_WORLD or the communicator you used in creating the matrix, don't use PETSC_COMM_SELF


> On Jun 28, 2016, at 9:14 AM, ehsan sadrfaridpour <it.sadr at gmail.com> wrote:
> 
> Hi, 
> Sorry for long email. My questions are in the bottom.
> 
> I try to use MatMult to multiply a vector to a matrix but I face below problem. 
> [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
> [0]PETSC ERROR: Nonconforming object sizes
> [0]PETSC ERROR: Incompatible partition of A (20) and xx (40)
> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.
> [1]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
> [1]PETSC ERROR: Nonconforming object sizes
> [1]PETSC ERROR: Incompatible partition of A (20) and xx (40)
> [1]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.
> [1]PETSC ERROR: Petsc Release Version 3.6.3, unknown 
> 
> I use 2 process for this. I check the local ranges with VecGetOwnershipRange and MatGetOwnershipRange commands and they reveal that the matrix is distributed between processes while the vector is exist completely on both processes.
> in rank:1, vector start:0, end:40, matrix start:20, end:40
> in rank:0, vector start:0, end:40, matrix start:0, end:20
> 
> I created the vector "vol_" using below commands.
>    Vec vol_;
>     VecCreateMPI(PETSC_COMM_SELF, PETSC_DECIDE, size_,&vol_);
>     VecSet(vol_,val);           //Sets all components of a vector to a single scalar value.
>     VecAssemblyBegin(vol_);
>     VecAssemblyEnd(vol_);
> 
> My questions:
> A- What should I do differently to create a scattered vector in the first place?
> B- If my vector initialization is ok, what should I do now to scatter the vector among the processes? 
> I saw the VecScatter function, but I am not sure how to use it, if it is the right function.
> 
> Best,
> Ehsan
> 



More information about the petsc-users mailing list