Thanks @dokken
Just for some else if they get stuck. Evaluate all only returns the values at non zeros. So instead I interate through all using evaluate_basis_derivates, returning 0 if we are not in the support.
def basis_func_derv_i(i,x,n):
cell_index = tree.compute_first_entity_collision(Point(*x))
cell_global_dofs = V.dofmap().cell_dofs(cell_index)
for local_dof in range(0,len(cell_global_dofs)):
if(i==cell_global_dofs[local_dof]):
cell = Cell(spatial_mesh, cell_index)
values = np.array([0,])
return V.element().evaluate_basis_derivatives(local_dof,n,x,cell.get_vertex_coordinates(),cell.orientation())
# If none of this cell's shape functions map to the i-th basis function,
# then the i-th basis function is zero at x.
return 0.0
order =1
first_derv = lambda i,x:basis_func_derv_i(i,x,order)
for i in range(0,V.dim()):
list_of_basis_functions_der += [(lambda i: lambda x : first_derv(i,x))(i),]
# Try evaluating all basis functions at a point:
for i in range(0,V.dim()):
if(list_of_basis_functions_der[i](point)!=0.0):
print((i,list_of_basis_functions_der[i](point)[0]))