Plotting von mises stress results for individual Named Selections in pydpf post

Hello All,

Thanks for Helping, I am facing an issue while developing a code to plot the von mises stress results for each Named selection separately. (Big model with 10 components) I would like to have a code in pydpf post such a way that for each Named selection (NS created for each components), von mises stress (should display only one NS at once, not in an assembly format) with max and min data should be plotted. As of now my code can read a .rst file and plot for each Named selection but in assembly level.

Tagged:

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 899
    100 Answers 500 Comments 250 Likes Second Anniversary
    ✭✭✭✭
  • Karthick RAJAN
    Karthick RAJAN Member Posts: 8
    Name Dropper First Comment
    **

    In the example provided by pyAnsys, there are 4 named selections, when plotted, Bar 1 is contoured and other bars are not contoured but all the bars are displayed. I need to display only Bar 1 contoured and not the other bars shaded grey. Is there any option to do the same?

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 899
    100 Answers 500 Comments 250 Likes Second Anniversary
    ✭✭✭✭

    Got it. I'm afraid that there is no direct solution. Possible workaround would be to grab the field of results and the corresponding mesh for the named selection, and plot this as if it was a separate result (ie, use the mesh of the named selection and not the mesh of the whole structure).

  • Karthick RAJAN
    Karthick RAJAN Member Posts: 8
    Name Dropper First Comment
    **

    Thank you @Pernelle Marone-Hitz for your quick response. I will explore the work around that you suggested.

    @Ayush Kumar do you have any suggestions on the same?

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 489
    100 Answers 250 Likes 100 Comments Second Anniversary
    ✭✭✭✭
    edited April 16

    @Karthick RAJAN the way suggested by @Pernelle Marone-Hitz is the only way, you need to create a mesh from the named selection. Here is a basic example, you can build upon this:

    from ansys.dpf import core as dpf
    from ansys.dpf.core.plotter import DpfPlotter
    
    dpf.start_local_server(ansys_path=r"C:\Program Files\ANSYS Inc\v241")
    
    rst = r"D:\...\file.rth"
    
    ds = dpf.DataSources(rst)
    model = dpf.Model(ds)
    
    # Get Mesh Scoping
    ns = dpf.operators.scoping.on_named_selection(requested_location="Elemental", named_selection_name="SEL_ELM")
    ns.inputs.data_sources.connect(ds)
    my_mesh_scoping = ns.outputs.mesh_scoping()
    
    # Get Mesh from Scoping
    mesh_ns = dpf.operators.mesh.from_scoping(scoping=my_mesh_scoping, mesh=model.metadata.meshed_region)
    mesh_ns_out = mesh_ns.outputs.mesh.get_data()
    
    # Temperature Field
    disp = dpf.operators.result.temperature(data_sources=ds, mesh_scoping=my_mesh_scoping)
    disp_f = disp.outputs.fields_container.get_data()[0]
    
    # Plot results
    plot = DpfPlotter()
    plot.add_field(disp_f, meshed_region=mesh_ns_out)
    plot.show_figure(show_axes=True)
    
  • Karthick RAJAN
    Karthick RAJAN Member Posts: 8
    Name Dropper First Comment
    **

    Hello @Ayush Kumar Really Thanks for your quick response. I could surely build from here the complete script, except few things,

    1. Each plot should return max and min value for each Named selection

    (plot.add_field(disp_f, meshed_region=mesh_ns_out,show_max=True, show_min=True)

    This doesn't plot the maximum and minimum in each plot

    1. Each plot should be saved in a 3d viewable file.

    (The user should be able to open the 3D interactive file whenever needed which has Max and Min value of each field along with selected Named selection scoping

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 489
    100 Answers 250 Likes 100 Comments Second Anniversary
    ✭✭✭✭

    @Karthick RAJAN

    1. The arguments show_max and show_min should normally do the trick, can you try it on a different model? Maybe something specific to the model is causing the issue.

    2. You can save the model and results as vtk files, those can be used in post-processing tools or 3D viewers, refer to the posts below:

    https://discuss.ansys.com/discussion/2124/usage-of-dpf-operator-vtk-to-fields

    https://discuss.ansys.com/discussion/1998/export-results-to-vtk-format