Open APaganini opened 4 weeks ago
The error with assemble(0*dx(domain=mesh))
occurs because the ufl.algorithms.map_integrands
does not map integrals for Zero
as coded at this line. I am unsure if the correct approach is also to map the Zero
integrand. @dham any thoughts?
I don't necessarily think that this is a UFL problem. It looks like we basically just preprocess the form to give us an "empty" form so things like form.ufl_domains()
gives us back an empty tuple, hence the IndexError
. I think a reasonable fix would be to modify assemble.py
so it can deal with empty forms.
Describe the bug firedrake.assemble does not work correctly on zero forms with constant scalar values (and in one case it even throws an
IndexError
Steps to Reproduce Run the following
Error message Expect 1, got 1.0000000000000002 Expect nan, got nan
print("Expect 0, got ", assemble(0dx(domain=mesh)))
File "petsc4py/PETSc/Log.pyx", line 188, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 189, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/Users/admp1/Documents/FIREDRAKE/firedrake/src/firedrake/firedrake/adjoint_utils/assembly.py", line 30, in wrapper
output = assemble(form, args, *kwargs)
File "/Users/admp1/Documents/FIREDRAKE/firedrake/src/firedrake/firedrake/assemble.py", line 132, in assemble
return get_assembler(expr, args, **kwargs).assemble(tensor=tensor)
File "/Users/admp1/Documents/FIREDRAKE/firedrake/src/firedrake/firedrake/assemble.py", line 969, in assemble
tensor = self.allocate()
File "/Users/admp1/Documents/FIREDRAKE/firedrake/src/firedrake/firedrake/assemble.py", line 1115, in allocate
comm=self._form.ufl_domains()[0]._comm
Expect nan, got 0.0
Expect nan, got 0.0
Expect 0, got 0.0 Traceback (most recent call last): File "/Users/admp1/Documents/bug_assemble.py", line 10, inIndexError: tuple index out of range
Environment: