0

Need Help Generating VTK Files for Vector Visualization in ParaView

Hi everyone,

I'm having trouble generating VTK files for my vectors to visualize them in ParaView with Tough3. I haven't been able to create a proper VTK file, and I'm wondering if anyone has a Python script or code snippet that could help me with this.

If you have any suggestions or examples, I would greatly appreciate it!

Thank you!

3 replies

null
    • Keurfon_Luu
    • 1 mth ago
    • Reported - view

    Hi 

    You can do it with the development version of toughio, to install it, run in a console or iPython kernel:

    pip install https://github.com/keurfonluu/toughio/archive/devel.zip

    Then, assuming you have connection outputs in OUTPUT_CONNE.csv and a MESH file:

    import toughio
    
    mesh = toughio.read_input("MESH")
    output_conne = toughio.read_output("OUTPUT_CONNE.csv", time_steps=-1)  # e.g., last time step
    output = output_conne.to_element(mesh)

    The snippet above reads the MESH file, then output file, and finally approximates the flows at the element centers from the flow data at the interfaces.

    To generate a VTK with only the approximate flow outputs, we can use PyVista:

    import numpy as np
    import pyvista as pv
    
    points = np.array([v["center"] for v in mesh["elements"].values()])
    grid = pv.PolyData(points)
    
    for k, v in output.data.items():
        grid[k] = v
    
    grid.save("OUTPUT_CONNE.vtk")

    This code snippet uses the centers of the elements to generate a cloud of points, and then associates the approximated data points to the vertices.

    Note that this requires a version of toughio that is still in development and which will be released whenever it's ready.

      • Associate Research Fellow
      • plussss190
      • 1 mth ago
      • Reported - view

      Hi ,
      I tried your instruction but seems that output_conne don't have attribute 'to_element'

      Please help me check my file

      Thank you!

      • Keurfon_Luu
      • 1 mth ago
      • Reported - view

       As I mentioned in my previous post, you need to install the current development version of toughio from GitHub:

      pip install https://github.com/keurfonluu/toughio/archive/devel.zip
      

      I would recommend installing it in a separate environment as this version is still in development and is expected to make breaking changes.

Content aside

  • 1 mth agoLast active
  • 3Replies
  • 45Views
  • 3 Following