How can we evaluate interpolated Expression at arbitrary points?

Hi all,
I have a question regarding interpolation. I want to evaluate Expression at some point in a domain.

import fenics as dl
T = 1
N = 100
mesh = dl.IntervalMesh(N, 0, T)
V = dl.FunctionSpace(mesh, ‘Lagrange’, 1)
m_true = dl.Expression(‘sin(x[0]*pi)’, degree = 5)
mtrue = dl.interpolate(m_true, V)

How can we evaluate “mtrue” at points that are not the vertex of the mesh (e.g., x = 0.123; the vertex is 0, 0.01, 0.02 …, 1.0)? I want to use “mtrue” not “m_true” because m_true is not given in the computation.

Hey,

mtrue is a function, therefore it can easily evaluated with

print(str( mtrue(dl.Point(0.123)) ))

Best Regards

Emanuel

Hi Emanuel,

Thank you so much. It works perfectly!