[petsc-users] malloc error

Jorti, Zakariae zjorti at lanl.gov
Mon Aug 16 18:56:36 CDT 2021


Hello,


I am using TSSolve to solve a linear problem.

In the FormIJacobian function that I provide to TSSetIJacobian, I first set the coefficients of both J and Jpre matrices the same way (J and Jpre matrices are equal in the first step). Then I call MatAXPY to prepare Jpre (Jpre := Jpre - another_matrix. So, Jpre and J are not equal anymore).


But I get the error once FormIJacobian is called the second time inside TSSolve:

"[0]PETSC ERROR: New nonzero at (5,1) caused a malloc

Use MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE) to turn off this check".


It looks like MatAXPY changes the allocation of Jpre, which the second FormIJacobian does not like unless Jpre is destroyed first.


Do you have any suggestions to fix this malloc issue?

Thanks.


Best regards,


Zakariae
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20210816/3c1efd2e/attachment.html>


More information about the petsc-users mailing list