I want to use FEniCS to evaluate an expression (f below) at a particular argument value. The below works (2018.1) but is ugly, and I think I’m missing something.
from fenics import *
from ufl import replace
mesh = RectangleMesh(Point(0,0), Point(1,1) ,10,10)
P = FiniteElement("Lagrange", mesh.ufl_cell(),1)
c = Function(FunctionSpace(mesh,P))
f = c**2
f_at_1 = replace(f,{c:1})
print(f_at_1(0))
returns ‘1’ as expected.