[petsc-users] Error Norm_2

Fazlul Huq huq2090 at gmail.com
Mon Feb 25 20:37:03 CST 2019


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190225/1316421c/attachment.html>


More information about the petsc-users mailing list