<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Oct 8, 2018 at 6:58 PM Weizhuo Wang <<a href="mailto:weizhuo2@illinois.edu">weizhuo2@illinois.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">The first plot is the norm with the flag -pc_type lu with respect to number of grids in one axis (n), and the second plot is the norm without the flag -pc_type lu. <div><br></div><div>Specifically, the norm is calculated by</div><div><br></div><div>       norm = norm_2(numerical - analytic)/(n*n)</div></div></div></div></blockquote><div><br></div><div>I do not believe you are calculating this correctly. There is no way your discretisation error is that low.</div><div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div dir="ltr">On Mon, Oct 8, 2018 at 5:47 PM Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Oct 8, 2018 at 6:13 PM Weizhuo Wang <<a href="mailto:weizhuo2@illinois.edu" target="_blank">weizhuo2@illinois.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">Sorry I was caught up with midterms for the last few days. I tried the lu decomposition today and the 2-norm is pretty stable at ~ 10^-15, which is expected for double precision. Since the discretization error is so small, it would be reasonable to assume the rest is majority the algebraic error. </div></div></blockquote><div><br></div><div>What are you plotting? It looks like only the algebraic error or residual. There is absolutely no way your discretization error is 1e-14.</div><div><br></div><div>  Thanks,</div><div><br></div><div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">Then looking at the result without the -pc_type lu flag(second graph), the error is asymptoting to a constant several magnitudes larger than the tolerance set for the solver. (atol=1e-12, rtol=1e-9) Is this the expected behavior? Shouldn't it decrease with finer grid?<br><div><img src="cid:ii_jn0ugeme1" alt="LU.png" width="562" height="417"><br></div><div><img src="cid:ii_jn0ugeqq2" alt="Total.png" width="562" height="431"><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 2, 2018 at 6:52 PM Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Oct 2, 2018 at 5:26 PM Weizhuo Wang <<a href="mailto:weizhuo2@illinois.edu" target="_blank">weizhuo2@illinois.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">I didn't specify a tolerance, it was using the default tolerance. Doesn't the asymptoting norm implies finer grid won't help to get finer solution?</div></div></blockquote><div><br></div><div>There are two things going on in your test, discretization error controlled by the grid, and algebraic error controlled by the solver. This makes it difficult to isolate what is happening. However, it seems clear that your plot is looking at algebraic error. You can confirm this by using</div><div><br></div><div>  -pc_type lu</div><div><br></div><div>for the solve. Then all you have is discretization error.</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div dir="ltr">Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 2, 2018 at 5:04 PM Weizhuo Wang <<a href="mailto:weizhuo2@illinois.edu" target="_blank">weizhuo2@illinois.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Yes I was using one norm in my Helmholtz code, the example code used 2 norm. But now I am using 2 norm in both code.</div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr">  /*</div><div dir="ltr">     Check the error</div><div dir="ltr">  */</div><div dir="ltr">  ierr = VecAXPY(x,-1.0,u); CHKERRQ(ierr);</div></div><div dir="ltr"><div dir="ltr">  ierr = VecNorm(x,NORM_1,&norm); CHKERRQ(ierr);</div><div dir="ltr">  ierr = KSPGetIterationNumber(ksp,&its); CHKERRQ(ierr);</div><div dir="ltr">  ierr = PetscPrintf(PETSC_COMM_WORLD,"Norm of error %g iterations %D\n",(double)norm/(m*n),its); CHKERRQ(ierr);</div></div><div dir="ltr"><br></div><div dir="ltr"> I made a plot to show the increase:</div></div></div></div></div></div></blockquote><div><br></div><div><br></div><div>FYI, this is asymptoting to a constant.  What solver tolerance are you using? </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div><div dir="ltr"><div><img src="cid:ii_jms7k5ct0" alt="Norm comparison.png" width="562" height="225"><br></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 2, 2018 at 2:24 PM Weizhuo Wang <<a href="mailto:weizhuo2@illinois.edu" target="_blank">weizhuo2@illinois.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The example code and makefile are attached below. The whole thing started as I tried to build a Helmholtz solver, and the mean error (calculated by: sum( | numerical_sol - analytical_sol | / analytical_sol ) ) </div></blockquote><div><br></div><div>This is a one norm. If you use max (instead of sum) then you don't need to scale. You do have to be careful about dividing by (near) zero. </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">increases as I use finer and finer grids. </div></blockquote><div><br></div><div>What was the rate of increase?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Then I looked at the example 12 (Laplacian solver) which is similar to what I did to see if I have missed something. The example is using 2_norm. I have made some minor modifications (3 places) on the code, you can search 'Modified' in the code to see them. <div><br></div><div>If this helps: I configured the PETSc to use real and double precision. Changed the name of the example code from ex12.c to ex12c.c<br><div><br></div><div>Thanks for all your reply! </div><div><br></div><div>Weizhuo</div></div><br><div class="gmail_quote"><div dir="ltr"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>>   </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br>
   Please send your version of the example that computes the mean norm of the grid; I suspect we are talking apples and oranges<br>
<br>
   Barry<br>
<br>
<br>
<br>
> On Oct 1, 2018, at 7:51 PM, Weizhuo Wang <<a href="mailto:weizhuo2@illinois.edu" target="_blank">weizhuo2@illinois.edu</a>> wrote:<br>
> <br>
> I also tried to divide the norm by m*n , which is the number of grids, the trend of norm still increases.<br>
> <br>
> Thanks!<br>
> <br>
> Weizhuo<br>
> <br>
> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>><br>
> On Mon, Oct 1, 2018 at 6:31 PM Weizhuo Wang <<a href="mailto:weizhuo2@illinois.edu" target="_blank">weizhuo2@illinois.edu</a>> wrote:<br>
> Hi!<br>
> <br>
> I'm recently trying out the example code provided with the KSP solver (ex12.c). I noticed that the mean norm of the grid increases as I use finer meshes. For example, the mean norm is 5.72e-8 at m=10 n=10. However at m=100, n=100, mean norm increases to 9.55e-6. This seems counter intuitive, since most of the time error should decreases when using finer grid. Am I doing this wrong?<br>
> <br>
> The norm is misleading in that it is the l_2 norm, meaning just the sqrt of the sum of the squares of<br>
> the vector entries. It should be scaled by the volume element to approximate a scale-independent<br>
> norm (like the L_2 norm).<br>
> <br>
>   Thanks,<br>
> <br>
>      Matt<br>
>  <br>
> Thanks! <br>
> -- <br>
> Wang Weizhuo<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://urldefense.proofpoint.com/v2/url?u=https-3A__www.cse.buffalo.edu_-7Eknepley_&d=DwMFaQ&c=OCIEmEwdEq_aNlsP4fF3gFqSN-E3mlr2t9JcDdfOZag&r=hsLktHsuxNfF6zyuWGCN8x-6ghPYxhx4cV62Hya47oo&m=KjmDEsZ6w8LEry7nlv3Bw7-pczqWbKGueFU59VoIWZg&s=tEv9-AHhL2CIlmmVos0gFa5PAY9oMG3aTQlnfi62ivA&e=" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
> <br>
> <br>
> -- <br>
> Wang Weizhuo<br>
<br>
</blockquote></div></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-654140004411608327m_-992652518112556458m_2671194209988417879m_-4857170720746257107m_2361083245395568463m_7363555038824281564m_8222594503841844358m_5680273830266429210m_-548067399957601370m_2305654470436472434gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Wang Weizhuo</div></div>
</blockquote></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-654140004411608327m_-992652518112556458m_2671194209988417879m_-4857170720746257107m_2361083245395568463m_7363555038824281564m_8222594503841844358gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Wang Weizhuo</div></div>
</blockquote></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-654140004411608327m_-992652518112556458m_2671194209988417879m_-4857170720746257107m_2361083245395568463gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Wang Weizhuo</div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-654140004411608327m_-992652518112556458m_2671194209988417879m_-4857170720746257107gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>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</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-654140004411608327m_-992652518112556458m_2671194209988417879gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Wang Weizhuo</div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-654140004411608327m_-992652518112556458gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>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</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-654140004411608327gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Wang Weizhuo</div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>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</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>