Skip to content

Edge case: fd.dx works but fd.par_loop fails when fd.dx subdomain_id is a single-element tuple #411

Description

@anilbeycorintis

fd.dx accepts int or tuple as seen below.

fd.dx(8, domain=mesh)
fd.dx((8,), domain=mesh)

When fd.dx is to be called from within fd.par_loop then the single element tuples fail.

Minimal reproducer:

import firedrake as fd

# Mesh with all cells labeled as subdomain id 8
base = fd.UnitSquareMesh(2, 2)
V0 = fd.FunctionSpace(base, "DG", 0)
mesh = fd.RelabeledMesh(base, [fd.Function(V0).assign(1.0)], [8])

f = fd.Function(fd.FunctionSpace(mesh, "DG", 0))

fd.dx(8, domain=mesh)  # OK
fd.dx((8,), domain=mesh)  # OK

# Works with int
fd.par_loop(
    kernel=("{[i]: 0 <= i < f.dofs}", "f[i] = 1.0"),
    measure=fd.dx(8),
    args={"f": (f, fd.RW)},
    is_loopy_kernel=True,
)

# Fails with single-element tuple
fd.par_loop(
    kernel=("{[i]: 0 <= i < f.dofs}", "f[i] = 1.0"),
    measure=fd.dx((8,)),
    args={"f": (f, fd.RW)},
    is_loopy_kernel=True,
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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