This can be seen as a follow-up to this resolved bug. When I try to assemble a form after adapting it to a new mesh, I get an error message:
from dolfin import *
mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, "Lagrange", 1)
U = Function(V)
U.interpolate(Constant(1.0))
F = U*dx
assemble(F) # works
adapted_mesh = adapt(mesh)
adapted_form = adapt(Form(F), adapted_mesh)
assemble(adapted_form) # raises error
Running the above code yields the message
TypeError: Expected a dolfin form to have a _compiled_form attribute.
I also accounted the problem when I tried to assemble a bilinear form which was returned by LinearVariationalProblem.bilinear_form(). The following is a slight modification of the classic Poisson demo which raises same error as above:
from dolfin import *
mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, "Lagrange", 1)
u = TrialFunction(V)
v = TestFunction(V)
f = Expression("1.0")
a = inner(grad(u), grad(v))*dx
L = f*v*dx
u = Function(V)
A = assemble(a) # works
problem = LinearVariationalProblem(a,L,u)
A = assemble(problem.bilinear_form()) # raises error
It seems that the _compiled_form attribute (which is created when the ufl.form is passed to assemble or explicitly converted to a dolfin.Form using Form(ufl.form)) somehow gets lost in these examples.