<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:10pt;color:#000000;font-family:Helvetica;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">That all makes sense. Thanks.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Is it okay to MatCreate() and MatDestroy() in each time step or am I just defeating the purpose of preserving the KSP?</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Is there a way to tell if the KSP is reusing the factorization (e.g., with -ksp_view)?</p>
</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> Smith, Barry F. <bsmith@mcs.anl.gov><br>
<b>Sent:</b> Tuesday, April 17, 2018 5:13:10 PM<br>
<b>To:</b> Young, Matthew, Adam<br>
<b>Cc:</b> Matthew Knepley; petsc-users@mcs.anl.gov<br>
<b>Subject:</b> Re: [petsc-users] Reuse KSP</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText"><br>
If the matrix has a null space then, in general, direct LU factorizations should fail. If they don't fail they can produce an incorrect answer
<br>
<br>
If your matrix has a null space then you should not remove the [Set nullspace of A with MatSetNullSpace]
<br>
<br>
Barry<br>
<br>
> On Apr 17, 2018, at 7:48 AM, Young, Matthew, Adam <may@bu.edu> wrote:<br>
> <br>
> <br>
> <br>
> <br>
> From: Matthew Knepley <knepley@gmail.com><br>
> Sent: Tuesday, April 17, 2018 8:38 AM<br>
> To: Young, Matthew, Adam<br>
> Cc: petsc-users@mcs.anl.gov<br>
> Subject: Re: [petsc-users] Reuse KSP<br>
> <br>
> On Tue, Apr 17, 2018 at 8:33 AM, Young, Matthew, Adam <may@bu.edu> wrote:<br>
> My code (C/C++) uses PETSc to solve a linear system at each iteration in a time-stepping scheme. The PETSc routines are separated out because the scheme that uses them is optional in the larger code.
<br>
> <br>
> At each time step, the PETSc scheme calls a routine that includes:<br>
> <br>
> {<br>
> Mat A;<br>
> Vec x,b;<br>
> KSP ksp;<br>
> <br>
> [Set up A,x,b]<br>
> <br>
> KSPCreate(PETSC_COMM_WORLD,&ksp);<br>
> <br>
> [Build A and b from simulation data]<br>
> <br>
> [Set nullspace of A with MatSetNullSpace]<br>
> <br>
> KSPSetOperators(ksp,A,A);<br>
> KSPSetFromOptions(ksp);<br>
> KSPSolve(ksp,b,x);<br>
> <br>
> [Write x into an instance of our array class, perform checks, etc.]<br>
> <br>
> KSPDestroy(&ksp);<br>
> <br>
> return(0);<br>
> }<br>
> <br>
> My question is: If I want to use superLU_DIST with the option -mat_superlu_dist_fact SamePattern (or SamePattern_SameRowPerm), should I move KSPCreate/Destroy outside of the time-step loop in the larger code?<br>
> <br>
> 1) Yes<br>
> <br>
> 2) How are you using LU when A has a nullspace?<br>
> My bad - that code is in there from when I was trying iterative solvers. Should I remove it if I use LU or will PETSc just ignore it?<br>
> <br>
> 3) You can also move out SetFromOptions().<br>
> Thanks for the advice. So, that means I'll build A and b from simulation data, SetOperators(), Solve(), and carry on?<br>
> <br>
> Matt<br>
> <br>
> Thanks.<br>
> ----------------------------<br>
> Matthew Young<br>
> PhD Candidate<br>
> Astronomy Department<br>
> Boston University<br>
> <br>
> <br>
> <br>
> <br>
> <br>
> -- <br>
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
> -- Norbert Wiener<br>
> <br>
> <a href="https://www.cse.buffalo.edu/~knepley/">https://www.cse.buffalo.edu/~knepley/</a><br>
<br>
</div>
</span></font></div>
</body>
</html>