[petsc-users] Example 23 of ksp problems
Smith, Barry F.
bsmith at mcs.anl.gov
Tue Nov 27 10:57:38 CST 2018
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 <petsc-users at mcs.anl.gov> 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: huq2090 at gmail.com
> <ex23.c>
More information about the petsc-users
mailing list