Skip to content

BUG: Matfree EquationBC with Schur fails #4721

@KarsKnook

Description

@KarsKnook

When using EquationBC in a matrix-free context with Schur complement preconditioning, we do not get the correct behaviour (potentially the EquationBC is not enforced correctly?). For example, the problem in the MFE below should converge in 1 FGMRES iteration but it takes 2 FGMRES iterations. When commenting out "mat_type": "matfree", we get the expected behaviour.

from firedrake import *

mesh = UnitSquareMesh(2, 2)
nml = FacetNormal(mesh)

V = FunctionSpace(mesh, "RT", 1)
W = FunctionSpace(mesh, "DG", 0)
Z = V * W

z = Function(Z)
sigma, u = split(z)
tau, v = TestFunctions(Z)

F = inner(sigma, tau) * dx
F -= inner(u, div(tau)) * dx
F += inner(div(sigma), v) * dx
F += inner(div(sigma), div(tau)) * dx

bcs = [EquationBC(inner(dot(sigma - Constant([1,1]), nml), dot(tau, nml)) * ds(1) == 0, z, [1], V=Z.sub(0))]

sp = {
        "mat_type": "matfree",
        "snes_monitor": None,
        "ksp_monitor": None,
        "ksp_type": "fgmres",
        "pc_type": "fieldsplit",
        "pc_fieldsplit_type": "schur",
        "pc_fieldsplit_schur_fact_type": "full",
        "fieldsplit_0": {
            "ksp_type": "preonly",
            "pc_type": "python",
            "pc_python_type": "firedrake.AssembledPC",
            "assembled": {
                "pc_type": "lu",
                "pc_factor_mat_solver_type": "mumps",
                },
            },
        "fieldsplit_1": {
            "ksp_type": "gmres",
            "ksp_monitor": None,
            "ksp_atol": 0,
            "ksp_rtol": 1e-12,
            "pc_type": "python",
            "pc_python_type": "firedrake.MassInvPC",
            "aux_pc_type": "python",
            "aux_pc_python_type": "firedrake.AssembledPC",
            "aux_assembled": {
                "pc_type": "lu",
                "pc_factor_mat_solver_type": "mumps",
                },
            },
        }

solve(F==0, z, bcs=bcs, solver_parameters=sp)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions