FEniCS / FEniCS/dolfinx

Replace `dolfinx.fem.Constant` with a real function space

Open
#4,006 3 comments 1 reaction 0 assignees View on GitHub
proposal
Dominant language
C++
Stars
1.2k
Forks
261
Avg merge
1d 19h
Merged PRs (30d)
71

Description

Currently, DOLFINx uses two UFL concepts, namely `ufl.Constant` and `ufl.Coefficient`.
The `ufl.Constant` is tied to a domain (`dolfinx.mesh.Mesh`), even if it doesn't leverage any information from it.
The primal motivation for having a domain in `Constant` is differentiation (ref: https://github.com/FEniCS/ufl/issues/313#issuecomment-2757954998).
However, we don't use this in DOLFINx atm.

Pros with `dolfinx.fem.Constant`:
- Faster packing, as there is only one value per domain

Cons with `dolfinx.fem.Constant`:
- Extra input to kernels, i.e. extra code and special handling in `FFCx`
- Extra packing routines in DOLFINx, i.e extra code
- No clear instructions on ownership of the values in the constant. One is required to manually sync this value.

Pros with `dolfinx.fem.FunctionSpace(real_element)`
- Clear ownership of values
- Differentiability
- Less code in FFCx and DOLFINx for packing and passing data to kernels.
Cons:
- Slightly more packed data (real space is equivalent to packing a DG-0 function.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.