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

Reply via email to