Skip to content

ufl >= 2024 and Constant having a domain. #313

@dr-robertk

Description

@dr-robertk

In dune-fem we have not been able to upgrade to ufl beyond 22.2.0 because of the Constant (now having a domain) and the domain check being enforced in domain.py:221: (join_domains).

In our case this is, for example, the case when a Constant representing the time step dt is used in two different forms.

I think this is also related to the discussion in #267.

The following code triggers the problem:

import basix.ufl
import ufl

# Bulk problem: u - tau laplace u = u_n + tau f.
# but only setting up right hand side forcing 'tau f'
#
bc_el = basix.ufl.element("Lagrange", "triangle", 1, shape=(2, ))
bdomain = ufl.Mesh(bc_el)

# issue here: constant defined on bulk domain
tau = ufl.Constant(bdomain)

bel = basix.ufl.element("Lagrange", "triangle", 1)
bV = ufl.FunctionSpace(bdomain, bel)
bL = tau*ufl.inner(ufl.Coefficient(bV), ufl.TestFunction(bV)) * ufl.dx

#############################################################

# Surface problem: w - tau laplace w = w_n + tau g
# but only setting up right hand side forcing 'tau g'
sc_el = basix.ufl.element("Lagrange", "triangle", 1, shape=(3, ))
sdomain = ufl.Mesh(sc_el)

# issue here: can't use constant from bulk problem - using 'sdomain' works
# tau = ufl.Constant(sdomain)

sel = basix.ufl.element("Lagrange", "triangle", 1)
sV = ufl.FunctionSpace(sdomain, sel)

# This line results in
# ValueError: Found domains with different geometric dimensions.
sL = tau*ufl.inner(ufl.Coefficient(sV), ufl.TestFunction(sV)) * ufl.dx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions