I would like to plot result having deformed mesh and undeformed mesh after getting results from PyDPF. The plot should looks something similar to Mechanical, like below.
from ansys.dpf import core as dpf from ansys.dpf.core import examples from ansys.dpf.core.plotter import DpfPlotter #Here we create a Model and request its mesh model = dpf.Model(examples.find_msup_transient()) mesh_set = model.metadata.meshed_region #Then we need to request the displacement for two different time steps displacement_operator = model.results.displacement() displacement_operator.inputs.time_scoping.connect([2, 15]) displacement_set2 = displacement_operator.outputs.fields_container()[0] displacement_set15 = displacement_operator.outputs.fields_container()[1] #scaling by 100 factor to see significant difference between deformed and undeformed mesh scaled_op = dpf.operators.math.scale( field=displacement_set2, ponderation=100.0 ) #Creaet a new mesh for undeformed state mesh_set_undeformed = mesh_set.deep_copy() #User Dpf plotter for adding deformed results and undeformed mesh pl = DpfPlotter() pl.add_field(displacement_set2, mesh_set2,deform_by=scaled_op.outputs.field()) #one can use other arguments from pyvista library as well. pl.add_mesh(mesh_set15,opacity=1.0,show_edges=False,hidden_line_removal=True,style="wireframe") pl.show_figure(show_axes=True)
The above script can be referred to plot result with undeformed mesh. The resulting plot look like below: You can play with transparency of undeformed mesh to make it closer to Mechanical view.