Skip to content

Setting mumps options with BlockedNewtonSolver #79

@ottarph

Description

@ottarph

When making my own Newton solver manually with dolfinx.fem.petsc.assemble_matrix/vector_block, I can change the options for the mumps direct solver with something like

A = dolfinx.fem.petsc.create_matrix_block(jacobian_comp)
ksp = PETSc.KSP().create(mesh.comm)
ksp.setOperators(A)
ksp.setType("preonly")
ksp.getPC().setType("lu")
ksp.getPC().setFactorSolverType("mumps")
ksp.getPC().getFactorMatrix().setMumpsIcntl(14, 300)

I would like to set the same options when using the scifem BlockedNewtonSolver, but my attempts using

solver = scifem.BlockedNewtonSolver(residual_comp, [u, v, p, q], bcs, jacobian_comp)
ksp = solver.krylov_solver
ksp.setType("preonly")
ksp.getPC().setType("lu")
ksp.getPC().setFactorSolverType("mumps")
ksp.getPC().getFactorMatrix().setMumpsIcntl(14, 300)

or

solver = scifem.BlockedNewtonSolver(residual_comp, [u, v, p, q], bcs, jacobian_comp)
ksp = solver.krylov_solver
ksp.setType("preonly")
ksp.getPC().setType("lu")
ksp.getPC().setFactorSolverType("mumps")
solver._J.setMumpsIcntl(14, 300)

crash with the errors

petsc4py.PETSc.Error: error code 73
[0] MatMumpsSetIcntl() at /home/conda/feedstock_root/build_artifacts/petsc_1733218859887/work/src/mat/impls/aij/mpi/mumps/mumps.c:2814
[0] Object is in wrong state
[0] Only for factored matrix

and

petsc4py.PETSc.Error: error code 73
[0] PCFactorGetMatrix() at /home/conda/feedstock_root/build_artifacts/petsc_1733218859887/work/src/ksp/pc/interface/precon.c:1461
[0] PCFactorSetUpMatSolverType() at /home/conda/feedstock_root/build_artifacts/petsc_1733218859887/work/src/ksp/pc/impls/factor/factor.c:105
[0] PCFactorSetUpMatSolverType_Factor() at /home/conda/feedstock_root/build_artifacts/petsc_1733218859887/work/src/ksp/pc/impls/factor/factimpl.c:8
[0] Object is in wrong state
[0] You can only call this routine after the matrix object has been provided to the solver, for example with KSPSetOperators() or SNESSetJacobian()

Is there a good way to control these options with the BlockedNewtonSolver?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions