I am trying to use pyvista to plot the isosurfaces of some function. However, this function takes values in a circle, and hence between -pi and pi because the circle is parametrized by the angle. Therefore when the angle is close to pi there is a sudden jump to -pi, a discontinuity. When using the StructuredGrid.contour method, this causes those branch points to always appear on the graph, because it seems to be interpolating between said values of -pi and pi. Is there any way to avoid this?
EDIT: here's the program I'm running. Changing the value of angle changes the smooth part, but not the blocky artifact at the branch cut.
import numpy as np
import pyvista as pv
a = 2
b = 3
theta = 1
def toComplex(x, y, z):
z1 = 2*x + 2*y*1j
z2 = 2*z + (x*x + y*y + z*z - 1)*1j
z1 /= x*x + y*y + z*z + 1
z2 /= x*x + y*y + z*z + 1
return [z1, z2]
#%% Data
x, y, z = np.pi*np.mgrid[-2:2:101j, -2:2:101j, -2:2:101j]
complexPoint = toComplex(x, y, z)
argument = np.angle(complexPoint[0]**2 + complexPoint[1]**3)
vol = argument
grid = pv.StructuredGrid(x, y, z)
grid["vol"] = vol.flatten()
contours = grid.contour([theta])
#%% Visualization
pv.set_plot_theme('default')
p = pv.Plotter()
p.add_mesh(contours, scalars=contours.points[:, 2], show_scalar_bar=False)
p.show(interactive_update=False)