When to use NonLinearVariationalSolver?

In the FEniCS tutorial, a case of nonlinear Poisson equation is treated. Once the weak form has been found, the nonlinear problem is solved using solve().

However, I found a few examples (and there is a documentation) of “NonLinearVariationalProblem” and an associated solver. I can find no use of this in the FEniCS tutorial.

My question is, is there any reason to use NonlinearVariationalSolver.solve() instead of just solve()? What are the differences exactly? Should we use one over the other in specific problems? If so, which kind of problems? Why has the FEniCS tutorial focused on solve() rather than the other alternative?

I suppose the non-linear Poisson example you mention is the one in demo/documented/nonlinear-poisson/demo_nonlinear-poisson.py.

The solve(....) function distinguishes two cases
(case 1) : solve(A == L, u, bc) corresponds to a linear problem, and uses LinearVariationalProblem and LinearVariationalSolver .
(case 2) : solve(F==0, u, bc) which corresponds to a non-linear problem, and uses NonLinearVariationalProblem and NonLinearVariationalSolver as :

# Create problem
problem = NonlinearVariationalProblem([...])
# Create solver and call solve
solver = NonlinearVariationalSolver(problem)
solver.parameters.update(solver_parameters)
solver.solve()

The example you mention is solved using solve(F == 0, u, bc,...) (case 2 above). So I guess the answer to your question is : there is no difference between NonlinearVariationalSolver.solve() and just solve(), solve(F==0, u, bc, ...) is just a “shortcut”

4 Likes

Thank you very much, I did not know this at all! That’s very informative.

2 Likes