How to get nemrical solution value for a given point?

Hey guys.

Suppose I have an interval mesh from (0,1) and u is the solution created on the mesh. I need to get the value on a point, such as on 0.25 in (0,1) of the solution u. I find some functions such as get_local, array() (which seems to be no longer supported)

I am using fenics2018 version. Is there any simply way to do it? Any help is appreciated.

If you are using dolfin version 2018.1.0, then

u = Function(V)
print(u.vector().get_local())

is supported.
If your point does not match a mesh vertex, you need to call the function eval function, i.e.
print(u(Point(0.25))) to get the solution at that point.

1 Like

Thank you very much. I hope you are having a great day.

@dokken, what about the case if many points need to be evaluated, not only one point? For example, I am interested in evaluating u at all Gauss points, saying that I already obtained their coordinates.

I think one way you could try is to use iterations in code “print(u(Point(i)))”

2 Likes

Does anyone know how to do this in dolfinx?

Maybe this discussion would help