streamlines3.py 658 B

123456789101112131415161718192021
  1. """Draw streamlines for the cavity case from OpenFOAM tutorial"""
  2. from vedo import *
  3. # Load an UnStructuredGrid
  4. ugrid = UnstructuredGrid(dataurl+"cavity.vtk").alpha(0.1)
  5. # Make a grid of points to probe as type Mesh
  6. probe = Grid(s=[0.1,0.01], res=[20,4], c='k')
  7. probe.rotate_x(90).pos(0.05,0.08,0.005)
  8. # Compute stream lines with Runge-Kutta4, return a Mesh
  9. ugrid.pointdata.select('U') # select active vector
  10. print(ugrid)
  11. coords = ugrid.vertices
  12. vects = ugrid.pointdata['U']/200
  13. arrows = Arrows(coords-vects, coords+vects, c='jet_r') # use colormap
  14. stream = ugrid.compute_streamlines(probe)
  15. show(stream, arrows, ugrid, probe, __doc__, axes=5).close()