[petsc-users] question about creating a block matrix

Jed Brown jed at jedbrown.org
Mon Aug 10 23:00:19 CDT 2020


Randall Mackie <rlmackie862 at gmail.com> writes:

> Dear PETSc users -
>
> I am trying to create a block matrix but it is not clear to me what is the right way to do this.
>
> First, I create 2 sparse matrices J1 and J2 using two different DMDAs.
> Then I compute the products J1^T J1, and J2^T J2, which are different sized matrices.
>
> Since the matrices are already constructed and built, what is the best way to place those matrices into a block matrix?

Block diagonal or are they coupled?

> Does it work to create a composite DM, call DMCreateMatrix on the composite DM, then call MatGetLocalSubMatrix on the blocks, then simply do a MatCopy?

If the matrices are already assembled and there is no going back on that, it'd be easiest to use MatNest and then MatConvert (if you don't want a split solver).


More information about the petsc-users mailing list