[petsc-users] Create MATSEQAIJ from MATMPIAIJ
Matthew Knepley
knepley at gmail.com
Mon Jun 22 06:43:44 CDT 2020
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
> 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
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/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200622/ea5b241d/attachment.html>
More information about the petsc-users
mailing list