I am trying to implement a Newton method with the stopping criterium as the l2 norm of the residual from the non-linear form. However, when the norm of the residual is computed in each iteration
a.Apply(gfu.vec, res)
print("\t||res||_l2 = {:}".format(sqrt(InnerProduct(res,res))))
this does not converge to zero, even though the method converges (in the dual norm) and the update disappears. I have attached a MWE, (minimal adaptation of the iTutorial 3.7 on Nonlinear Problems).
As we are trying to solve a(u[sub]h[/sub],v[sub]h[/sub])=0, the residual ||a(u[sub]h[/sub][sup]i[/sup], v[sub]h[/sub]) ||[sub]l2[/sub] = ||res ||[sub]l2[/sub] should converge towards zero. Doe anyone know, what is going wrong here?
The application of the bilinearform does not care about dirichlet dofs. Hence, your res-vector may have (has) non-zero entries which however have no impact on your iterate. This is what you see in your MWE. You should Project the dirichlet dofs out.
You can use the Projector object. You provide a BitArray (in your case the freedofs-array) and a flag true/false. The result is a linear operator (basematrix). You can then apply the projector on a vector as any other basematrix object. The result will set the entries to zero wherever the BitArray is true/flase (depending on the flag you provided).