How to plot result on cut mesh using PyDPF



I would like to plot a one side of a volume geometry, for which I have nodal results, and would like to cut the geometry with specific plane.

I have tried the mesh_plan_clip operator but as soon as I use it, the output mesh is cannot really plot the results.

I have tried to create a possible solution with the PyVista and clipping tool, without any success.

Can you please let me know how I can plot it outside of mechanical and still use sections.

or is it a limitation of PyDPF at the moment?



  • kanchan_cadfem
    kanchan_cadfem Member Posts: 18
    First Anniversary First Comment 5 Likes First Answer

    @Ayush Kumar, any comments on this?

    clipping volumes and plotting with PyDPF pr PyVista?

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 419
    5 Likes First Anniversary Ansys Employee Solution Developer Community of Practice Member
    edited May 2023

    @kanchan_cadfem I have never tried with PyVista, but the example below looks promising. You need to convert the DPF data to PyVista format:

    If you are facing issues with mesh_plan_clip please file an issue on GitHub. The operator is supposed to do exactly this.

  • Rajesh Meena
    Rajesh Meena Moderator, Employee Posts: 78
    First Anniversary Solution Developer Community of Practice Member Ansys Employee 5 Likes

    @kanchan_cadfem @Ayush Kumar

    I just used it with PYDPF. The hack for now is that you need to plot the mesh with field before you use section cut.

    import pyvista
    from ansys.dpf import core as dpf
    rFile = "/path_to_rst/file.rst"
    pyvista.global_theme.cmap = 'jet'
    my_data_sources = dpf.DataSources(rFile)
    model = dpf.Model(my_data_sources)
    results = model.results
    displacements = results.displacement()
    fields = displacements.outputs.fields_container()
    mesh = model.metadata.meshed_region
    normal = (1, 1, 1)
    plane = pyvista.Plane(i_size=30, j_size=30, direction=normal)
    pv_mesh = mesh.grid
    clipped = pv_mesh.clip(normal=normal)
    p = pyvista.Plotter()
    p.add_mesh(clipped, show_edges=True)