@@ -43,13 +43,24 @@ Plot a single mesh scoping
4343
4444Create a single |Scoping | and plot the targeted entities when applied to a single |MeshedRegion |.
4545
46+ First for a node scoping:
47+
4648.. jupyter-execute ::
4749
50+ # Create a scoping of the first 100 node IDs of the mesh
4851 node_scoping = dpf.Scoping(location=dpf.locations.nodal, ids=mesh_1.nodes.scoping.ids[0:100])
52+ # Plot the node scoping applied to the mesh, with nodes shown as red dots
4953 node_scoping.plot(mesh=mesh_1, color="red")
54+
55+ Then for an element scoping:
56+
57+ .. jupyter-execute ::
58+
59+ # Create a scoping of the first 100 elements IDs of the mesh
5060 element_scoping = dpf.Scoping(
5161 location=dpf.locations.elemental, ids=mesh_1.elements.scoping.ids[0:100]
5262 )
63+ # Plot the element scoping applied to the mesh, with elements shown in green
5364 element_scoping.plot(mesh=mesh_1, color="green")
5465
5566
@@ -61,30 +72,49 @@ and plot targeted entities of a |MeshedRegion|.
6172
6273.. jupyter-execute ::
6374
75+ # Create a scoping of the first 100 node IDs of the mesh
6476 node_scoping_1 = dpf.Scoping(location=dpf.locations.nodal, ids=mesh_1.nodes.scoping.ids[0:100])
77+ # Create a scoping of the 300th to 400th node IDs of the mesh
6578 node_scoping_2 = dpf.Scoping(
6679 location=dpf.locations.nodal, ids=mesh_1.nodes.scoping.ids[300:400]
6780 )
81+ # Create a ScopingsContainer
6882 node_sc = dpf.ScopingsContainer()
83+ # Add at least one label to the collection to identify entries
6984 node_sc.add_label(label="scoping", default_value=1)
85+ # Add the first node scoping to the collection
7086 node_sc.add_scoping(label_space={"scoping": 1}, scoping=node_scoping_1)
87+ # Add the second node scoping to the collection
7188 node_sc.add_scoping(label_space={"scoping": 2}, scoping=node_scoping_2)
89+ # Plot the scoping collection applied to the mesh
7290 node_sc.plot(mesh=mesh_1, show_mesh=True)
7391
7492Then plot the |ScopingsContainer | applied to a |MeshesContainer | with similarly labeled meshes.
7593
7694.. jupyter-execute ::
7795
96+ # Create a collection of meshes based on the initial mesh by splitting it by material
7897 meshes: dpf.MeshesContainer = ops.mesh.split_mesh(mesh=mesh_1, property="mat").eval()
79-
80- label_space = {"mat": 1, "body": 1}
98+ # Create a node scoping targeting the first 100 node IDs of the mesh for material 1
8199 node_scoping_3 = dpf.Scoping(
82- location=dpf.locations.nodal, ids=meshes.get_mesh(label_space).nodes.scoping.ids[0:100]
100+ location=dpf.locations.nodal,
101+ ids=meshes.get_mesh({"mat": 1, "body": 1}).nodes.scoping.ids[0:100],
102+ )
103+ # Create a node scoping targeting the first 100 node IDs of the mesh for material 2
104+ node_scoping_4 = dpf.Scoping(
105+ location=dpf.locations.nodal,
106+ ids=meshes.get_mesh({"mat": 2, "body": 2}).nodes.scoping.ids[0:100],
83107 )
108+ # Create a collection of scopings
84109 node_sc_2 = dpf.ScopingsContainer()
110+ # Add the appropriate labels to the collection
85111 node_sc_2.add_label(label="mat")
86112 node_sc_2.add_label(label="body")
87- node_sc_2.add_scoping(label_space=label_space, scoping=node_scoping_3)
113+ # Add the scoping associated to material 1
114+ node_sc_2.add_scoping(label_space={"mat": 1, "body": 1}, scoping=node_scoping_3)
115+ # Add the scoping associated to material 2
116+ node_sc_2.add_scoping(label_space={"mat": 2, "body": 2}, scoping=node_scoping_4)
117+ # Plot the collection of scopings applied to the collection of meshes
88118 node_sc_2.plot(mesh=meshes)
89119
90120Use DpfPlotter.add_scoping
@@ -94,14 +124,21 @@ We now use the |DpfPlotter| to add scopings applied to |MeshedRegion| to a scene
94124
95125.. jupyter-execute ::
96126
127+ # Create a node scoping for the first 100 node IDs of the mesh
97128 node_scoping = dpf.Scoping(location=dpf.locations.nodal, ids=mesh_1.nodes.scoping.ids[0:100])
129+ # Create an element scoping for the first 100 elements IDs of the mesh
98130 element_scoping = dpf.Scoping(
99131 location=dpf.locations.elemental, ids=mesh_1.elements.scoping.ids[0:100]
100132 )
101133
134+ # Import the DpfPlotter
102135 from ansys.dpf.core.plotter import DpfPlotter
103136
137+ # Instantiate a DpfPlotter
104138 plt = DpfPlotter()
139+ # Tell the plotter to also show the mesh associated with the first scoping
105140 plt.add_scoping(node_scoping, mesh_1, show_mesh=True, color="red")
141+ # Do not show the mesh for the second scoping as it is the same
106142 plt.add_scoping(element_scoping, mesh_1, color="green")
143+ # Show the resulting scene
107144 plt.show_figure()
0 commit comments