Newton Stopping criteria

More
5 years 5 months ago #1658 by hvwahl
Hi,

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
Code:
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(uh,vh)=0, the residual ||a(uhi, vh) ||l2 = ||res ||l2 should converge towards zero. Doe anyone know, what is going wrong here?

Best wishes,
Henry
More
5 years 5 months ago #1659 by schruste
Replied by schruste on topic Newton Stopping criteria
Hi Henry,

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.

Best,
Christoph
More
5 years 5 months ago #1660 by hvwahl
Replied by hvwahl on topic Newton Stopping criteria
Thank you Christoph!

Is there a better way for projecting out the Dirichlet Dofs than going for
Code:
res.FV().NumPy()[V.FreeDofs()]
?

Best wishes,
Henry
More
5 years 5 months ago #1661 by schruste
Replied by schruste on topic Newton Stopping criteria
Hi,

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).

Best,
Christoph
More
5 years 5 months ago #1662 by hvwahl
Replied by hvwahl on topic Newton Stopping criteria
Hi,

Thank you! I wasn’t aware of this object before. Using the projector has also resulted in the whole script running slightly faster :) !

Best wishes,
Henry
Time to create page: 0.118 seconds