Error on the goal function(?) in the Adaptive linear solver

I am trying to use the Adaptive solver for a linear elasticiti problem but i get

from dolfin import *

mesh = UnitSquareMesh(4,4)
V = VectorFunctionSpace(mesh, 'CG',1)
u = Function(V)
v = TestFunction(V)
du = TrialFunction(V)

E, nu = 70000., 0.2
mu, lamb = E / (2. * (1. + nu)), E * nu / (1. - nu ** 2)

def epsilon(u):
    return 0.5*(grad(u)  + grad(u).T)

def sigma(u):
    return 2.0*mu*epsilon(u) + lamb*tr(epsilon(u))*Identity(2)

class top(SubDomain):
    def inside(self,x,on_boundary):
        return near(x[1], 1.)
Top = top()

class bottom(SubDomain):
    def inside(self,x,on_boundary):
        return near(x[1], 0.)
Bottom = bottom()

bc1 = DirichletBC(V, Constant((0., 0.)), Bottom)
bc2 = DirichletBC(V.sub(1), Constant(0.2), Top)
bc = [bc1, bc2]

E_du = inner(nabla_grad(v), sigma(du))*dx
M = inner(u,u) * dx

problem_u = LinearVariationalProblem(lhs(E_du), rhs(E_du), u, bc)
solver_u = AdaptiveLinearVariationalSolver(problem_u, M)
solver_u.solve(1.e-5)

but i get the following error:

File “Poisson_adaptive.py”, line 74, in
solver_u = AdaptiveLinearVariationalSolver(problem_u, M)
File “/usr/local/lib/python3.6/dist-packages/dolfin/fem/adaptivesolving.py”, line 54, in init
ec = generate_error_control(self.problem, goal)
File “/usr/local/lib/python3.6/dist-packages/dolfin/fem/adaptivesolving.py”, line 145, in generate_error_control
(ufl_forms, is_linear) = generate_error_control_forms(problem, goal)
File “/usr/local/lib/python3.6/dist-packages/dolfin/fem/adaptivesolving.py”, line 196, in generate_error_control_forms
assert len(form.ufl_domains()) > 0, “Error control got as input a form with no domain!”
AssertionError: Error control got as input a form with no domain!

Thanks in advance.

I guess the problem is that there is no rhs in E_du. To circumvent this, you could add:
inner(Constant(0,0), v)*dx to E_du.

1 Like