DirichletBC.values() not of type ufl.classes.Expr
Issue #1034
new
(From https://www.allanswered.com/post/erarr/2018-1-dirichletbc-value-cannot-be-used-to-instantiate-another-dirichletbc-object/.) The following code fails in FEniCS 2018.1
from dolfin import *
import ufl
mesh = UnitSquareMesh(10, 10)
V = FunctionSpace(mesh, "CG", 1)
g = Expression("2 * x[0]", degree=1)
bc = DirichletBC(V, g, "on_boundary")
print(isinstance(g, ufl.classes.Expr))
print(isinstance(bc.value(), ufl.classes.Expr))
DirichletBC(
FunctionSpace(bc.function_space()),
bc.value(),
bc.sub_domain
)
with the output
True
False
Traceback (most recent call last):
File "i.py", line 16, in <module>
bc.sub_domain
File "/usr/lib/python3/dist-packages/dolfin/fem/dirichletbc.py", line 78, in __init__
expr = Constant(args[1])
File "/usr/lib/python3/dist-packages/dolfin/function/constant.py", line 68, in __init__
floats = list(map(float, array.flat))
TypeError: float() argument must be a string or a number, not 'dolfin.cpp.function.GenericFunction'
Apparently, bc.values() isn't of the correct type (ufl.classes.Expr) anymore. Any hints on how to work around this?