I have been interested in using a Non-Linear Conjugate Gradient (NLCG) method for minimizing non-linear problems and using DDM/PETSc tools. As discussed here, one can use for example TAO using the flags
I wrote (some times ago, with the help of @prj ) an alternative NLCG set of macros for hpddm/petsc that more or less reproduce the codes in the file src/femlib/CGNL.hpp. The main difference with TAO routine is that TAO requires evaluations of the functional to be minimized, while the NLCG here requires only to evaluate the variations… I ran few examples and find that the code I wrote is typically as fast as TAO but with a (slightly) better convergence rate… So I think it is worth sharing with the community.
I cooked up various examples for non-linear problems. I think a simple example is the static “kink” solution of the Sine-Gordon equation (the solution is called a topological soliton, and the analytic solution is known…). The code that constructs the kink is hpddm-petsc-NLCG.edp (4.3 KB) . I tried to make it quite documented.
Also the code hpddm-petsc-NLCG-vs-TAO.edp (5.5 KB) solves the same problem and compares results and execution time with the TAO implementation…
Please let me know if you have some feed back to improve the code, or if some things are not clear. Also, if it is of interest, I can write more detailed documentation on the background problem, or about various other non-linear problems…