If you know what point in the reference element you want to evaluate your function at, you can use dolfinx.fem.Expression, consider the mwe
from mpi4py import MPI
import dolfinx
import numpy as np
import ufl
def eval_trial_function(V, reference_points):
mesh = V.mesh
u = ufl.TrialFunction(V)
expr = dolfinx.fem.Expression(u, reference_points)
num_cells = mesh.topology.index_map(mesh.topology.dim).size_local
basis_functions = expr.eval(mesh, np.arange(num_cells, dtype=np.int32)).reshape(num_cells, len(reference_points), -1)
for i, functions in enumerate(basis_functions):
for j, point in enumerate(reference_points):
print(f"Cell {i}: Point {point} {functions[j, :]}")
mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 1, 1, dolfinx.cpp.mesh.CellType.triangle)
V = dolfinx.fem.functionspace(mesh, ("N1curl", 1))
# Points in reference element
points = np.array([[0.0, 0.0], [1.0, 0.0]])
eval_trial_function(V, points)
yielding:
Cell 0: Point [0. 0.] [ 0. 0. 1. 0. 1. -1.]
Cell 0: Point [1. 0.] [0. 0. 1. 1. 0. 0.]
Cell 1: Point [0. 0.] [-0. 1. -1. -0. 0. 1.]
Cell 1: Point [1. 0.] [-1. 0. 0. -0. 0. 1.]