当我添加像Plotting Glyphs (Vectors)这样的矢量箭头时,我已经绘制了 ABC 字段轮廓。我不知道如何为 3D 数据制作网格。
import pyvista as pv
import numpy as np
from numpy import mgrid
xmin = -800.
xmax = 800.
Lx = xmax-xmin
B0 = 1
k = 1
alpha = 2.0*np.pi*k/Lx
x, y, z = Lx*mgrid[0:1:51j, 0:1:51j, 0:1:51j]
Bx = B0*(np.sin(alpha*z) + np.cos(alpha*y))
By = B0*(np.sin(alpha*x) + np.cos(alpha*z))
Bz = B0*(np.sin(alpha*y) + np.cos(alpha*x))
B = Bx+By+Bz
grid = pv.StructuredGrid(x, y, z)
grid["ABC field 3D isocontour"] = B.flatten()
contours = grid.contour()
pv.set_plot_theme('document')
p = pv.Plotter()
p.add_mesh(contours)
#contours.plot(show_edges=True, show_grid=True, cpos="xy")
contours.plot(show_grid=True,screenshot='abc3d.png')
#p.show(screenshot='abc3d.png')
结果: