The Expression
approach should be modified as follows
class Delta(UserExpression):
def __init__(self, eps, **kwargs):
self.eps = eps
UserExpression.__init__(self, **kwargs)
def eval(self, values, x):
eps = self.eps
values[0] = eps/pi/(np.linalg.norm(x)**2 + eps**2)
values[1] = 0
values[2] = 0
def value_shape(self): return (3, )