Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Self-assignment via Cofunction.interpolate #3935

Open
jrmaddison opened this issue Dec 17, 2024 · 0 comments · May be fixed by #3939
Open

BUG: Self-assignment via Cofunction.interpolate #3935

jrmaddison opened this issue Dec 17, 2024 · 0 comments · May be fixed by #3939
Labels

Comments

@jrmaddison
Copy link
Contributor

jrmaddison commented Dec 17, 2024

Describe the bug
Cofunction.interpolate fails if used for self-assignment.

Steps to Reproduce

import firedrake as fd

mesh = fd.UnitIntervalMesh(1)
space = fd.FunctionSpace(mesh, "DG", 0)
u = fd.Cofunction(space.dual(), name="u")
u.interpolate(u)

leads to error

Traceback (most recent call last):
  File "/home/jmaddis2/test.py", line 6, in <module>
    u.interpolate(u)
  File "/home/jmaddis2/build/firedrake/firedrake/src/firedrake/firedrake/cofunction.py", line 317, in interpolate
    return firedrake.assemble(interp, tensor=self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 "/home/jmaddis2/build/firedrake/firedrake/src/firedrake/firedrake/adjoint_utils/assembly.py", line 30, in wrapper
    output = assemble(form, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jmaddis2/build/firedrake/firedrake/src/firedrake/firedrake/assemble.py", line 134, in assemble
    return get_assembler(expr, *args, **kwargs).assemble(tensor=tensor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jmaddis2/build/firedrake/firedrake/src/firedrake/firedrake/assemble.py", line 382, in assemble
    result = BaseFormAssembler.base_form_postorder_traversal(self._form, visitor, visited)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jmaddis2/build/firedrake/firedrake/src/firedrake/firedrake/assemble.py", line 605, in base_form_postorder_traversal
    visited[e] = visitor(e, *(visited[arg] for arg in operands))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jmaddis2/build/firedrake/firedrake/src/firedrake/firedrake/assemble.py", line 378, in visitor
    return self.base_form_assembly_visitor(e, t, *operands)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jmaddis2/build/firedrake/firedrake/src/firedrake/firedrake/assemble.py", line 545, in base_form_assembly_visitor
    return interpolator._interpolate(v, output=output, transpose=True, default_missing_val=default_missing_val)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 "/home/jmaddis2/build/firedrake/firedrake/src/firedrake/firedrake/interpolation.py", line 862, in _interpolate
    mul(x, out)
  File "petsc4py/PETSc/Mat.pyx", line 3760, in petsc4py.PETSc.Mat.multTranspose
petsc4py.PETSc.Error: error code 73
[0] MatMultTranspose() at /home/jmaddis2/build/firedrake/firedrake/src/petsc/src/mat/interface/matrix.c:2710
[0] Object is in wrong state
[0] x and y must be different vectors

Expected behavior
Operation should have no effect.

Environment:
Ubuntu 24.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant