This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Auto adaptive stokes fails with "Unable to perform just-in-time compilation of form... Unable to extract all indices"

+2 votes

I solve the stokes equations on a square domain. Minimal code:

mesh = UnitSquareMesh(8, 8)
P2 = VectorElement("Lagrange", mesh.ufl_cell(), 2)
P1 = FiniteElement("Lagrange", mesh.ufl_cell(), 1)
TH = P2 * P1
W = FunctionSpace(mesh, TH)

def bottom(x, on_boundary): return near(x[1],0.0)
def left(x, on_boundary): return near(x[0],0.0)
bc_b = DirichletBC(W.sub(0), Constant((1.0,0.0)), bottom);
bc_l = DirichletBC(W.sub(0), Constant((0.0,0.0)), left);
bc = [bc_b, bc_l]

(u, p) = TrialFunctions(W)
(v, q) = TestFunctions(W)

a = inner(grad(u), grad(v))*dx + div(v)*p*dx + q*div(u)*dx
L = inner( Constant((0.0,0.0)), v)*dx

U = Function(W)
M = p * dx
solve(a == L, U, bc, tol=0.1, M=M)

This code runs if I change the last line to:

solve(a == L, U, bc)

As written in fails with the message:

Unable to extract all indices.
...
*** Error:   Unable to perform just-in-time compilation of form.

I also get the same error if I replace the last line with the code from the Auto adaptive Poisson equation demo,

problem = LinearVariationalProblem(a, L, U, bc)
solver = AdaptiveLinearVariationalSolver(problem, M)
solver.parameters["error_control"]["dual_variational_solver"]["linear_solver"] = "cg"
solver.parameters["error_control"]["dual_variational_solver"]["symmetric"] = True
solver.solve(0.1)
asked Jan 27, 2017 by radbiv_kylops FEniCS Novice (680 points)

1 Answer

+1 vote

The problem is that I was writing the refinement criterion in the wrong form. I was incorrectly defining M as the integral of a TrialFunction when it should have been defined this way:

(uu, pp) = (as_vector((U[0], U[1])), U[2])
M = uu[0] * dx

I found this solution by examining this "undocumented" fenics demo:

https://github.com/FEniCS/dolfin/blob/master/demo/undocumented/auto-adaptive-navier-stokes/python/demo_auto-adaptive-navier-stokes.py

answered Jan 30, 2017 by radbiv_kylops FEniCS Novice (680 points)
...