This section describes examples for:
Scoping to FE Entities (Elements and Nodes)
Pre-define a nodal named selection "Selection-2Nodes," with two nodes selected. Reload the property and set it as below:

The workflow below is an example of:
Use of the time_scoping pin and connected to the set number 5 read from Group 1.
Use of the mesh_scoping pin and connected to the named selection read from Group 2.
Total Deformation scoped on Time Step and Name Selection via Property Provider Pane
import mech_dpf
import Ans.DataProcessing as dpf
dataSource = dpf.DataSources(analysis.ResultFileName)
u = dpf.operators.result.displacement()
nrm = dpf.operators.math.norm_fc()
prop_val = this.GetCustomPropertyByPath("Group 1/Double Property 1").Value
timeScop = dpf.Scoping()
timeScop.Ids = [int(prop_val)]
u.inputs.time_scoping.Connect(timeScop)
u.inputs.data_sources.Connect(dataSource)
scoping_refs = this.GetCustomPropertyByPath("Group 2/Scoping Property/Named Selection").Value
mech_dpf.setExtAPI(ExtAPI)
nodes_loc = mech_dpf.GetNodeScopingByRefId(scoping_refs)
u.inputs.mesh_scoping.Connect(nodes_loc)
nrm.Connect(u)
dpf_workflow = dpf.Workflow()
dpf_workflow.Add(u)
dpf_workflow.Add(nrm)
dpf_workflow.SetOutputContour(nrm)
dpf_workflow.Record('wf_id', True)
this.WorkflowId = dpf_workflow.GetRecordedId()

Two helper methods, GetNodeScopingByRefId() and GetElementScopingByRefId() are provided in mech_dpf to create the corresponding nodal/elemental scoping with the connected nodes/elements from the selection.
Similarly, if the geometry scoping is defined by Geometry Selection, and several nodes are selected manually by using the node select tool in the Graphics Toolbar, in the above script, just replace the line:
nodes_val = this.GetCustomPropertyByPath("Group 2/Scoping Property/Named Selection").Valuewith:
nodes_val = this.GetCustomPropertyByPath("Group 2/Scoping Property/Geometry Selection").ValueScoping to Geometry (Faces, Bodies, etc.)
The same script in the above section can be used if a geometry is selected (faces, bodies, vertices, etc.) with the property set as shown below.

The workflow below is an example of getting all nodes belong to the selected faces and display the total deformation on these nodes.
Total Deformation Scoped on Time Step and Two Faces via Property Provider Pane
import mech_dpf
import Ans.DataProcessing as dpf
dataSource = dpf.DataSources(analysis.ResultFileName)
u = dpf.operators.result.displacement()
nrm = dpf.operators.math.norm_fc()
prop_val = this.GetCustomPropertyByPath("Group 1/Double Property 1").Value
timeScop = dpf.Scoping()
timeScop.Ids = [int(prop_val)]
u.inputs.time_scoping.Connect(timeScop)
u.inputs.data_sources.Connect(dataSource)
scoping_refs = this.GetCustomPropertyByPath("Group 2/Scoping Property/Geometry Selection").Value
mech_dpf.setExtAPI(ExtAPI)
nodes_loc = mech_dpf.GetNodeScopingByRefId(scoping_refs)
u.inputs.mesh_scoping.Connect(nodes_loc)
nrm.Connect(u)
dpf_workflow = dpf.Workflow()
dpf_workflow.Add(u)
dpf_workflow.Add(nrm)
dpf_workflow.SetOutputContour(nrm, dpf.enums.GFXContourType.GeomFaceScoping)
dpf_workflow.Record('wf_id', True)
this.WorkflowId = dpf_workflow.GetRecordedId()
Similarly, dpf.enums.GFXContourType.GeomFaceScoping is used to get a better contour display as discussed next.
Von Mises Stress with Different Scoping Representations
The below enum is introduced for a better contour result display in various scoping:
dpf.enums.GFXContourType.FENodalScoping
dpf.enums.GFXContourType.FEElementalScoping
dpf.enums.GFXContourType.FEElementalFaceScoping
dpf.enums.GFXContourType.GeomBodyScoping
dpf.enums.GFXContourType.GeomFaceScoping
dpf.enums.GFXContourType.GeomEdgeScoping
dpf.enums.GFXContourType.GeomVertexScoping
It can be set as a second parameter when calling the below method in the script:
dpf_workflow.SetOutputContour(to_elemental_op, dpf.enums.GFXContourType.FENodalScoping)
while the default scoping type is:
dpf.enums.GFXContourType.FENodalScoping
The workflow below is an example of displaying the Von Mises Stress on named selection with different scoping representations via Property Provider.
Von Mises Stress Scoped on Time Step and Named Selection via Property Provider Pane
import mech_dpf
import Ans.DataProcessing as dpf
dataSource = dpf.DataSources(analysis.ResultFileName)
s_eqv_op=dpf.operators.result.stress_von_mises()
prop_val = this.GetCustomPropertyByPath("Group 1/Double Property 1").Value
timeScop = dpf.Scoping()
timeScop.Ids = [int(prop_val)]
s_eqv_op.inputs.time_scoping.Connect(timeScop)
s_eqv_op.inputs.data_sources.Connect(dataSource)
scoping_refs = this.GetCustomPropertyByPath("Group 2/Scoping Property/Named Selection").Value
mech_dpf.setExtAPI(ExtAPI)
nodes_loc = mech_dpf.GetNodeScopingByRefId(scoping_refs)
s_eqv_op.inputs.mesh_scoping.Connect(nodes_loc)
dpf_workflow = dpf.Workflow()
dpf_workflow.Add(s_eqv_op)
dpf_workflow.SetOutputContour(s_eqv_op, dpf.enums.GFXContourType.FENodalScoping)
dpf_workflow.Record('wf_id', True)
this.WorkflowId = dpf_workflow.GetRecordedId()Different scoping representations and the proper enum to select are summarized in the below table.
Scoping Representation and the Corresponding GFX Contour Type
|
Named Selection |
Method in |
|
|
Four Nodes |
GetNodeScopingByRefId() |
dpf.enums.GFXContourType.. FENodalScoping |
|
![]()
Averaged Von Mises stress scoped on four nodes. | ||
| Four Elements |
|
|
|
![]()
Averaged Von Mises stress scoped on four elements | ||
| Four Element Faces |
|
|
|
![]()
Averaged Von Mises stress scoped on four element faces. | ||
| Four Vertices |
|
|
|
![]()
Averaged Von Mises stress scoped on four vertices | ||
| Two Edges |
|
|
|
![]()
Averaged Von Mises stress scoped on two edges. | ||
| Two Faces |
|
|
|
![]()
Averaged Von Mises stress scoped on two faces. | ||
| One Body |
|
|
|
![]()
Averaged Von Mises stress scoped on 1 body | ||
Notes
Unaveraged elemental-nodal result such as Von Mises stress can be obtained by replacing the lines.
Averaged Von Mises Stress
scoping_refs = this.GetCustomPropertyByPath("Group 2/Scoping Property/Named Selection").Value mech_dpf.setExtAPI(ExtAPI) nodes_loc = mech_dpf.GetNodeScopingByRefId(scoping_refs) s_eqv_op.inputs.mesh_scoping.Connect(nodes_loc)With:
Unaveraged Von Mises Stress
scoping_refs = this.GetCustomPropertyByPath("Group 2/Scoping Property/Named Selection").Value mech_dpf.setExtAPI(ExtAPI) elems_loc = mech_dpf.GetElementScopingByRefId(scoping_refs) s_eqv_op.inputs.mesh_scoping.Connect(elems_loc) s_eqv_op.inputs.requested_location.Connect('ElementalNodal')However, contour display of unaveraged elemental-nodal result scoped on different entities besides Body may not be well supported.






