[petsc-users] Create MATSEQAIJ from MATMPIAIJ

Matthew Knepley knepley at gmail.com
Mon Jun 22 11:10:14 CDT 2020


On Mon, Jun 22, 2020 at 11:39 AM Eda Oktay <eda.oktay at metu.edu.tr> wrote:

> 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?
>

You _change_ the code. MatChop decides to make an element zero by looking
at how big it is. You would decide
to make an element zero by looking at what column it is in.

  Thanks,

     Matt


> >
> >   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/
>


-- 
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/c2146fc7/attachment.html>


More information about the petsc-users mailing list