Skip to content

Commit

Permalink
Let PETSc choose default LU solver within NewtonSolver (#2803)
Browse files Browse the repository at this point in the history
* Let PETSc handle default LU solver, consistent with LinearProblem behaviour.

* Remove commented lines.

* Use MUMPS unless on Mac ARM where it doesn't work.

* Use SuperLU_dist on mac, otherwise mumps, otherwise default.

* fix mypy

* Try this.

* Remove platform

---------

Co-authored-by: Garth N. Wells <gnw20@cam.ac.uk>
  • Loading branch information
jhale and garth-wells committed Nov 14, 2023
1 parent 2731add commit 6d0720e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 0 additions & 3 deletions cpp/dolfinx/nls/NewtonSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ nls::petsc::NewtonSolver::NewtonSolver(MPI_Comm comm)
_solver.set_options_prefix("nls_solve_");
la::petsc::options::set("nls_solve_ksp_type", "preonly");
la::petsc::options::set("nls_solve_pc_type", "lu");
#if PETSC_HAVE_MUMPS
la::petsc::options::set("nls_solve_pc_factor_mat_solver_type", "mumps");
#endif
_solver.set_from_options();
}
//-----------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions python/demo/demo_cahn-hilliard.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@
option_prefix = ksp.getOptionsPrefix()
opts[f"{option_prefix}ksp_type"] = "preonly"
opts[f"{option_prefix}pc_type"] = "lu"
sys = PETSc.Sys() # type: ignore
# For factorisation prefer MUMPS, then superlu_dist, then default.
if sys.hasExternalPackage("mumps"):
opts[f"{option_prefix}pc_factor_mat_solver_type"] = "mumps"
elif sys.hasExternalPackage("superlu_dist"):
opts[f"{option_prefix}pc_factor_mat_solver_type"] = "superlu_dist"
ksp.setFromOptions()
# -

Expand Down

0 comments on commit 6d0720e

Please sign in to comment.