Function evaluation on a grid
Hi all,
I am trying to calculate a 3D Function f on a large set of points, say a uniform cubic grid. Besides, the cubic grid points do not coincide with the mesh vertices where the Function f is defined. For example:
from dolfin import *
mesh1 = Mesh( meshfile) # A uniform mesh
V1 = FunctionSpace(
f = Function(V1)
f = ... # Construct f (e.g. by solving a PDE based on mesh1)
mesh2 = UnitCube(
Now I want to calculate the values of f at all vertices of mesh2.
I know that I can either use interpolate function:
V2 = FunctionSpace(
f2 = interpolate(f, V2)
Then f2.vector().array() gives me those values.
Or I can loop all vertices of mesh2 explicitly, and at each step invoke f(x, y, z) to calculate at that vertex.
The problem is that both these two methods are very very costly, and the interpolate method is even more time consuming than the explicit loop. Does anybody know if there is a more efficient way to do this job?
Thanks a lot,
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 Yi Jiang for more information if necessary.