[petsc-users] Does MatCopy require Mats to have the same communicator?

Mark Adams mfadams at lbl.gov
Mon Jan 27 11:49:40 CST 2020


Maybe I'm not understanding you -- matCopy does not have your
sub-communicator so how would it create a Mat with it ...

You probably want to use MatGetSubmatrix. This is general, but
the output will have the same communicator, but the idle processors will be
empty, if that is what you specify.
Now you just need to replace the communicator with your sub communicator.
Not sure how to do this but now you have your data in the right place at
least.

Oh, there is a method to create a Mat with a sub communicator with
non-empty rows. Now you use this and use the communicator in the new matrix
as your sub-communicator.

https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMPIAdjCreateNonemptySubcommMat.html


On Mon, Jan 27, 2020 at 11:59 AM David Knezevic <david.knezevic at akselos.com>
wrote:

> I have a case where I'd like to copy a Mat defined on COMM_WORLD to a new
> Mat defined on some sub-communicator. Does MatCopy support this, or would I
> have to write a custom copy operation?
>
> I see here
> <https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatConvert.html#MatConvert>
> that MatConvert requires identical communicators, but I don't see any
> mention of this for MatCopy, so I wanted to check.
>
> Thanks,
> David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200127/0c3e002a/attachment.html>


More information about the petsc-users mailing list