Forms generated with adapt() can not be assembled
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
DOLFIN |
Fix Released
|
Undecided
|
Marie Rognes |
Bug Description
Hi,
I would like to assemble a form on two different meshes using the adapt() function.
Unfortunately, the objects that are generated by adapt can not be directly passed to the assembly function
as demonstrated below (code with tested on trunk):
from dolfin import *
mesh = UnitSquareMesh(2,2)
adapt(mesh)
V = FunctionSpace(mesh, "CG", 1)
u = TrialFunction(V)
w = TestFunction(V)
form = inner(u, w)*dx
dolfin_form = Form(form) # Ideally I would want to call adapt(form), but that does not work...
adapt(dolfin_form, mesh.child(), False)
print type(dolfin_form) # <class 'dolfin.
print type(dolfin_
A1 = assemble(
A2 = assemble(
# Let's try and apply some boundary conditions
bc = DirichletBC(V, Constant(0), "on_boundary")
adapt(bc, mesh.child(), V.child())
print type(bc) # <class 'dolfin.
print type(bc.child()) # <class 'dolfin.
bc.apply(A1)
bc.child(
The error message I get is:
Traceback (most recent call last):
File "adapt_test.py", line 16, in <module>
A2 = assemble(
File "/home/
common_
File "/home/
self.
AttributeError: 'Form' object has no attribute '_compiled_form'
Thanks,
Simon
Changed in dolfin: | |
status: | Fix Committed → Fix Released |
Hi Simon,
The underlying cause of this issue, and most other similar issues with adapt, is that adapt here accepts Python objects but the new, adapted objects are created in the C++ layer. The Python versions typically carry more information than the C++ objects, and this additional information is then not available for the adapted objects.
A fix would be to essentially reimplement most of the adapt functions in the Python interface. Johan, could you comment on whether this is a good idea?