- changed title to Direct use of compute_form_data leads to FFC failures
Direct use of compute_form_data leads to FFC failures
Consider the following example:
from dolfin import *
mesh = UnitIntervalMesh(10)
space = FunctionSpace(mesh, "CG", 1)
c = Constant(1.0)
test = TestFunction(space)
F = Function(space)
form = inner(test, c * F) * dx
print form.form_data() # None
print form.compute_form_data() # The form data
Attempting to assemble the form leads to an error:
Traceback (most recent call last):
File "./ufl_bug_form_data", line 12, in <module>
v = assemble(form)
File "/usr/lib/python2.7/dist-packages/dolfin/fem/assembling.py", line 169, in assemble
common_cell=common_cell)
File "/usr/lib/python2.7/dist-packages/dolfin/fem/form.py", line 56, in __init__
common_cell)
File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py", line 66, in mpi_jit
return local_jit(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/dolfin/compilemodules/jit.py", line 154, in jit
return jit_compile(form, parameters=p, common_cell=common_cell)
File "/usr/lib/python2.7/dist-packages/ffc/jitcompiler.py", line 77, in jit
return jit_form(ufl_object, parameters, common_cell)
File "/usr/lib/python2.7/dist-packages/ffc/jitcompiler.py", line 159, in jit_form
element_mapping=element_mapping)
File "/usr/lib/python2.7/dist-packages/ufl/form.py", line 127, in compute_form_data
element_mapping=element_mapping)
File "/usr/lib/python2.7/dist-packages/ufl/algorithms/formdata.py", line 72, in validate
"Found non-matching element mappings in form data validation.")
File "/usr/lib/python2.7/dist-packages/ufl/assertions.py", line 37, in ufl_assert
if not condition: error(*message)
File "/usr/lib/python2.7/dist-packages/ufl/log.py", line 154, in error
raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Found non-matching element mappings in form data validation.
This seems to be caused by the two calls to compute_form_data having different arguments.
Comments (7)
-
reporter -
reporter - edited description
-
compute_form_data is not meant for direct use.
-
- changed status to wontfix
Not intended for users, and not fixable without major code rewriting and breaking the user interface.
-
reporter That was more-or-less my expected response. I have some obscure cases where I need direct access to form data, and it led to this opaque bug on updating my code for FEniCS 1.2.
-
You might get the same results if you make all your Constant and Expression objects fully defined from a ufl point of view by defining the cell of the Constant:
c = Constant(0.0, cell=mesh.ufl_cell())
and the element of the Expression
e = Expression("0.0", ufl_element=V)
as these are the things that ffc "fills in" later.
You could also call preprocess directly:
from ufl.algorithms.preprocess import preprocess form_data = preprocess(form)
although this is a similarly unintended use that may break later, you'll get around the ffc failures reported in this issue.
-
reporter Great, thanks. preprocess seems to return the information I need.
- Log in to comment