Hello,

Thank you for your reply.

The problem is now fixed.

The issue was actually with MatZeroRowsIS that was called after MatAXPY to 
cancel the boundary rows of Jpre.

It seems to change the non-zero pattern of Jpre.

I added MatSetOption(Jpre,MAT_KEEP_NONZERO_PATTERN,PETSC_TRUE); to make sure it 
does not happen.

Thanks.


Zakariae

________________________________
From: Jed Brown <[email protected]>
Sent: Monday, August 16, 2021 10:40:20 PM
To: Jorti, Zakariae; [email protected]
Cc: Tang, Xianzhu
Subject: [EXTERNAL] Re: [petsc-users] malloc error

"Jorti, Zakariae via petsc-users" <[email protected]> writes:

> 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).

How do you call MatAXPY? What MatStructure arg are you passing? What is the 
sparsity pattern of another_matrix relative to Jpre?

>
> 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