question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

streamlines using highly nonuniform vector field

See original GitHub issue

Updates

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: demo-pyvista

Paraview results: demo-paraview


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:open
  • Created 2 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
liangwang0734commented, Mar 7, 2022

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 to max_length (or max_physical_length) and set the default to a reasonable value, for example, domain length along the longest dimension. This seems what Paraview does for MaximumPropagation (note the BoundsDomain; 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 set MaximumPropagation manually?

Hopefully, I’m not misleading here.

1reaction
MatthewFlammcommented, Mar 9, 2022

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Evenly Spaced Streamlines for Surfaces: An Image-Based ...
We introduce a novel, automatic streamline seeding algorithm for vector fields defined on surfaces in 3D space. The algorithm generates evenly spaced ...
Read more >
Chapter 18: Field flows - NCAR Graphics
The field flow utilities, Vectors and Streamlines, allow you to create plots representing two-dimensional field flows in a variety of styles, given arrays ......
Read more >
streamlines with figures
The elegant hand-designed streamline drawings in physics texts (for. example in Figure 1a) provide ample inspiration for vector field. illustrations.
Read more >
On the effect of curved streamlines on the accuracy of PIV ...
The results reveal that second-order accurate vector fields suffer from a biased shift vector length depending on the streamline's curvature and ...
Read more >
Coherent Streamline Generation for 2-D Vector Fields
Abstract: Visualizing 2-D vector fields using streamlines is one popular flow ... Supported by the National High-Tech Research and.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found