<div dir="ltr"><div dir="ltr">On Fri, Jun 5, 2020 at 11:04 AM Fazlul Huq <<a href="mailto:huq2090@gmail.com">huq2090@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:"comic sans ms",sans-serif">Hello All,</div><div style="font-family:"comic sans ms",sans-serif">I'm trying to calculate the norm_2 error of a solution. </div><div style="font-family:"comic sans ms",sans-serif">Here, vector s: Analytical solution</div><div style="font-family:"comic sans ms",sans-serif"> vector x: Numerical solution</div><div style="font-family:"comic sans ms",sans-serif"><br></div>ierr = VecView(s,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);<br>ierr = VecView(x,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);<br><br> ierr = VecAXPY(x,-1.0,s);CHKERRQ(ierr);<br> ierr = VecNorm(x,NORM_2,&norm);CHKERRQ(ierr);<br> <span class="gmail_default" style="font-family:"comic sans ms",sans-serif">i</span>err = VecView(x,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);<br> ierr = KSPGetIterationNumber(ksp,&its);CHKERRQ(ierr);<br> if (norm > tol) {<br> ierr = PetscPrintf(PETSC_COMM_WORLD,"Second Norm of error %g\n",<span class="gmail_default" style="font-family:"comic sans ms",sans-serif"> </span>double)norm);CHKERRQ(ierr);<br> ierr = PetscPrintf(PETSC_COMM_WORLD,"Iterations %D\n",its);CHKERRQ(ierr);<br><div style="font-family:"comic sans ms",sans-serif"><span style="font-family:Arial,Helvetica,sans-serif"> }</span><br></div><div><br></div><div><div style="font-family:"comic sans ms",sans-serif">Am I calculating the "Norm_2" error correctly or making any mistake?</div><div style="font-family:"comic sans ms",sans-serif">Unfortunately, for large sized matrix, say 10^6, I am getting very high value of "Norm_2" error.</div></div></div></blockquote><div><br></div><div>1) I am guessing x comes from a KSPSolve(). It is only as accurate as your tolerance</div><div><br></div><div>2) This is the l_2 norm, not the L_2 norm, so if you are using a continuum method like FEM, this is likely wrong.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div style="font-family:"comic sans ms",sans-serif">Thank you.</div><div style="font-family:"comic sans ms",sans-serif">Sincerely,</div><div style="font-family:"comic sans ms",sans-serif">Huq</div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><br><div><font face="comic sans ms, sans-serif">Fazlul Huq</font></div><div><font face="comic sans ms, sans-serif">Graduate Research Assistant</font></div><div><font face="comic sans ms, sans-serif">Department of Nuclear, Plasma & Radiological Engineering (NPRE)</font></div><div><font face="comic sans ms, sans-serif">University of Illinois at Urbana-Champaign (UIUC)</font></div><div><font face="comic sans ms, sans-serif">E-mail: <a href="mailto:huq2090@gmail.com" target="_blank">huq2090@gmail.com</a></font></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="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>