Skip to content

Replace dolfinx.fem.Constant with a real function space #4006

@jorgensd

Description

@jorgensd

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions