Suppose I have some function defined on a 2d mesh, for example:
mesh = BoundaryMesh(SphereMesh(Point(0,0,0), 1, 0.1), 'exterior')
V = FunctionSpace(mesh, 'CG', 1)
f = Function(V)
(xs, ys, zs) = V.dofmap().tabulate_all_coordinates(mesh).reshape((-1,3)).T
thetas = np.arctan2(ys, xs)
f.vector()[:] = np.cos(thetas) * (1-zs**2)
How do I extract the function values along a specific path, say with theta = constant? The straightforward approach using e.g.
phi = np.linspace(-math.pi/2, math.pi/2, 100)
values = [ f(x, 0, z) for (x, z) in zip(np.cos(phi), np.sin(phi)) ]
doesn't work (even with parameters['allow_extrapolation'] = True
), I think because the spherical mesh does not describe a perfect circle. Is there a way to project my path on the mesh? Or some other way to do what I want?