FEniCS / FEniCS/ufl

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

Open
#411 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
150
Forks
79
Avg merge
1d 16h
Merged PRs (30d)
10

Description

`fd.dx` accepts int or tuple as seen below.

```python
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:

```python
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,
)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.