Matrix-vector multiplication in weak formulation

I’m not a TAO expert, you’ll have to try different methods. Also, I still don’t know what you are trying to solve exactly, so it’s difficult for me to give you precise pointers. SNESSolve either solves F(x) = 0, or F(x) = b. You are free to put what you want in the output vector, but this acts as an initial guess for nonlinear solves, so it’s best to use something not too far from the solution otherwise your Newton may never converge.

Thank you for your reply, prj.

Here I uploaded my problem using SNESSolve, all the macro and constants are deleted to reduce the program from 2300 lines to 270+ lines. 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.PETSc_Example.edp (18.0 KB)

Would you please help me point out the incorrect part in this program? Thanke you very much. I’m nont sure whether I transform the code in a correct way.

Your script doesn’t even run.

Sorry, I don’t have a simplified version that can run, sorry.

No, I mean that your script is wrong, I can’t even launch it on my machine.

Is the way of adding boundary condition in SNESSolve the same with TAO? If the initial value of boundary nodes are set to meet the requirements of boundary condition, can it be maintained using the constrain of upper and lower bound or using the form as on(1,2,3,4, du1=0,du2=0,du3=0) in varf function?

Thank you for your reply.

The boundary conditions have to be set in your initial guess.

Thans for your timely reply.

I have found that in the definition of funcRes and funcJ, “tgv” is used in the vector and matrix forming such as “Loc = vPb(Wh, Wh, tgv = -2)” in SNESSolve. The tgv in FreeFem++ is always represent 1e30 to implement Dirichlet boundary conditions and in most situation can be neglected.

So is it necessary to define funcRes and funcJ with the form “Loc = vPb(Wh, Wh, tgv = -2)” or with the form in which tgv can be neglected as “Loc = vPb(Wh, Wh)”?

If correct form is Loc = vPb(Wh, Wh, tgv = -2), which value of tgv should be used, -1, -2 or 1e30 and why?

Thank you.

I always advise against using the default value of 10e+30. -1 (or -2 if your problem has homogeneous boundary conditions and is symmetric) is always better when you do iterative algorithms, such as a Newton loop in SNESSolve/TaoSolve.

Thanke you. I’m now using tgv=-2 in a SNESSolve iteration.

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.

Your script has 1.5k source lines of code. Start with something small, if it doesn’t give you what you want, I’ll help you debug. Then, incrementally add complexity on top of functioning code.

Thank you. I will try that.

Do you know how to use the PDIPM solver (-tao type pdipm) in TAO? I found it may be the same solver used in IPOPT, but there is not much information about it. I have try several time with the command
TaoSolve(H, J, DJ, uPETSc, xl=lbPETSc, xu=ubPETSc, sparams="-tao_monitor -tao_view -tao_type pdipm -tao_max_it 1000 -tao_gatol 1e-4 -pc_type lu", HessianRoutine=HJ)
but failed, the iteration can not even start.

Does it fail on a complicated problem, or on a very basic one? If it’s again on your 1.5k lines of code solver, then it’s not surprise, I guess you have other issues that you need to figure out first. And that’s why I recommend that you start with a much simpler version of your solver and gradually transition into the complete one.

Thanks for your reply.

Do you have a example using Taosolve with Interior-point Newton’s method(-tao type pdipm). I couldn’t find a correct form to use Interior-point Newton’s method. I have uploaded a small example use -tao type pdipm but failed. This one is correct use -tao type bnls.

Moreover, beside SNESVINEWTONRSLS and SNESVINEWTONSSLS, there any other SNES solvers can be used for variational equility and bond-constrained problem?

TAOexample_use_pdipm.edp (5.1 KB)

Thanks for your kindly help.

Here is an example that should work with PDIPM.

I have read that.

TaoSolve(H, J, DJ, x, xl = xl, xu = xu, sparams = “-tao_monitor -tao_type ipm -pc_type lu -pc_factor_mat_solver_type mumps”, HessianRoutine = funcH, EqualityConstraints = funcE, JacobianEquality = funcJE, JE = JE);

In this TaoSolve, are the options “EqualityConstraints = funcE, JacobianEquality = funcJE, JE = JE” necessary for IPM solver? My problem is a simple bound problem without other equality constraints (as the uploaded one). How should I form funcE, funcJE and JE with FF++ function “varf”?

And what about the problem on SNES solvers?

Thank you for your timely reply.

The options are not mandatory, it all depends on what you want to solve. To use a varf instead, you can look instead at this other example.
You cannot provide derivatives of constraints with SNES, so it may converge slower, but this is problem specific.

TAOexample_use_ipm.edp (5.2 KB)

Here I have uploaded a small example using ipm solver. But the error continue to show in the cmd window. The problem is the one which you have helped me to correct it and it’s runable using bnls solver. Could you lend me a hand on how to correct this example using ipm solver with multiple processors?

Thank you very much.

There are probably some bugs with PDIPM (the solver is rather new), I’m trying to figure this out with the Tao development team. In the meantime, if things work with BNLS, why don’t you use it?