Matrix-vector multiplication in weak formulation

Dear prj

Here I have uploaded a runable simplified version of my problem.

This is a nonlinear problem F(x)=0, the F is given in funcRes part and the correct Jacobian matrix is obtained in funcJ part. Their forms have been proved in my original IPOPT program so don’t worry about that. The solution vector is [u1,u2,u3,eta,eta0], boundary condition is given for u1, u2 and u3, bound Inequality constrain [0,1] is given for eta and eta0. Also, the eta and eta0 are time dependent so their values of previous time step is defined as etaOLD and eta0OLD.

Could you please point out the errors it contains and give me some suggestions on how to correct it? My own version does not run well and can not get the correct results as IPOPT does,the boundary constrain are some times violated in the line search iterations in Newton computation with the default solver option as " -snes_monitor -ksp_converged_reason -snes_view -snes_vi_monitor -snes_type vinewtonrsls -snes_max_it 1000 -snes_rtol 1.0e-6 -pc_type lu ". And moreover, if I turn off the line search using -snes_linesearch_type basec or change the preconditioner, the results converge would fail.

PETSc_exa.edp (103.6 KB)

Thank you very much.