This is an ad hoc way of checking that the error from the linear solve is 
"reasonable".  Note that PETSC_MACHINE_EPSILON 
depends on the precision of the floating point used so for more precise 
floating point (in going from half precision to quad precision) we expect the 
error 
to be smaller (depending on the machine epsilon). The 1000 is an arbitrary 
number, it could be 100 or 10,000 or anything in between could be reasonable. 
Note that using a 1.0 is probably not reasonable because it is not reasonable 
to expect the error to be only a machine epsilon away from the "exact" answer.

    Barry

If you are not familiar with the term machine epsilon you can google it.



> On Nov 26, 2018, at 9:30 PM, Fazlul Huq via petsc-users 
> <[email protected]> wrote:
> 
> Hello PETSc developers,
> 
> I went through the ex23.c of ksp section attached herewith but I don't 
> understand the following part: 
> ***********************************************
> tol=1000.*PETSC_MACHINE_EPSILON
> ************************************************
> and,
> ************************************************
> ierr = VecAXPY(x,-1.0,u);CHKERRQ(ierr);
>  ierr = VecNorm(x,NORM_2,&norm);CHKERRQ(ierr);
>  ierr = KSPGetIterationNumber(ksp,&its);CHKERRQ(ierr);
>  if (norm > tol) {
>  ierr = PetscPrintf(PETSC_COMM_WORLD,"Norm of error %g, Iterations %D\n",  
> (double)norm,its);CHKERRQ(ierr);
>   }
> ************************************************
> I don't understand what is "tol" here and "*PETSC_MACHINE_EPSILON"?
> The if condition is also not clear to me.
> 
> Thanks.
> Sincerely,
> Huq
> -- 
> 
> Fazlul Huq
> Graduate Research Assistant
> Department of Nuclear, Plasma & Radiological Engineering (NPRE)
> University of Illinois at Urbana-Champaign (UIUC)
> E-mail: [email protected]
> <ex23.c>

Reply via email to