how to control contour in PyDPF plot

Pavel
Pavel Member Posts: 9
5 Likes Name Dropper First Answer Photogenic
**
edited June 2023 in Structures

https://dpf.docs.pyansys.com/examples has quite some useful example but I couldn't find anythin on how to manipulate the contour. For example banded/smooth, number of bands, their colors, min and max limits, position of the legend on screen. How can I do those things? Especially min,max is pretty important for any relevancy of created plots.

Tagged:

Best Answer

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 467
    100 Answers 250 Likes 100 Comments Second Anniversary
    ✭✭✭✭
    edited January 2023 Answer ✓

    Hi @Pavel,

    AsDpfPlotter is a wrapper for pyvista.Plotter you can pass on the following arguments from PyVista Method Plotter.add_scalar_bar directly toDpf.Plotter.add_mesh or DpfPlotter.add_field

            title='',
            mapper=None,
            n_labels=5,
            italic=False,
            bold=False,
            title_font_size=None,
            label_font_size=None,
            color=None,
            font_family=None,
            shadow=False,
            width=None,
            height=None,
            position_x=None,
            position_y=None,
            vertical=None,
            interactive=None,
            fmt=None,
            use_opacity=True,
            outline=False,
            nan_annotation=False,
            below_label=None,
            above_label=None,
            background_color=None,
            n_colors=None,
            fill=False,
            render=False,
            theme=None,
    

    For a detailed documentation on the arguments please refer to Plotter.add_scalar_barhelp document.

    Example:

    sargs = dict(title="Legend", fmt="%.2e", title_font_size=30, label_font_size=20, n_labels=10)
    plot.add_field(
        field_norm_stress,
        meshed_region=mesh_set,
        show_max=True,
        show_min=True,
        label_text_size=15,
        label_point_size=5,
        scalar_bar_args=sargs
    )
    

    There isn't any specific example for this PyDPF documentation but a few of these arguments have also been used to modify the legend in the LS-Dyna transient example - https://dpf.docs.pyansys.com/examples/01-transient_analyses/02-lsdyna_operators.html

Answers

  • Pavel
    Pavel Member Posts: 9
    5 Likes Name Dropper First Answer Photogenic
    **

    @Ayush Kumar Thank you, that's helpful! I was trying to dig through PyVista documentation myself but I got only so far. Your example helps!

    Btw. I was testing PyDPF recently and combination get data+plot to file wasn't any faster than evaluating Mechanical result objects and saving them to file using ACT (PyDPF being about 2/3 of Mechanical speed). Partly because of this we might not use it as much although I'll keep it in back of the head in some specific cases (e.g. making automatic plots on HPC after solve in batch mode).

  • Pierre Thieffry
    Pierre Thieffry Member, Moderator, Employee Posts: 107
    25 Answers Second Anniversary 10 Comments 25 Likes
    ✭✭✭✭

    @Pavel that's an interesting observation on DPF efficiency that I my not have expected. If you get a chance, can you share some more data to me directly so we can investigate?

    Thanks

    Pierre

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

    Hi @Pavel , Thanks for the feedback, few pointers on increasing efficiency while working with DPF:

    1. Work with Model class - it uses streams behind the scenes.
    2. Try to avoid fetching fields / field containers data as much as possible and work with connecting operators in your workflow. Fetch data only at the end of your workflow.
    3. Looping over data is the most time consuming step in a DPF code, so make sure you get rid of all the loops (unless of course absolutely necessary) and find alternatives.

    But as Pierre mentioned please feel free to share the example, we will investigate further.

    Regards

    Ayush

  • Pavel
    Pavel Member Posts: 9
    5 Likes Name Dropper First Answer Photogenic
    **

    Hi @Pierre Thieffry , I'll see what I can do. It was a mid size/larger model, maybe 10-15 GB rth file. Maybe it performance penalty was on plotting, not on data collection.

    @Ayush Kumar Thanks for the tips!

    Right now it's not hot topic but next time we try to use PyDPF I'll get back to this thread and use Ayush's tips or contact you directly.