[petsc-users] Norm_2 calculation
    Matthew Knepley 
    knepley at gmail.com
       
    Fri Jun  5 10:16:06 CDT 2020
    
    
  
On Fri, Jun 5, 2020 at 11:04 AM Fazlul Huq <huq2090 at gmail.com> wrote:
> Hello All,
> I'm trying to calculate the norm_2 error of a solution.
> Here, vector s: Analytical solution
>           vector x: Numerical solution
>
> ierr = VecView(s,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
> ierr = VecView(x,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
>
>  ierr = VecAXPY(x,-1.0,s);CHKERRQ(ierr);
>  ierr = VecNorm(x,NORM_2,&norm);CHKERRQ(ierr);
>  ierr = VecView(x,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
>  ierr = KSPGetIterationNumber(ksp,&its);CHKERRQ(ierr);
>  if (norm > tol) {
>     ierr = PetscPrintf(PETSC_COMM_WORLD,"Second Norm of error %g\n",
> double)norm);CHKERRQ(ierr);
>     ierr = PetscPrintf(PETSC_COMM_WORLD,"Iterations
> %D\n",its);CHKERRQ(ierr);
>   }
>
> Am I calculating the "Norm_2" error correctly or making any mistake?
> Unfortunately, for large sized matrix, say 10^6, I am getting very high
> value of "Norm_2" error.
>
1) I am guessing x comes from a KSPSolve(). It is only as accurate as your
tolerance
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.
  Thanks,
     Matt
> Thank you.
> 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
>
-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200605/d9d5ad5c/attachment.html>
    
    
More information about the petsc-users
mailing list