The use of general passion is success but the use of adaptive error

7 months ago by
Hello everyone:
I am studying auto-adaptive solution, unluckly, In the process i encountered a problem; 

the code is following:

from dolfin import *
# Create mesh and define function space
mesh = UnitSquareMesh(8, 8)
V = FunctionSpace(mesh, "CG", 1)
# Define Dirichlet boundary (x = 0 or x = 1)
def boundary(x):
return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS

# Define boundary condition
u0 = Constant(1.0)
bc = DirichletBC(V, u0, boundary)

# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)

g = Expression("sin(5*x[0])",degree=2)
F =inner(grad(u), grad(v))*dx+g*u*v*ds
A = lhs(F)
L = rhs(F)

# Compute solution
u = Function(V)
problem = LinearVariationalProblem(A,L,u,bc)
solver = AdaptiveLinearVariationalSolver(problem,M)

# Plot solution


An error occurs when  using adaptation. However not using adaption is runnable, how do i solve?
Best wishes!
Thank you!

The tip of error is forrowing:
Generating forms required for error control, this may take some time...
Traceback (most recent call last):
File "", line 29, in <module>
solver = AdaptiveLinearVariationalSolver(problem,M)
File "/usr/lib/python2.7/dist-packages/dolfin/fem/", line 59, in __init__
ec = generate_error_control(self.problem, goal)
File "/usr/lib/python2.7/dist-packages/dolfin/fem/", line 146, in generate_error_control
(ufl_forms, is_linear) = generate_error_control_forms(problem, goal)
File "/usr/lib/python2.7/dist-packages/dolfin/fem/", line 194, 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!
[1] 5740 abort python
Community: FEniCS Project

1 Answer

7 months ago by
The problem seems to be that the form F has no right-hand side (all terms involve u).  If I add "+ Constant(0.0)*v*dx" to the form F it runs (with version 2017.1).
Please login to add an answer/comment or follow this question.

Similar posts:
Search »