From updating an old code:
I used to use PETSc's fieldsplit
for solving Stokes system à la
from dolfin import *
mesh = UnitSquareMesh(20, 20, 'crossed')
W = VectorElement('Lagrange', mesh.ufl_cell(), 2)
P = FiniteElement('Lagrange', mesh.ufl_cell(), 1)
WP = FunctionSpace(mesh, W*P)
u_bcs = DirichletBC(WP.sub(0), Constant((0.0, 0.0)), 'on_boundary')
p_bcs = DirichletBC(WP.sub(1), Constant(0.0), 'on_boundary')
bcs = [u_bcs, p_bcs]
(u, p) = TrialFunctions(WP)
(v, q) = TestFunctions(WP)
# Create Stokes system
mu = 1.0
f = Constant((1.0, 1.0))
a = mu * inner(grad(u), grad(v))*dx \
- p * div(v) * dx \
- q * div(u) * dx
L = dot(f, v)*dx
A, b = assemble_system(a, L, bcs)
# solver
W = WP.sub(0)
P = WP.sub(1)
u_dofs = W.dofmap().dofs()
p_dofs = P.dofmap().dofs()
prec = PETScPreconditioner()
prec.set_fieldsplit([u_dofs, p_dofs], ['u', 'p'])
PETScOptions.set('pc_type', 'fieldsplit')
PETScOptions.set('pc_fieldsplit_type', 'additive')
PETScOptions.set('fieldsplit_u_pc_type', 'lu')
PETScOptions.set('fieldsplit_p_pc_type', 'jacobi')
solver = PETScKrylovSolver('gmres', prec)
solver.set_operator(A)
solver.parameters['monitor_convergence'] = verbose
solver.parameters['report'] = verbose
solver.parameters['absolute_tolerance'] = 0.0
solver.parameters['relative_tolerance'] = tol
solver.parameters['maximum_iterations'] = 500
# Solve
up = Function(WP)
solver.solve(up.vector(), b)
Now, the above gives the error
TypeError: PETScPreconditioner_set_fieldsplit expected 4 arguments, got 3
Is anyone using fieldsplit and knows what's going on?