[petsc-users] Create MATSEQAIJ from MATMPIAIJ

Eda Oktay eda.oktay at metu.edu.tr
Mon Jun 22 10:39:41 CDT 2020


Matthew Knepley <knepley at gmail.com>, 22 Haz 2020 Pzt, 14:43 tarihinde
şunu yazdı:
>
> On Mon, Jun 22, 2020 at 7:14 AM Eda Oktay <eda.oktay at metu.edu.tr> wrote:
>>
>> Hello everyone,
>>
>> I am trying to find elements in off diagonal blocks of a parallel
>> sparse matrix. That is why, I want to use MatGetDiagonalBlock and from
>> the matrix I obtain, I want to obtain off diagonal elements by
>> subtracting it from my original matrix by using MatAXPY.
>>
>> However, since MatGetDiagonalBlock gives a sequential matrix and my
>> The original one is parallel, I can't use MatAXPY. That's why I want to
>> change the type of one of the matrices.
>>
>> How can I change a MATSEQAIJ to MATMPIAIJ or vice versa?
>
>
> I assume you want a parallel matrix with the element in the diagonal block removed. I can think
> of at least two ways to do this which sound easier to me:
>
>   1) Make a copy and then zero out the diagonal block is a way similar to MatChop: https://www.mcs.anl.gov/petsc/petsc-current/src/mat/utils/axpy.c.html#MatChop

I read MatChop before, however I couldn't understand how to decide
tolerance. What I understood from this function is to eliminate
entries less than a number which is set to be the tolerance. But the
entries in the diagonal blocks can be less than ones in offdiagonal
blocks. What am I missing?

>
>   2) Use MatGetSubMatrix() and exclude any columns from the diagonal block on each process.
>
>   Thanks,
>
>      Matt
>
>>
>> Thanks!
>
>
>
> --
> 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