(plot_grid[0].ravel(), plot_grid[1].ravel(), np.zeros(plot_grid[0].size)))

# Bounding box tree etc for function evaluations
tree = geometry.BoundingBoxTree(mesh, 2)
points_2d = points[0:2, :]
cell_candidates = [
    geometry.compute_collisions_point(tree, xi) for xi in points.T
]
cells = [
    dolfinx.cpp.geometry.select_colliding_cells(mesh, cell_candidates[i],
                                                points.T[i], 1)[0]
    for i in range(len(cell_candidates))
]

# Evaluate scattered and incident fields at grid points
u_sca = u.eval(points.T, cells).reshape((Nx, Ny))
inc_field = incident(points_2d)
u_inc = inc_field.reshape((Nx, Ny))

# Sum to give total field
u_total = u_inc + u_sca
'''                     Plot field and save figure                          '''
plt.rc('font', family='serif', size=22)
fig = plt.figure(figsize=(10, 5))
ax = fig.gca()
plt.imshow(np.fliplr(np.real(u_total)).T,
           extent=[-dim_in_x / 2, dim_in_x / 2, -dim_in_y / 2, dim_in_y / 2],
           cmap=plt.cm.get_cmap('seismic'),
           interpolation='spline16')
x_start = -0.5 * (nx - 1) * (2 * rad_crys + gap)
y_start = -0.5 * (ny - 1) * (2 * rad_crys + gap)
points[1, in_circ] = radius + wave_len / 10
points[2, in_circ] = 0.

# Bounding box tree etc for function evaluations
tree = geometry.BoundingBoxTree(mesh, 2)
cell_candidates = [
    geometry.compute_collisions_point(tree, xi) for xi in points.T
]
cells = [
    dolfinx.cpp.geometry.select_colliding_cells(mesh, cell_candidates[i],
                                                points.T[i], 1)[0]
    for i in range(len(cell_candidates))
]

# Evaluate scattered and incident fields at grid points
u_sca_temp = u.eval(points.T, cells)
u_sca_temp[in_circ_2d] = 0.0  # Set field inside circle to zero
u_sca = u_sca_temp.reshape((Nx, Ny))  # Reshape
inc_field = incident(points_2d)
inc_field[in_circ_2d] = 0.0  # Set field inside circle to zero
u_inc = inc_field.reshape((Nx, Ny))

# Sum to give total field
u_total = u_inc + u_sca
'''                  Compare against analytical solution                    '''
# Uncomment to perform comparison, takes a few seconds to run
u_exact = sound_hard_circle(k0, radius, plot_grid)
diff = u_exact - u_total
error = np.linalg.norm(diff) / np.linalg.norm(u_exact)
print('Relative error = ', error)
'''                     Plot field and save figure                          '''