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: FEniCS/ufl#313 (comment)).
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.
Currently, DOLFINx uses two UFL concepts, namely
ufl.Constantandufl.Coefficient.The
ufl.Constantis 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
Constantis differentiation (ref: FEniCS/ufl#313 (comment)).However, we don't use this in DOLFINx atm.
Pros with
dolfinx.fem.Constant:Cons with
dolfinx.fem.Constant:FFCxPros with
dolfinx.fem.FunctionSpace(real_element)Cons: