<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Thanks for the explanations. Yes they are identical if no preconditioner is applied.
<br>
<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
A follow-up question on this: in the case of a changing matrix at every time step, it's necessary for my code to destroy and re-assemble the matrix every time, so I was wondering whether the matrix-free method, even though with no preconditioner the KSP convergence
 is slower, would have any advantage by saving the matrix assembly step? Or the time saved by that is insignificant compared to the slowdown in KSP with a preconditioned matrix?<br>
<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Thank you,<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
Yuyun<br>
<br>
</div>
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
<span id="OutlookSignature">
<div dir="auto" style="direction: ltr; margin: 0; padding: 0; font-family: sans-serif; font-size: 11pt; color: black; ">
»ρΘ‘ <a href="https://aka.ms/ghei36">Outlook for Android</a></div>
</span><br>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Mark Adams <mfadams@lbl.gov><br>
<b>Sent:</b> Saturday, March 28, 2020 10:29:14 PM<br>
<b>To:</b> Jed Brown <jed@jedbrown.org><br>
<b>Cc:</b> Yuyun Yang <yyang85@stanford.edu>; petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br>
<b>Subject:</b> Re: [petsc-users] Speed of KSPSolve using Matshell vs. regular matrix</font>
<div> </div>
</div>
<div>
<div dir="ltr">I think Yuyun is saying "....<span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:16px">inevitable to encounter significant slowdown compared to using a fully assembled matrix
<b>with a suitable preconditioner</b>? </span>"
<div><br>
</div>
<div>You convergence rate will basically always be better with a preconditioner and unless you are solving the identity (mass matrix) then it will often be significant.</div>
<div><br>
</div>
<div>Jed is responding to comparing un-preconditioned matrix vs matrix-free and you do want to check that they are identical if you think you have an exact Jacobian of a linear problem.</div>
<div><br>
</div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Sat, Mar 28, 2020 at 9:54 AM Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
If the number of iterations is (significantly) different, then you'd<br>
have to debug why your code doesn't implement the same linear operator.<br>
You can use MatComputeOperator or -ksp_view_mat_explicit to help reveal<br>
differences.<br>
<br>
If the number of iterations is the same but your code is slower, then<br>
you'd have to optimize the performance of your code.<br>
<br>
Yuyun Yang <<a href="mailto:yyang85@stanford.edu" target="_blank">yyang85@stanford.edu</a>> writes:<br>
<br>
> Hello team,<br>
><br>
> If I use KSPSolve for Ax=b using Matshell (a user-defined stencil equivalent of A) without preconditioning (since the standard PC would need information of the matrix so cannot apply it to matrix-free method), is it possible, or even inevitable to encounter
 significant slowdown compared to using a fully assembled matrix with a suitable preconditioner? I'm running a small example and it's already taking a long time for Matshell to converge.<br>
><br>
> Thanks for your help,<br>
> Yuyun<br>
</blockquote>
</div>
</div>
</body>
</html>