[petsc-users] Matrix Decomposition

Smith, Barry F. bsmith at mcs.anl.gov
Wed May 15 08:34:21 CDT 2019


   You cannot change the sizes after the matrix is assembled, nor can you duplicate a matrix with a different layout from the original matrix.

   If you want to partition a matrix that already exists use MatCreateSubMatrix(). You can use ISCreateStride() to generate the IS that define
the new layout you want.

   Barry

   But when possible I would set the sizes of the matrix before loading it since then you don't need two copies of the matrix in memory at the same time.


> On May 15, 2019, at 8:06 AM, Eda Oktay via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> Dear Matt,
> 
> I am trying to distribute the matrix after loading it. So I tried something like this:
> 
>   Mat B;
>   PetscInt bm,bn;
>   MatSetSizes(B,kk,kk,PETSC_DETERMINE,PETSC_DETERMINE);
>   MatDuplicate(A,MAT_COPY_VALUES,&B);
>   MatGetLocalSize(B,&bm,&bn);
> 
> where A is the original matrix (10*10) and kk is one the local sizes of A (kk=4 so I want to divide A into 4*4 and 6*6). However, I get error in MatSetSizes part and when I printed bm and bn, I get 5. In other words, B is divided equally even though I tried to divide it unequally. Am I using MatSetSizes wrong?
> 
> Thanks,
> 
> Eda
> 
> Matthew Knepley <knepley at gmail.com>, 15 May 2019 Çar, 14:51 tarihinde şunu yazdı:
> On Wed, May 15, 2019 at 7:35 AM Eda Oktay via petsc-users <petsc-users at mcs.anl.gov> wrote:
> Hello,
> 
> I am trying to divide a matrix into unequal sized parts into different processors (for example I want to divide 10*10 matrix into 4*4 and 6*6 submatrix in two processors). When my program reads a matrix from file, it automatically divides it into equal parts and then I can't change local sizes.
> 
> How can I decompose a matrix that is read from a file?
> 
> MatLoad() takes a matrix argument. I believe you can use MatSetSizes() before loading to get the distribution you want.
> 
>    Matt
>  
> Thanks,
> 
> Eda
> 
> 
> -- 
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
> -- Norbert Wiener
> 
> https://www.cse.buffalo.edu/~knepley/



More information about the petsc-users mailing list