Discussion:
[petsc-users] SNESSolve_KSPONLY not working for my linear problem
Yaqi Wang
2015-10-14 07:08:14 UTC
Permalink
Hello All,

This is possibly a newbie question but I cannot figure out why. A SNES is
set up in my code but I would like to use it for solving a simple linear
problem.

The sequence of setting up the SNES is as the following:
SNESCreate()
SNESSetFunction()
SNESSetJacobian()
SNESSetFromOptions()

I do not list all calls but just list those I think matters. Note that my
Jacobian is not exact, i.e. it is not consistent with my function.

Then SNESSolve() is called. If I use -snes_type newtonls and
-snes_mf_operator, SNES can solve the linear problem properly, i.e. the
residual norm dropped bellow the tolerance I specified. I know I donot have
to by playing with tolerances, but I tried -snes_type ksponly. I saw my
residual function is only called at the beginning and the end of solve.
Most likely KSP is trying to solve the linear problem with the Jacobian I
specified, which is not exact. I cannot make the solution converge probably
because of this.

My question is why KSPONLY is not using my function for evaluating (b-Ax)
at each linear iteration? I am using the default KSP type, which I guess
should be GMRES. I do not think it matters anyway.
Did I do something wrongly or I had some misunderstanding?

Many thanks,
Yaqi
Yaqi Wang
2015-10-14 07:18:06 UTC
Permalink
While reading my post again, I realized I did not have -snes_mf or
-snes_mf_operator set with -ksp_only. This possibly explains the behavior I
observed. I was not thinking this combination. I will confirm this tomorrow.

Thanks,
Yaqi
Post by Yaqi Wang
Hello All,
This is possibly a newbie question but I cannot figure out why. A SNES is
set up in my code but I would like to use it for solving a simple linear
problem.
SNESCreate()
SNESSetFunction()
SNESSetJacobian()
SNESSetFromOptions()
I do not list all calls but just list those I think matters. Note that my
Jacobian is not exact, i.e. it is not consistent with my function.
Then SNESSolve() is called. If I use -snes_type newtonls and
-snes_mf_operator, SNES can solve the linear problem properly, i.e. the
residual norm dropped bellow the tolerance I specified. I know I donot have
to by playing with tolerances, but I tried -snes_type ksponly. I saw my
residual function is only called at the beginning and the end of solve.
Most likely KSP is trying to solve the linear problem with the Jacobian I
specified, which is not exact. I cannot make the solution converge probably
because of this.
My question is why KSPONLY is not using my function for evaluating (b-Ax)
at each linear iteration? I am using the default KSP type, which I guess
should be GMRES. I do not think it matters anyway.
Did I do something wrongly or I had some misunderstanding?
Many thanks,
Yaqi
Yaqi Wang
2015-10-14 15:23:35 UTC
Permalink
Sorry for my dumb question. I confirmed that I need to set either -snes_mf
or -snes_mf_operator. Thanks.
Post by Yaqi Wang
While reading my post again, I realized I did not have -snes_mf or
-snes_mf_operator set with -ksp_only. This possibly explains the behavior I
observed. I was not thinking this combination. I will confirm this tomorrow.
Thanks,
Yaqi
Post by Yaqi Wang
Hello All,
This is possibly a newbie question but I cannot figure out why. A SNES is
set up in my code but I would like to use it for solving a simple linear
problem.
SNESCreate()
SNESSetFunction()
SNESSetJacobian()
SNESSetFromOptions()
I do not list all calls but just list those I think matters. Note that my
Jacobian is not exact, i.e. it is not consistent with my function.
Then SNESSolve() is called. If I use -snes_type newtonls and
-snes_mf_operator, SNES can solve the linear problem properly, i.e. the
residual norm dropped bellow the tolerance I specified. I know I donot have
to by playing with tolerances, but I tried -snes_type ksponly. I saw my
residual function is only called at the beginning and the end of solve.
Most likely KSP is trying to solve the linear problem with the Jacobian I
specified, which is not exact. I cannot make the solution converge probably
because of this.
My question is why KSPONLY is not using my function for evaluating (b-Ax)
at each linear iteration? I am using the default KSP type, which I guess
should be GMRES. I do not think it matters anyway.
Did I do something wrongly or I had some misunderstanding?
Many thanks,
Yaqi
Loading...