Skip to content

Differentiation of external operators via ufl.diff #456

Description

@a-latyshev

A user of dolfinx-externa-operator spotted that external operators are not differentiable via ufl.diff:

N = ExternalOperator(u, function_space=V)  # N(u; v')
dNdu = ufl.diff(N, u)
dNdu_expanded = expand_derivatives(dNdu) # error

Is there a specific reason why this is not supported by ufl.ExternalOperator? Perhaps @dham could assist us with this?

MWE:

import ufl
from ufl.core.external_operator import ExternalOperator
from ufl import Coefficient, Argument, derivative, dx, diff
from ufl.algorithms import expand_derivatives

from ufl.pullback import identity_pullback
from ufl.sobolevspace import H1

from utils import FiniteElement, LagrangeElement

domain = ufl.Mesh(LagrangeElement(ufl.triangle, 1, (2,)))
f1 = FiniteElement("Lagrange", ufl.triangle, 1, (), identity_pullback, H1)
V = ufl.FunctionSpace(domain, f1)

u = Coefficient(V)
N = ExternalOperator(u, function_space=V)  # N(u; v')
dNdu = ufl.diff(N, u)
dNdu_expanded = expand_derivatives(dNdu) # error

Error message:

ValueError: Missing differentiation handler for type ExternalOperator. Have you added a new type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions