Skip to content

Direct solve fails for a mixed system #431

Closed
@ctjacobs

Description

@ctjacobs

I'm trying to use a direct solver on a mixed system:

from firedrake import *

mesh = UnitSquareMesh(2, 2)

# Define the mixed function space
U = VectorFunctionSpace(mesh, "CG", 2)
H = FunctionSpace(mesh, "CG", 1)
W = MixedFunctionSpace([U, H])

# The solution field defined on the mixed function space
solution = Function(W)
u, h = split(solution)
w, v = TestFunctions(W)

# Define the compulsory shallow water fields
solution_old = Function(W)
solution_old.interpolate(Expression(("0.1*sin(pi*x[0])", "1e-16", "cos(pi*x[0])")))
u_old, h_old = split(solution_old)

# The solution should first hold the initial condition.
solution.assign(solution_old)

# Mean free surface height
h_mean = Function(W.sub(1)).interpolate(Expression("50"))

# The total height of the free surface.
h_total = h_mean + h

# Time-step size
dt = 0.05

# The form, F
F = 0
M_momentum = (1.0/dt)*(inner(w, u) - inner(w, u_old))*dx
F += M_momentum

A_momentum = inner(dot(grad(u), u), w)*dx
F += A_momentum

C_momentum = -9.81*inner(w, grad(h))*dx
F += C_momentum

M_continuity = (1.0/dt)*(inner(v, h) - inner(v, h_old))*dx
F += M_continuity

Ct_continuity = inner(v, div(h_total*u))*dx
F += Ct_continuity

# Construct the solver objects
problem = NonlinearVariationalProblem(F, solution, bcs=[])
solver = NonlinearVariationalSolver(problem, solver_parameters={'ksp_type':'preonly', 'pc_type':'lu'})
solver.solve()

but I'm getting the following PETSc error:

Traceback (most recent call last):
  File "test_lu.py", line 52, in <module>
    solver.solve()
  File "<string>", line 2, in solve
  File "/usr/local/lib/python2.7/dist-packages/PyOP2-0.11.0_148_g8a1955c-py2.7-linux-x86_64.egg/pyop2/profiling.py", line 197, in wrapper
    return f(*args, **kwargs)
  File "/data/firedrake/firedrake/variational_solver.py", line 252, in solve
    self.snes.solve(None, v)
  File "PETSc/SNES.pyx", line 511, in petsc4py.PETSc.SNES.solve (src/petsc4py.PETSc.c:155735)
petsc4py.PETSc.Error: error code 56
[0] SNESSolve() line 3740 in /tmp/pip-IWeiSF-build/src/snes/interface/snes.c
[0] SNESSolve_NEWTONLS() line 232 in /tmp/pip-IWeiSF-build/src/snes/impls/ls/ls.c
[0] KSPSolve() line 419 in /tmp/pip-IWeiSF-build/src/ksp/ksp/interface/itfunc.c
[0] KSPSetUp() line 306 in /tmp/pip-IWeiSF-build/src/ksp/ksp/interface/itfunc.c
[0] PCSetUp() line 902 in /tmp/pip-IWeiSF-build/src/ksp/pc/interface/precon.c
[0] PCSetUp_LU() line 116 in /tmp/pip-IWeiSF-build/src/ksp/pc/impls/factor/lu/lu.c
[0] MatGetOrdering() line 260 in /tmp/pip-IWeiSF-build/src/mat/order/sorder.c
[0] MatGetOrdering_ND() line 19 in /tmp/pip-IWeiSF-build/src/mat/order/spnd.c
[0] No support for this operation for this object type
[0] Cannot get rows for matrix type nest

Do I need to pass in some additional options when building PETSc, or is this unsupported in Firedrake? If it's the latter, please tag this as a 'wishlist' item.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions