[petsc-users] Error Norm_2

Smith, Barry F. bsmith at mcs.anl.gov
Sun Mar 3 17:51:41 CST 2019


   Note that your sum is over more and more values (as n gets larger) so unless the individual values are decreasing very rapidly to zero the sum will increase. You need the L2 weighted norm. If your problem is in one dimension, which it appears to be, you need to divide the VecNorm() result by the square root of n

   Barry

   Read up on some book on finite difference methods where they discuss the convergence rates and note how they define the weighted norm.


> On Feb 25, 2019, at 8:37 PM, Fazlul Huq <huq2090 at gmail.com> wrote:
> 
> Hello PETSc Developers,
> 
> Thanks for the response!
> 
> To calculate error, I first calculate the analytical solution and put it inside vector s.
> Then I took difference between analytical solution and numerical solution and put it inside vector x.
> Then I calculate the NORM_2 of x.
> The code is as follows:
> /*
>      Check the error
>   */
>   for (i = 0; i < n; i++)
>     {
>       k1 = (float) (i+1)/(n+1);
>       k2 = -0.5 * k1 * k1 + 5.5 * k1 + 10;
>       ierr = VecSetValues(s, 1, &i, &k2, INSERT_VALUES);CHKERRQ(ierr);
>     }
>   ierr = VecAXPY(x,-1.0,s);CHKERRQ(ierr);
>   ierr = VecNorm(x,NORM_2,&norm);CHKERRQ(ierr);
>   if (norm > tol) {
>     ierr = PetscPrintf(PETSC_COMM_WORLD,"Second Norm of error %g\n",(double)norm);CHKERRQ(ierr);
>   }
> 
> Thanks again.
> Sincerely,
> Huq
> 
> On Mon, Feb 25, 2019 at 5:15 PM Smith, Barry F. <bsmith at mcs.anl.gov> wrote:
> 
>    How are you computing the error norm? 
> 
>    You need to use the L2 norm in the computations, not the l2 norm. 
> 
>    Also you need to make sure the convergence criteria you use for the algebraic system is smaller than the descritzation error 
> 
> 
>    Barry
> 
> 
> > On Feb 25, 2019, at 1:55 PM, Fazlul Huq via petsc-users <petsc-users at mcs.anl.gov> wrote:
> > 
> > Hello PETSc Developers,
> > 
> > I have solved a very simple poisson problem with different matrix sizes (10 to 10^7).
> > But when I have compared error norm_2 for the solution, I got the attached curve.
> > It looks like error norm_2 increases with increasing matrix size. Shouldn't it decrease rather with increasing matrix size?
> > 
> > Thanks.
> > 
> > Sincerely,
> > Huq
> > -- 
> > 
> > Fazlul Huq
> > Graduate Research Assistant
> > Department of Nuclear, Plasma & Radiological Engineering (NPRE)
> > University of Illinois at Urbana-Champaign (UIUC)
> > E-mail: huq2090 at gmail.com
> > <Error norm_2_withoutJacobi.png>
> 
> 
> 
> -- 
> 
> Fazlul Huq
> Graduate Research Assistant
> Department of Nuclear, Plasma & Radiological Engineering (NPRE)
> University of Illinois at Urbana-Champaign (UIUC)
> E-mail: huq2090 at gmail.com



More information about the petsc-users mailing list