<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:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">If it is indeed 'zero pivot' issue, you could add an extra option to your simulation '<span>-pc_factor_shift_type NONZERO -pc_factor_shift_amount 1.0e-10', and see if it helps.</span></p>
<p style="margin-top:0;margin-bottom:0"><span><br>
</span></p>
<p style="margin-top:0;margin-bottom:0"><span><a href="http://www.mcs.anl.gov/petsc/documentation/faq.html#zeropivot" class="OWAAutoLink" id="LPlnk497761" previewremoved="true">http://www.mcs.anl.gov/petsc/documentation/faq.html#zeropivot</a></p>
<div id="LPBorder_GT_15360729157660.44128207229090854" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_15360729157630.9630878509267427" role="presentation" cellspacing="0" style="width: 90%; background-color: rgb(255, 255, 255); position: relative; overflow: auto; padding-top: 20px; padding-bottom: 20px; margin-top: 20px; border-top: 1px dotted rgb(200, 200, 200); border-bottom: 1px dotted rgb(200, 200, 200);">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td id="TextCell_15360729157640.8752040438754687" colspan="2" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;">
<div id="LPRemovePreviewContainer_15360729157640.8943356300812981"></div>
<div id="LPTitle_15360729157640.25251283954152304" style="top: 0px; color: rgb(0, 120, 215); font-weight: 400; font-size: 21px; font-family: wf_segoe-ui_light, "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; line-height: 21px;">
<a id="LPUrlAnchor_15360729157650.9721473934057328" href="http://www.mcs.anl.gov/petsc/documentation/faq.html#zeropivot" target="_blank" style="text-decoration: none;">PETSc: Documentation: FAQ - mcs.anl.gov</a></div>
<div id="LPMetadata_15360729157650.047373272348318674" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: 400; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 14px;">
www.mcs.anl.gov</div>
<div id="LPDescription_15360729157650.2808218998792771" style="display: block; color: rgb(102, 102, 102); font-weight: 400; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 20px; max-height: 100px; overflow: hidden;">
Execution PETSc executables are SO big and take SO long to link. We find this annoying as well. On most machines PETSc can use shared libraries, so executables should be much smaller, run ./configure with the additional option --with-shared-libraries (this
is the default).</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
</span>
<p></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> Rahul Samala <srahul_05@yahoo.co.in><br>
<b>Sent:</b> Thursday, August 30, 2018 11:26:37 PM<br>
<b>To:</b> Fande Kong; Smith, Barry F.; Ling Zou<br>
<b>Cc:</b> PETSc users list<br>
<b>Subject:</b> Re: [petsc-users] Problem with SNES convergence</font>
<div> </div>
</div>
<meta content="text/html; charset=utf-8">
<div>
<div style="font-family:garamond,new york,times,serif; font-size:13px">
<div>Thank you Barry for the suggestion, I will definitely look in to TS implementation.<br>
</div>
<div>I have implemented my own version of reduced time step size using the <span><span style="font-family:Consolas,Courier,monospace">SNESGetConvergedReason</span></span>, but encountered the same problem after another 30 time-steps. So, I am experimenting
with different set of initial conditions.<br>
</div>
<div>Ling, thank you for the code, I will see if my understanding is different from yours.</div>
<div><br>
</div>
<div>--</div>
<div>Rahul.<br>
</div>
<div><br>
</div>
<div id="x_yahoo_quoted_6336599421" class="x_yahoo_quoted">
<div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size:13px; color:#26282a">
<div>On Thursday, August 30, 2018, 11:25:35 PM GMT+5:30, Smith, Barry F. <bsmith@mcs.anl.gov> wrote:
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div dir="ltr"><br clear="none">
<br clear="none">
> On Aug 30, 2018, at 12:49 PM, Fande Kong <<a shape="rect" href="mailto:fdkong.jd@gmail.com">fdkong.jd@gmail.com</a>> wrote:<br clear="none">
> <br clear="none">
> Hi Barry,<br clear="none">
> <br clear="none">
> I haven't had time to look into TS so far. But it is definitely interesting. One simple question would like this: If I have a simple loop for time steppers, and each step SNES is called. How hard to convert my code to use TS?
<br clear="none">
<br clear="none">
You would need to look at the examples in ts/examples/tutorials but essentially you need to provide a slightly different version of FormFunction() and FormJacobian() and call TSSolve() etc instead of having your own loop.
<div class="x_yqt5895941878" id="x_yqtfd76634"><br clear="none">
<br clear="none">
Barry<br clear="none">
<br clear="none">
> <br clear="none">
> Any suggestion? Where should I start from?<br clear="none">
> <br clear="none">
> <br clear="none">
> Fande,<br clear="none">
> <br clear="none">
> On Thu, Aug 30, 2018 at 11:29 AM Smith, Barry F. <<a shape="rect" href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br clear="none">
> <br clear="none">
> Note also that the PETSc TS component has a large variety of timesteppers with automatic adaptivity which adjust the time-step for accuracy and convergence. Depending on the exact needs of your time-stepper it might be easier in the long run to use PETSc's
time-steppers rather than write your own.<br clear="none">
> <br clear="none">
> Barry<br clear="none">
> <br clear="none">
> <br clear="none">
> > On Aug 30, 2018, at 10:46 AM, Ling Zou <<a shape="rect" href="mailto:Ling.Zou@inl.gov">Ling.Zou@inl.gov</a>> wrote:<br clear="none">
> > <br clear="none">
> > Rahul, please see the logic I used to reduce time step size.<br clear="none">
> > Hope this helps you.<br clear="none">
> > <br clear="none">
> > Ling<br clear="none">
> > <br clear="none">
> > for (timestep = 1; timestep <= N; timestep++) // loop over time steps<br clear="none">
> > {<br clear="none">
> > // before trying to solve a time step, 1) it is still not successful; 2) we are not giving up; 3) haven't failed yet<br clear="none">
> > bool give_up = false; bool success = false; bool experienced_fail_this_time_step = false;<br clear="none">
> > // save solutions and old solutions into u_copy and u_old_copy, in case a time step fails and we restart from this saved solutions<br clear="none">
> > VecCopy(u, u_copy); VecCopy(u_old, u_old_copy);<br clear="none">
> > <br clear="none">
> > while ((!give_up) && (!success)) // as long as not successful and not giving up, we solve again with smaller time step<br clear="none">
> > {<br clear="none">
> > if (time_step_size < dt_min) { give_up = true; break; } // ok, bad luck, give up due to time step size smaller than a preset value<br clear="none">
> > if (experienced_fail_this_time_step) { // get the vectors from backups if this is a re-try, i.e., already failed with a larger time step<br clear="none">
> > VecCopy(u_old_copy, u); VecCopy(u_old_copy, u_old);<br clear="none">
> > }<br clear="none">
> > <br clear="none">
> > try {<br clear="none">
> > SNESSolve(snes, NULL, u);<br clear="none">
> > SNESGetConvergedReason(snes, &snes_converged_reason);<br clear="none">
> > <br clear="none">
> > if (snes_converged_reason > 0) success = true; // yes, snes converged<br clear="none">
> > else { // no, snes did not converge<br clear="none">
> > cutTimeStepSize(); // e.g., dt / 2<br clear="none">
> > experienced_fail_this_time_step = true;<br clear="none">
> > }<br clear="none">
> > }<br clear="none">
> > catch (int err) { // in case your own pieces of code throws an exception<br clear="none">
> > std::cout << "An exception occurred." << std::endl;<br clear="none">
> > success = false;<br clear="none">
> > cutTimeStepSize(); // e.g., dt / 2<br clear="none">
> > experienced_fail_this_time_step = true;<br clear="none">
> > }<br clear="none">
> > }<br clear="none">
> > <br clear="none">
> > if (success) {<br clear="none">
> > // output, print, whatever<br clear="none">
> > // duplicate current solution to old solution in preparing next time step<br clear="none">
> > VecCopy(u, u_old);<br clear="none">
> > // you can increase time step size here, e.g. * 2<br clear="none">
> > increaseTimeStepSize();<br clear="none">
> > }<br clear="none">
> > <br clear="none">
> > if (give_up) {<br clear="none">
> > simulationFailed = true;<br clear="none">
> > std::cerr << "Simulation failed.\n";<br clear="none">
> > //exit(1);// dont exit(1) now, just break the for-loop, let PETSc clean its workspace.<br clear="none">
> > break;<br clear="none">
> > }<br clear="none">
> > }<br clear="none">
> > <br clear="none">
> > From: Rahul Samala <<a shape="rect" href="mailto:srahul_05@yahoo.co.in">srahul_05@yahoo.co.in</a>><br clear="none">
> > Sent: Wednesday, August 29, 2018 10:37:30 PM<br clear="none">
> > To: Ling Zou; Smith, Barry F.<br clear="none">
> > Cc: PETSc Users List<br clear="none">
> > Subject: Re: [petsc-users] Problem with SNES convergence<br clear="none">
> > <br clear="none">
> > Thank you Ling, I would definitely like to look at your code for reducing timestep size.<br clear="none">
> > Thank you Barry for your inputs.<br clear="none">
> > <br clear="none">
> > --<br clear="none">
> > Rahul.<br clear="none">
> > <br clear="none">
> > On Wednesday, August 29, 2018, 9:02:00 PM GMT+5:30, Smith, Barry F. <<a shape="rect" href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br clear="none">
> > <br clear="none">
> > <br clear="none">
> > <br clear="none">
> > Current time (before start of timestep) 52.5048, iter=5380 Timestep=864.000000
<br clear="none">
> > 0 SNES Function norm 1.650467412595e+05 <br clear="none">
> > 0 KSP preconditioned resid norm 3.979123221160e+03 true resid norm 1.650467412595e+05 ||r(i)||/||b|| 1.000000000000e+00<br clear="none">
> > 1 KSP preconditioned resid norm 9.178246525982e-11 true resid norm 7.006473307032e-09 ||r(i)||/||b|| 4.245144892632e-14<br clear="none">
> > Linear solve converged due to CONVERGED_RTOL iterations 1<br clear="none">
> > 1 SNES Function norm 6.722712947273e+02 <br clear="none">
> > Linear solve did not converge due to DIVERGED_NANORINF iterations 0<br clear="none">
> > Nonlinear solve did not converge due to DIVERGED_LINEAR_SOLVE iterations 1<br clear="none">
> > <br clear="none">
> > This usually is an indicator that the LU (ILU) factorization has hit a zero pivot (hence the linear solve has a divide by zero so gives the DIVERGED_NANORINF flag).
<br clear="none">
> > <br clear="none">
> > You can/should call SNESGetConvergedReason() immediately after each SNESSolve(), if the result is negative that means something has failed in the nonlinear solve and you can try cutting the time-step and trying again.<br clear="none">
> > <br clear="none">
> > Good luck,<br clear="none">
> > <br clear="none">
> > Barry<br clear="none">
> > <br clear="none">
> > <br clear="none">
> > > On Aug 29, 2018, at 10:11 AM, Ling Zou <<a shape="rect" href="mailto:Ling.Zou@inl.gov">Ling.Zou@inl.gov</a>> wrote:<br clear="none">
> > > <br clear="none">
> > > 1) My experience is that this kind of bug or sudden death (everything is fine till suddenly something is broken) is very difficult to debug/fix. I looked at your txt files and could not give any quick comments. Maybe PETSc developers have better idea
on this.<br clear="none">
> > > 2) I do have successful experience on reducing time step size when PETSc fails solving or my own piece of code throws an exception. If you are interested, I can share them.<br clear="none">
> > > <br clear="none">
> > > -Ling<br clear="none">
> > > From: petsc-users <<a shape="rect" href="mailto:petsc-users-bounces@mcs.anl.gov">petsc-users-bounces@mcs.anl.gov</a>> on behalf of Rahul Samala <<a shape="rect" href="mailto:srahul_05@yahoo.co.in">srahul_05@yahoo.co.in</a>><br clear="none">
> > > Sent: Wednesday, August 29, 2018 8:36:58 AM<br clear="none">
> > > To: PETSc Users List<br clear="none">
> > > Subject: [petsc-users] Problem with SNES convergence<br clear="none">
> > > <br clear="none">
> > > Hello PetSc users,<br clear="none">
> > > <br clear="none">
> > > 1) I have problem with SNES convergence. I call SNESSolve in a time loop and use the inbuilt Jacobian feature. The code works fine for about 5380 time steps after which it breaks down. The solution till that point looks fine. I have used newtonls of
type l2. (newtontr and others aren't working). Since I have used inbuilt Jacobian feature and the code worked for about 5000 time steps I don't understand the reason for failure, is it an incorrect function evaluation? Attached are the outputs with -pc_type
lu and ilu along with -snes_linesearch_type l2 -snes_converged_reason -snes_monitor -snes_view -ksp_converged_reason -ksp_monitor_true_residual<br clear="none">
> > > <br clear="none">
> > > 2) How to get hold of failure signal, like Nonlinear solve DIVERGED_MAX_IT or DIVERGED_LINEAR_SOLVE so that whenever it occurs I can use a reduced time step and see if the code converges.<br clear="none">
> > > <br clear="none">
> > > Thank you,<br clear="none">
> > > Rahul.<br clear="none">
> > > <br clear="none">
> > > output_ilu.txt<br clear="none">
> > > <br clear="none">
> > > <br clear="none">
> > > output_ilu.txt<br clear="none">
> > > <br clear="none">
> > > <br clear="none">
> > > <br clear="none">
> > > output_lu.txt<br clear="none">
> > > <br clear="none">
> > > <br clear="none">
> > > output_lu.txt<br clear="none">
> <br clear="none">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>