Adapt does not return a valid FunctionSpace
Issue #322
resolved
Adapt does not return a valid FunctionSpace, reproduce with this code:
from dolfin import *
mesh = UnitSquareMesh(3,3)
Vx = VectorFunctionSpace(mesh, "CG", 1)
x = interpolate(Expression(("x[0]", "x[1]")), Vx)
mesh2 = adapt(mesh)
Vx2 = adapt(Vx, mesh2)
x2 = adapt(x, mesh2)
print type(Vx) # <class 'dolfin.functions.functionspace.VectorFunctionSpace'>
print type(Vx2) # <class 'dolfin.cpp.function.FunctionSpace'>
print Vx.ufl_element() # Ok
#print Vx2.ufl_element() # Fails, AttributeError: 'FunctionSpace' object has no attribute 'ufl_element'
xinterp = interpolate(x, Vx2) # Fails:
"""
*** Error: Unable to compute interpolation.
*** Reason: Illegal function space for interpolation, not a FunctionSpace (f_5).
*** Where: This error was encountered inside interpolation.py.
"""
Comments (7)
-
-
The type of the function space changes depending on how it is accessed
print x2.function_space().id()==Vx2.id() # True print type(x2.function_space()) # <class 'dolfin.functions.functionspace.FunctionSpaceBase'> print type(x2.function_space().ufl_element()) # <class 'ufl.finiteelement.mixedelement.VectorElement'>
As Mikael Mortensen points out,
x2
is afunction
butx2.parent().child()
is again aCoefficient
. Moreover,print Vx2.parent().child().ufl_element()
gives the expected answer althoughprint Vx2.ufl_element()
fails. I think something strange happens in the swig interface. -
- changed milestone to 1.6
-
- changed milestone to 1.7
-
-
- changed status to resolved
Resolved by d14be62
-
- removed milestone
Removing milestone: 1.7 (automated comment)
- Log in to comment
Furthermore,
x2
is not aCoefficient
, but a C++Function
. See this question