Dear Simone,
> On 25 Jun 2019, at 19:20, Matthew Knepley <knepley@gmail.com> wrote:
>
> On Tue, Jun 25, 2019 at 11:48 AM Simone Puel <spuel@utexas.edu> wrote:
> Dear Lawrence and David,
>
> Thank you so much for your explanation and helps, I really appreciate it. I would like to switch from FEniCS to Firedrake and I am trying to rewrite my scripts according to the Firedrake syntax and logic. This should be a very simple problem (2D with less than 1000 dofs).
> However, adding the line you suggested in the solver_parameters as:
> solve(lhs_varf == rhs_varf, sol, bcs=[bc1, bc2],
> solver_parameters={"ksp_type": "preonly",
> "pc_type": "lu",
> "pc_factor_mat_solver_type": "mumps",
> "mat_type": "aij"})
>
> The solver does not still converge giving the following error:
>
> Traceback (most recent call last):
> File "Elasticity2D_Firedrake.py", line 167, in <module>
> "mat_type": "aij"})
> File "/home/simone/firedrake/src/firedrake/firedrake/solving.py", line 125, in solve
> _solve_varproblem(*args, **kwargs)
> File "/home/simone/firedrake/src/firedrake/firedrake/solving.py", line 153, in _solve_varproblem
> solver.solve()
> File "/home/simone/firedrake/src/firedrake/firedrake/variational_solver.py", line 267, in solve
> solving_utils.check_snes_convergence(self.snes)
> File "/home/simone/firedrake/src/firedrake/firedrake/solving_utils.py", line 44, in check_snes_convergence
> %s""" % (snes.getIterationNumber(), msg))
> firedrake.exceptions.ConvergenceError: Nonlinear solve failed to converge after 0 nonlinear iterations.
> Reason:
> Inner linear solve failed to converge after 0 iterations with reason: DIVERGED_PCSETUP_FAILED
>
> Hi Simone,
>
> This means the factorization failed If this is elasticity, you should not have a nullspace. Are you sure the
> boundary conditions are correct? The other possibility is that the package you were using in FEniCS,
> maybe UMFPACK, is doing better pivoting than what you are using now, maybe PETSc. You can get
> UMFPACK by configuring PETSc with --download-suitesparse.
Matt is correct. We are using MUMPS to do the factorisation, we can get a bit more information by adding:
"ksp_converged_reason": None
to the solver parameters dict.
When I do that, I get the same error, but I also see:
Linear firedrake_0_ solve did not converge due to DIVERGED_PC_FAILED iterations 0
PC_FAILED due to FACTOR_OUTMEMORY
Aha! MUMPS has an "esoteric" approach to memory allocation, it guesses how much space it will need, and then never attempts to reallocate. In this case, its guess is too low, and we get an error. We can help it out by upping the safety factor it uses.
The relevant option is:
-mat_mumps_icntl_14 "ICNTL(14): percentage increase in the estimated working space"
So, let's have a guess and add
"mat_mumps_icntl_14": 200
to the solver parameters dictionary.
Now it works!
$ python Elasticity2D_Firedrake.py
Linear firedrake_0_ solve converged due to CONVERGED_ITS iterations 1
Time elapsed 0.42232704162597656 seconds
Finished!
So my final solver options were:
solver_parameters={"ksp_type": "preonly",
"pc_type": "lu",
"ksp_converged_reason": None,
"pc_factor_mat_solver_type": "mumps",
"mat_mumps_icntl_14": 200,
"mat_type": "aij"}
Other sparse direct solvers are also available. The default firedrake-install does not build petsc with them, but as Matt mentions, UMFPACK is often a good option, as well as superlu_dist. I need to look up the right magic incantations to install those though.
Thanks,
Lawrence