streamlines using highly nonuniform vector field
See original GitHub issueUpdates
After I set the max_time
to 10
, which is the default Maximum Streamline Length
in Paraview, I can reproduce the Paraview results.
The default value max_time=None
might not play well with certain data. In my case, the magnitude of the vector field varies greatly. Then, the default length figured out by the following code does not work well:
if max_time is None:
max_velocity = self.get_data_range()[-1]
max_time = 4.0 * self.GetLength() / max_velocity
I’m about to close this issue. But still, the usage of the parameter MaximumPropagation
might be improved, like I discussed in my own reply below.
Describe the bug, what’s wrong, and what you expect:
streamlines
using highly nonuniform vector field do not reproduce Paraview results.
I guess it could just be a parameter issue, but I haven’t found the cause.
To Reproduce
Please include a code snippet to reproduce the bug in the block below:
Input data (sorry for its nontrivial size ~ 10 MB; please remove the .zip extension which was added to be recognized by github issue system): bfield.vti.zip
import pyvista
bfield = pyvista.read('bfield.vti')
bfieldlines = bfield.streamlines(
pointa=(-23, 0, 0),
pointb=(-13, 0, 0),
n_points=100,
step_unit='cl',
initial_step_length=0.2,
min_step_length=0.01,
max_step_length=0.5,
max_steps=2000, # tried 20000, no difference
terminal_speed=1e-12,
max_error=1e-06,
max_time=None,
)
plotter = pyvista.Plotter()
plotter.add_mesh(bfieldlines.tube(radius=0.01), color='r')
plotter.add_mesh(pyvista.Sphere(center=(-18,0,0), radius=0.3)) # just for reference
plotter.add_axes()
plotter.camera_position = 'xz'
plotter.show()
Screenshots
Pyvista results using streamline
parameters taken from Paraview test:
Paraview results:
System Information: Please run the following code wherever you are experiencing the bug and paste the output below. This report helps us track down bugs and it is critical to addressing your bug:
# Get system info
import pyvista as pv
print(pv.Report())
--------------------------------------------------------------------------------
Date: Sun Mar 06 15:19:38 2022 EST
OS : Linux
CPU(s) : 4
Machine : x86_64
Architecture : 64bit
RAM : 15.5 GiB
Environment : Jupyter
File system : ext4
GPU Vendor : Intel
GPU Renderer : Mesa Intel(R) HD Graphics 4600 (HSW GT2)
GPU Version : 4.6 (Core Profile) Mesa 21.3.6
Python 3.8.12 (default, Oct 12 2021, 13:49:34) [GCC 7.5.0]
pyvista : 0.34.dev0
vtk : 9.0.3
numpy : 1.21.2
imageio : 2.9.0
appdirs : 1.4.4
scooby : 0.5.11
matplotlib : 3.5.1
PyQt5 : 5.9.2
IPython : 7.31.1
colorcet : 3.0.0
cmocean : 2.0
ipyvtklink : 0.2.2
scipy : 1.8.0
itkwidgets : 0.32.1
tqdm : 4.62.3
meshio : 5.3.2
Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904
for Intel(R) 64 architecture applications
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (12 by maintainers)
Top GitHub Comments
Maybe it’s not a bug of vtk, but an intended behavior.
LENGTH_UNIT
does mean physical arc length, correct?In that case, things are easy: Just rename
max_time
tomax_length
(ormax_physical_length
) and set the default to a reasonable value, for example, domain length along the longest dimension. This seems what Paraview does forMaximumPropagation
(note theBoundsDomain
; again, I’m not 100% sure as I don’t really know Paraview internals).The vtk default value, like you pointed earlier, is simply
1.0
. Perhaps in raw vtk, the user is always expected to setMaximumPropagation
manually?Hopefully, I’m not misleading here.
I’m +1 on making the default the maximum domain length (either in a Cartesian direction or across the diagonal).
Could we deprecate
max_time
and move it to the end of the parameter list?