firedrakeproject / firedrake

Firedrake is an automated system for the portable solution of partial differential equations using the finite element method (FEM)
https://firedrakeproject.org
Other
482 stars 157 forks source link

BUG: LinearEigenproblem/Solver does not work for mixed problems with fieldsplit #3607

Open danshapero opened 3 weeks ago

danshapero commented 3 weeks ago

Describe the bug I'm trying to solve a Stokes eigenproblem to empirically determine the stability constant for a certain element pair. Solving the eigenproblem using LU works fine. Trying to use a fieldsplit preconditioner as recommended in the docs gives an error Unhandled case, must have at least two fields, not 1.

Per discussion in slack with @wence- and Matt Knepley, something is wrong with the Section; it should have 2 fields but it has only 1. The DMs are probably not attached to the operators that are getting passed to the EPS object, and so there's no transfer of the algebraic data that this is a problem for two fields.

Steps to Reproduce Minimal working example is here. Run with python mwe.py -solver lu and it works fine, run with python mwe.py -solver fieldsplit and it errors.

Expected behavior It solves the Stokes eigenproblem but like really fast and then I publish a lovely paper

Error message

Traceback (most recent call last):
  File "/home/daniel/papers/tensor-product-stokes/mwe.py", line 62, in <module>
    num_converged = solver.solve()
                    ^^^^^^^^^^^^^^
  File "/home/daniel/.pyenv/versions/firedrake-2024-04-29/src/firedrake/firedrak
e/eigensolver.py", line 199, in solve
    self.es.solve()
  File "slepc4py/SLEPc/EPS.pyx", line 1266, in slepc4py.SLEPc.EPS.solve
petsc4py.PETSc.Error: error code 77
[0] EPSSolve() at /home/daniel/.pyenv/versions/firedrake-2024-04-29/src/slepc/sr
c/eps/interface/epssolve.c:134
[0] EPSSetUp() at /home/daniel/.pyenv/versions/firedrake-2024-04-29/src/slepc/sr
c/eps/interface/epssetup.c:381
[0] STSetUp() at /home/daniel/.pyenv/versions/firedrake-2024-04-29/src/slepc/src
/sys/classes/st/interface/stsolve.c:545
[0] STSetUp_Sinvert() at /home/daniel/.pyenv/versions/firedrake-2024-04-29/src/s
lepc/src/sys/classes/st/impls/sinvert/sinvert.c:116
[0] KSPSetUp() at /home/daniel/.pyenv/versions/firedrake-2024-04-29/src/petsc/sr
c/ksp/ksp/interface/itfunc.c:415
[0] PCSetUp() at /home/daniel/.pyenv/versions/firedrake-2024-04-29/src/petsc/src
/ksp/pc/interface/precon.c:1079
[0] PCSetUp_FieldSplit() at /home/daniel/.pyenv/versions/firedrake-2024-04-29/sr
c/petsc/src/ksp/pc/impls/fieldsplit/fieldsplit.c:582
[0] PCFieldSplitSetDefaults() at /home/daniel/.pyenv/versions/firedrake-2024-04-
29/src/petsc/src/ksp/pc/impls/fieldsplit/fieldsplit.c:544
[0] Petsc has generated inconsistent data
[0] Unhandled case, must have at least two fields, not 1

Environment: