The failure also occurs when the vanished term is combined with other terms, e.g. (c*y).dx(0) + y. I found it after I changed physical parameters from Python floats to Constants, so that kernels are not recompiled for each parameter set. A velocity component of the form psi.dx(0), where psi does not depend on x, then caused this error.
Traceback (most recent call last):
File "bug.py", line 9, in <module>
Function(V).interpolate((c*y).dx(0)) # AssertionError
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "petsc4py/PETSc/Log.pyx", line 250, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 251, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/home/truec/firedrake/firedrake/function.py", line 382, in interpolate
return assemble(interp, tensor=self, ad_block_tag=ad_block_tag)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "petsc4py/PETSc/Log.pyx", line 250, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 251, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/home/truec/firedrake/firedrake/adjoint_utils/assembly.py", line 30, in wrapper
output = assemble(form, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/truec/firedrake/firedrake/assemble.py", line 151, in assemble
return get_assembler(expr, *args, **kwargs).assemble(**assemble_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/truec/firedrake/firedrake/assemble.py", line 433, in assemble
result = BaseFormAssembler.base_form_postorder_traversal(self._form, visitor, visited)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/truec/firedrake/firedrake/assemble.py", line 657, in base_form_postorder_traversal
visited[e] = visitor(e, *(visited[arg] for arg in operands))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/truec/firedrake/firedrake/assemble.py", line 429, in visitor
return self.base_form_assembly_visitor(e, t, bcs, *operands)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/truec/firedrake/firedrake/assemble.py", line 629, in base_form_assembly_visitor
return interpolator.assemble(tensor=tensor, bcs=bcs, mat_type=self._mat_type, sub_mat_type=self._sub_mat_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/truec/firedrake/firedrake/interpolation.py", line 364, in assemble
result = self._get_callable(tensor=tensor, bcs=bcs, mat_type=mat_type, sub_mat_type=sub_mat_type)()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/truec/firedrake/firedrake/interpolation.py", line 814, in _get_callable
loops.extend(_build_interpolation_callables(sub_expr, sub_op2_tensor, self.access, self.subset, bcs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<decorator-gen-31>", line 2, in _build_interpolation_callables
File "/home/truec/firedrake/firedrake/utils.py", line 172, in wrapper
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/home/truec/firedrake/firedrake/interpolation.py", line 1172, in _build_interpolation_callables
parloop = op2.ParLoop(*parloop_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/truec/firedrake/pyop2/parloop.py", line 706, in ParLoop
return LegacyParloop(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/truec/firedrake/pyop2/parloop.py", line 735, in LegacyParloop
global_knl = GlobalKernel(local_knl, global_knl_args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/truec/firedrake/pyop2/global_kernel.py", line 294, in __init__
for larg, garg in zip(local_kernel.arguments, arguments)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/truec/firedrake/pyop2/local_kernel.py", line 144, in arguments
assert len(self.accesses) == len(self.dtypes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
Describe the bug
Interpolating a UFL expression fails with a bare
AssertionErrorfrom PyOP2 if aConstantin the expression drops out when derivatives are expanded. For example,(c*y).dx(0)is identically zero, socdoes not appear in the generated kernel, but PyOP2 still appears to countcas a kernel argument. Assembling a form that contains the same expression works correctly.The failure also occurs when the vanished term is combined with other terms, e.g.
(c*y).dx(0) + y. I found it after I changed physical parameters from Python floats toConstants, so that kernels are not recompiled for each parameter set. A velocity component of the formpsi.dx(0), wherepsidoes not depend onx, then caused this error.Steps to Reproduce
python bug.py(serial). The same error occurs undermpiexecand on extruded meshes.Expected behavior
The interpolation gives a zero-valued
Function, as it does whenConstant(2.0)is replaced by the float2.0.Error message
Environment:
mainat de93479 (2026-09-16)pip list:pip list