<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p>Hello,</p>
<p><br>
</p>
<p>Thank you for your reply.</p>
<p>The problem is now fixed. </p>
<p>The issue was actually with MatZeroRowsIS that was called after MatAXPY to cancel the boundary rows of Jpre.</p>
<p>It seems to change the non-zero pattern of Jpre. </p>
<p>I added MatSetOption(Jpre,MAT_KEEP_NONZERO_PATTERN,PETSC_TRUE); to make sure it does not happen.</p>
<p>Thanks.</p>
<p><br>
</p>
<p>Zakariae</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Jed Brown <jed@jedbrown.org><br>
<b>Sent:</b> Monday, August 16, 2021 10:40:20 PM<br>
<b>To:</b> Jorti, Zakariae; petsc-users@mcs.anl.gov<br>
<b>Cc:</b> Tang, Xianzhu<br>
<b>Subject:</b> [EXTERNAL] Re: [petsc-users] malloc error</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">"Jorti, Zakariae via petsc-users" <petsc-users@mcs.anl.gov> writes:<br>
<br>
> Hello,<br>
><br>
><br>
> I am using TSSolve to solve a linear problem.<br>
><br>
> 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).<br>
<br>
How do you call MatAXPY? What MatStructure arg are you passing? What is the sparsity pattern of another_matrix relative to Jpre?<br>
<br>
><br>
> But I get the error once FormIJacobian is called the second time inside TSSolve:<br>
><br>
> "[0]PETSC ERROR: New nonzero at (5,1) caused a malloc<br>
><br>
> Use MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE) to turn off this check".<br>
><br>
><br>
> It looks like MatAXPY changes the allocation of Jpre, which the second FormIJacobian does not like unless Jpre is destroyed first.<br>
><br>
><br>
> Do you have any suggestions to fix this malloc issue?<br>
><br>
> Thanks.<br>
><br>
><br>
> Best regards,<br>
><br>
><br>
> Zakariae<br>
</div>
</span></font>
</body>
</html>