[petsc-users] [EXTERNAL] Re: malloc error

Jorti, Zakariae zjorti at lanl.gov
Tue Aug 17 15:51:16 CDT 2021


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 <jed at jedbrown.org>
Sent: Monday, August 16, 2021 10:40:20 PM
To: Jorti, Zakariae; petsc-users at mcs.anl.gov
Cc: Tang, Xianzhu
Subject: [EXTERNAL] Re: [petsc-users] malloc error

"Jorti, Zakariae via petsc-users" <petsc-users at mcs.anl.gov> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20210817/2ec2902b/attachment.html>


More information about the petsc-users mailing list