[petsc-users] adding mat rows

Carles Bona carlesbona at gmail.com
Thu Nov 19 11:25:13 CST 2015


Dear all,

I would like to add some of my equations before I modify them. I haven't
found any high level function that would allow me to add rows of a matrix
(I am working with a parallel BAIJ). Is there any nice way of doing this?

I have tried with MatGetRow/MatRestoreRow, but I am struggling a bit to
retain the cols and vals, as only one processor can call MatGetRow but if
only that processor tries to allocate memory then one gets a segmentation
fault. I guess I should allocate enough memory on all processors...

If I refrain from storing the cols and vals I need to call MatSetValues
before returning the pointer, with a subsequent call to assemblybegin/end
for each row, which slows down the code.

The other option would be to forget about these row additions after the
matrix has been filled and try to fill it while taking into account these
row additions at the same time. I guess I need to be constantly checking
for indices then.

So, which option (not necessarily mentioned here) would you reccomend?

Thanks a lot,

Carles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20151119/45375b81/attachment.html>


More information about the petsc-users mailing list