Skip to content

Interaction between fem.petsc.LinearProblem and setting a nullspace #3784

@francesco-ballarin

Description

@francesco-ballarin

The logic in fem.petsc.LinearProblem is currently the following

  1. initialize the matrix A and vector b data structure, in __init__
  2. assemble the matrix and vector values, in solve
  3. call KSP to solve the linear system, in solve.

I think this makes sense for most of the cases. However, there is a limit case in which the user would need to interact with the matrix/vector between steps 2 and 3, which is the case of setting a nullspace, doing something like

assert nullspace.test(A)
A.setNullSpace(nullspace)
nullspace.remove(b)
  • What we currently do is to do A.setNullSpace(nullspace) after step 1. See e.g.
    problem.A.setNullSpace(nsp)
    . This works perfectly, even when A is still zero.
  • What we currently do is to do assert nullspace.test(A) after step 3. See e.g.
    assert nsp.test(problem.A)
    . IMHO, this is hard to understand for a end-user: arguably, the logical order would be first to test the nullspace, if the test passes then to set it to the matrix, and finally to solve. Unfortunately, we cannot do it in this way because the test would need to happen between steps 2 and 3, at .
  • We currently cannot have nullspace.remove(b) . Again, it would need to happen between steps 2 and 3.

Opening this issue as an enhancement just in case we can work out a slightly modified design, or determine that this is not worth it. I like fem.petsc.LinearProblem as it currently is and I would refrain from making it much more involved for the end-user just to support this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions