streamlines4.py 655 B

1234567891011121314151617181920212223
  1. from vedo import *
  2. f = download('https://github.com/marcomusy/vedo/files/4602353/domain_unstruct.vtk.gz')
  3. ug = UnstructuredGrid(gunzip(f))
  4. # make up some custom vector field
  5. pts = ug.vertices
  6. x,y,z = pts.T
  7. windx = np.ones_like(x)*4
  8. windy = np.exp(-(x+18)**2/100) * np.sign(y)/(abs(y)+8)*20
  9. wind = np.c_[windx, windy, np.zeros_like(windy)]
  10. ug.pointdata["wind"] = wind # add the vectors to the mesh
  11. ars = Arrows(pts-wind/10, pts+wind/10, c='hot')
  12. ypr = np.linspace(-15,15, num=25)
  13. xpr = np.zeros_like(ypr)-40
  14. probes = np.c_[xpr, ypr]
  15. lines = ug.compute_streamlines(probes, max_propagation=80).c("red4")
  16. show(ars, lines, zoom=8, bg2='lb').close()