Pointwise evaluation in the context of Empirical Cubature Methods

Pointwise evaluation of functions and UFL expressions in fenicsx

I would like to know what the best (computational efficient) methods
are to evaluate functions and UFL expressions for specific points.
The reason for this post is that I did not find a (straightforward) solution in other posts that would cover the following case: Evaluate a function (or UFL expression) for a subset of integration points chosen among the integration points of the (full) FE mesh.

Context: This kind of operation is necessary in Empirical Cubature Methods(ECM).

Existing methods


As described in the dolfinx-tutorial one can use the eval method of a function given points and the cells containing those points.
In another post in this forum @dokken commented that this might not be the most performant approach.


Using dolfinx.fem.Expression allows to evaluate an UFL expression at a set of pre-defined points on the reference cell.
After definition of the dolfinx.fem.Expression one would call its eval method to evaluate the expression in given cells.
In the context of ECM, this does not seem to help, because I would not want to evaluate at the same integration point(s) in each cell.


  1. What would be the best way to approach this?
  2. Would a solution involving dolfinx.fem.Expression make sense? (Given a mapping from integration point to cell containing this point, one could create several expressions … up to N expressions if N is the number of integration points.)