[petsc-users] Question about MatCreateSubMatrix

Jed Brown jed at jedbrown.org
Thu Mar 29 15:12:22 CDT 2018

Manav Bhatia <bhatiamanav at gmail.com> writes:

> Hi, 
>   I have quick questions about MatCreateSubMatrix:
> — Once the sub matrix is created, do I need to keep the IS (isrow and iscol) in memory till this matrix is active, or can I destroy it immediately after the creation of the matrix and continue to use the matrix? 

You don't need to keep them.

> — Is the assembly begin/end supposed to be called on the submatrix or the original full matrix? Is it a problem is I call this on both? 

I think you're referring to MatCreateSubMatrixVirtual, and you only need
to assemble on the outer matrix.

> — If I modify values in the sub matrix, would these be reflected in the original matrix after assembly begin/end, or do I need to do something else for that to happen? 

Normally you would only call MatSetValues* on the virtual submatrix.  I
hope src/snes/examples/tutorials/ex28.c answers further questions by way
of example, but let us know if not.

More information about the petsc-users mailing list