This question has probably been asked before, but I would appreciate some guidance on how to solve it in the following concrete, simple setting:
Consider a regular, low-resolution mesh on the unit square and a CG-1 finite-element space based on it. To fix ideas, let us define the mesh and the finite-element space like so:
from dolfin import *
resolution_param = 3
mesh = UnitSquareMesh(resolution_param, resolution_param)
num_mesh_vertices = (resolution_param + 1) ** 2
mesh_vertex_coords = mesh.coordinates()
V = FunctionSpace(mesh, 'CG', 1)
Consider also the following function:
f = Expression("x[0] - x[1]")
f_proj = project(f, V)
f_proj_arr = f_proj.vector().array()
THE QUESTION
The value f_proj_arr[j]
is not the value of f
at mesh_vertex_coords[j]
.
How can I construct a new array f_proj_new_arr
out of f_proj_arr
such that f_proj_new_arr[j]
is the value of f
at mesh_vertex_coords[j]
?