FEniCS / FEniCS/ffcx

Codimension 1 derivative index is wrong

Closed
#816 2 comments 0 reactions 2 assignees Claimed by @jpdean View on GitHub
bug
Dominant language
Python
Stars
192
Forks
45
Avg merge
1d 18h
Merged PRs (30d)
17

Description

MWE:
```python
import numpy as np
import ufl
from dolfinx import fem, mesh
from dolfinx.fem import assemble_scalar
from mpi4py import MPI

comm = MPI.COMM_WORLD

msh2d = mesh.create_unit_square(comm, 1, 1, mesh.CellType.quadrilateral)

fdim = 1
top_facets = mesh.locate_entities_boundary(msh2d, fdim, lambda x: np.isclose(x[1], 1.0))
mt = mesh.meshtags(msh2d, fdim, top_facets, 1.0)

msh1d, entity_map = mesh.create_submesh(msh2d, fdim, top_facets)[0:2]

entity_maps = [entity_map]

dx1 = ufl.Measure("dx", domain=msh1d)
ds2 = ufl.Measure("ds", domain=msh2d, subdomain_id=1, subdomain_data=mt)

V = fem.functionspace(msh1d, ("Lagrange", 1))

u = fem.Function(V)
u.interpolate(lambda x: x[0])
w = ufl.Dx(u, 1)
f1 = fem.form(w * dx1)
f2 = fem.form(w * ds2, entity_maps=entity_maps)
v1 = comm.allreduce(assemble_scalar(f1), op=MPI.SUM)
v2 = comm.allreduce(assemble_scalar(f2), op=MPI.SUM)

if comm.rank == 0:
print(f"v1: {v1}")
print(f"v2: {v2}")
print(f"diff: {abs(v1 - v2)}")
```
yielding:
```bash
v1: 0.0
v2: 0.9999999999999998
diff: 0.9999999999999998
```
and with `w = ufl.Dx(u, 0)`, one gets
```bash
v1: 1.0
v2: 0.0
diff: 1.0
```

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.