### Interpolate solution in a point that is not a vertex

212
views
0
10 months ago by
I have compute the solution of the elastic acoustic wave equation in a 2D domain using P1 basis. I would like to get the (interpolated) value of the solution in a point x_p that does not coincide with a vertex. How can I do that? I don't know if there exist some authomatized options to (1) find to which triangle to point x_p belongs to, (2) find the 3 vertices that belong to that triangle, (3) interpolate the solutions at those vertices to get the solution in x_p.

Community: FEniCS Project

4
10 months ago by
Can you simply try

P = Point(np.array((0.0, 1.0))
value = MySolution(P)
print value​

Let me know if it doesn't work.

Yes, thank you. I thought it was much more complicated than this!! Especially because I am solving the system for a variable (acceleration), but I am interested in another value (displacement) that I derive from it (see below). I thought that because of this projection I had to do some tricky workaround... even better like this :)

# Solve system for acceleration
solve(A, a1.vector(), b)

# Newmark method to update displacement and velocity
u1 = u0 + dt*v0 + pow(dt,2)*((0.5-beta_)*a0 + beta_*a1)
v1 = v0 + dt*((1-gamma_)*a0 + gamma_*a1)

# Remark: u1 is a function of the trial func -- you need to project onto V
u1_proj.vector()[:] = project(u1, V).vector() ​
written 10 months ago by caterinabig