I want to create a plot like this: Where the mesh not associated with the results is translucent or trans parent.
All I can get with DPFPlotter is this:
It should not be so difficult to plot results scoped to a named selection
@Jim Kosloski You will need to add the other mesh as a separate object, then set the opacity. This method however will get one layer of elements attached to the nodes as opaque. Not sure if we can get rid of that as well.
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\v252") rst = r"D:\…\file.rst" ds = dpf.DataSources(rst) model = dpf.Model(ds) mesh = model.metadata.meshed_region # Get Mesh Scoping ns = dpf.operators.scoping.on_named_selection(named_selection_name="FACES") 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() # Displacement Field disp = dpf.operators.result.displacement_X(data_sources=ds, mesh_scoping=my_mesh_scoping) disp_f = disp.outputs.fields_container.get_data()[0] # Plot results plot = DpfPlotter() plot.add_mesh(mesh, opacity=0.3) plot.add_field(disp_f, meshed_region=mesh_ns_out) plot.show_figure(show_axes=True)
@Jim Kosloski
Another idea is to create shell elements from the nodes and plot results on that meshed region. Add the original mesh with the opacity argument.
Hello @Jim Kosloski, Here is an example of how to do what you want using the plotter and some necessary manipulations to actually get the meshed support you want to plot results on if the named selection is for a boundary. You need to create the mesh for the boundary faces as it does not exist in the original mesh, resulting in what Ayush showed above where elements connected to the nodes of interest are kept.
import ansys.dpf.core as dpf from ansys.dpf.core import examples from ansys.dpf.core.plotter import DpfPlotter #Load your data into a DPF model model = dpf.Model(examples.download_all_kinds_of_complexity()) #Select your named selection of interest print(model.metadata.available_named_selections) named_selection_name = model.metadata.available_named_selections[2] ns = dpf.operators.scoping.on_named_selection( named_selection_name=named_selection_name, data_sources=model, requested_location=dpf.locations.nodal, ).eval() print(ns) #Extract the result on the named selection displacement = dpf.operators.result.displacement( data_sources=model, mesh_scoping=ns, ).eval() #Get the skin mesh for the named selection skin_mesh_ns = dpf.operators.mesh.skin( mesh=model.metadata.meshed_region, mesh_scoping=ns, ).eval() #Instantiate the plotter plt = DpfPlotter() #Add the global mesh to the scene with opacity plt.add_mesh(model.metadata.meshed_region, opacity=0.5) #Add the result with the associated skin mesh with no opacity plt.add_field(displacement[0], meshed_region=skin_mesh_ns, opacity=1.0) #Show the scene plt.show_figure()
This will result in: