wrong interpolation of data in 3D
Hi,
I am trying to get an interpolation function f (in3D) at all vertices of cells. I can extract all vertices of cells and then I assign the value to each vertex: If it's in a sphere of radius R, then I assign the value, say 3.91. If it's outside the sphere, then I assign the value 0. I got it running without the error message but then when I calculated the function value at points that are not vertices then it does not give me either 3.91 or 0. Am I doing something wrong here?
Here is a part of my code:
# Extract vertices of all cells, then I export these points and use another software to assign value for each point (say 3.91 for points #inside sphere, 0 for points outside)
coor = mesh.coordinates()
numpy.savetxt(
#I get the values at all vertices and then interpolate this to function f
qvalues2 = numpy.loadtxt(
V = FunctionSpace(mesh, "CG", 1)
f = Function(V)
f.vector()[:] = qvalues2
#then I read points (xp, yp) on z=0 plane and evaluate the funtion at these points
with open('xpdata.txt') as g:
xp = g.readlines()
print "xp[1]=", xp[1]
with open('ypdata.txt') as h:
yp = h.readlines()
print "yp[2]=", yp[2]
for i in range(len(xp)):
g_in[i] = f(xp[i],yp[i],0.0)
#Now when I plot g_i , it does not look like what it should be, i.e. constant(3.91) inside the circle R=50, and 0 outside.
Any help would be appreciated.
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Paul Scott for more information if necessary.