[petsc-users] is there a function to append matrix

Jed Brown jed at jedbrown.org
Mon Aug 31 23:22:44 CDT 2020


Karl Lin <karl.linkui at gmail.com> writes:

> Thanks for the feedback. What about if I build A to have as many rows as A
> and B and then later on use MatGetRow and MatSetValues to add B matrix
> entries to A? Can MatGetRow and MatSetValues be used after MatAssembly is
> called? B is much much smaller than A so the number of rows can be added to
> just the portion of A on one process. Will this work? Thanks. Regards.

That would work fine, you'll just need to MatAssembly after your new MatSetValues.

Note that you'll likely want to think about the distribution of B relative to A; you may not want B to come "at the end" because it'll all be on the last rank, versus dispersed over the ranks.  This is especially true if those rows are heavier.

> On Mon, Aug 31, 2020 at 11:00 PM Jed Brown <jed at jedbrown.org> wrote:
>
>> Karl Lin <karl.linkui at gmail.com> writes:
>>
>> > I guess another way to look at this is if I already build matrix A and
>> > MatAssembly has been called. Can I populate more rows to matrix A later
>> on?
>> > With the number of columns and column ownership pattern not changed of
>> > course. Thank you.
>>
>> No.
>>


More information about the petsc-users mailing list