You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from firedrake import *
from firedrake.adjoint import *
continue_annotation()
def test_solve_cofunction_rhs():
mesh = UnitSquareMesh(2, 2)
V = FunctionSpace(mesh, "CG", 1)
u = TrialFunction(V)
v = TestFunction(V)
a = inner(u, v) * dx
L = Cofunction(V.dual())
L.vector()[:] = 1.
w = Function(V)
solve(a == L, w)
Aw = assemble(action(a, w))
assert isinstance(Aw, Cofunction)
assert np.allclose(Aw.dat.data_ro, L.dat.data_ro)
test_solve_cofunction_rhs()
get_working_tape().visualise("tape.pdf")
Error message
File "/Users/ddolci/work/firedrake_main/src/ufl/ufl/formatting/ufl2unicode.py", line 351, in ufl2unicode
return expression2unicode(ufl.as_ufl(expression))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ddolci/work/firedrake_main/src/ufl/ufl/formatting/ufl2unicode.py", line 357, in expression2unicode
return map_expr_dag(rules, expression)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ddolci/work/firedrake_main/src/ufl/ufl/corealg/map_dag.py", line 34, in map_expr_dag
result, = map_expr_dags(function, [expression], compress=compress,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ddolci/work/firedrake_main/src/ufl/ufl/corealg/map_dag.py", line 100, in map_expr_dags
r = handlers[v._ufl_typecode_](v, *[vcache[u] for u in v.ufl_operands])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ddolci/work/firedrake_main/src/ufl/ufl/corealg/multifunction.py", line 99, in undefined
raise ValueError(f"No handler defined for {o._ufl_class_.__name__}.")
^^^^^^^^^^^^^
AttributeError: 'Cofunction' object has no attribute '_ufl_class_'
Environment:
OS: MacOs
Python version: 3.11.6
Additional Info
Fix in the upstream for ufl2unicode works properly for Cofunction.
The text was updated successfully, but these errors were encountered:
I don't think the fact that Cofunctions don't have a _ufl_class_ attribute is a bug as they are not Expr objects. The error you are observing is a consequence of BaseForm objects, such as Cofunction or FormSum, not having ufl2unicode support at the moment, as mentioned in the following issue firedrakeproject/ufl#43, so the error you are observing is expected.
Steps to Reproduce
Error message
Environment:
Additional Info
Fix in the upstream for ufl2unicode works properly for
Cofunction
.The text was updated successfully, but these errors were encountered: