Introduction
The Data Processing Framework (DPF) is a tool that enables you to access and transform simulation data using customizable workflows. In the ACT console, with the IPython API of DPF, you can load results from Mechanical systems, apply post processing, and access data. DPF concepts:
The data is contained in an entity called a Field. Fields can be grouped into a Fields Container to describe an analysis, such as "time steps for transient" or "harmonic analysis."
The data is transformed by Operators that can be combined to define Workflows. Each Operator applies an elementary operation on the data.
DPF documentation is available in the ACT console. Available Operators with their descriptions and the required inputs/outputs are listed in this documentation. See the Available Operators menu. The documentation describes the entities used to contain the data (see Main data types) and the APIs available to explore the data with examples (see APIs).
Load the Framework
Open the Mechanical Scripting pane and import the Ans.DataProcessing module by running the following:
import mech_dpf import Ans.DataProcessing as dpf
Generate Documentation
Use the following function to generate DPF’s html documentation. This documentation contains examples and the library of Operators.
mech_dpf.help()
This function returns the path of the generated documentation. Copy and paste the path into a browser to view the documentation.
Access Data from Mechanical
You can use accessed data as input for DPF’s Operators. To access data from the current Mechanical session, run the following:
mech_dpf.setExtAPI(ExtAPI)
- Access Results
Run the following to obtain result data:
my_data_sources = mech_dpf.GetDataSources()
- Access Mesh Data
Select a geometric entity in the Geometry and run the following to display the node and/or element IDs for the selected geometry:
my_nodes_scoping = mech_dpf.GetNodesScoping() my_elements_scoping = mech_dpf.GetElementScoping()
Examples
This example shows how to read a displacement field on a selected geometry at a given time step and computes its normal.
import mech_dpf import Ans.DataProcessing as dpf mech_dpf.help() mech_dpf.setExtAPI(ExtAPI) my_data_sources = mech_dpf.GetDataSources() #once a geometry is selected on the interface my_nodes_scoping = mech_dpf.GetNodesScoping() my_time_scoping = dpf.data.Scoping() my_time_scoping.Ids = [1] read_disp_op = dpf.operators.result.displacement() read_disp_op.inputs.data_sources.Connect(my_data_sources) read_disp_op.inputs.time_scoping.Connect(my_time_scoping) read_disp_op.inputs.mesh_scoping.Connect(my_nodes_scoping) norm_op = dpf.operators.math.norm_fc() norm_op.inputs.fields_container.Connect(read_disp_op.outputs.fields_container) my_u_norm_fc = norm_op.outputs.fields_container.GetData() u_norm_1 = my_u_norm_fc.GetFieldByTimeId(1) #see node ids of the field u_norm_1.Scoping.Ids #see displacement norm data u_norm_1.Data
This example shows how to read a stress field on a selected geometry, average the elemental nodal stress on the nodes and compute its Von Mises equivalent.
import mech_dpf import Ans.DataProcessing as dpf mech_dpf.help() mech_dpf.setExtAPI(ExtAPI) my_data_sources = mech_dpf.GetDataSources() #once a geometry is selected on the interface my_elements_scoping = mech_dpf.GetElementScoping() read_stress_op = dpf.operators.result.stress() read_stress_op.inputs.data_sources.Connect(my_data_sources) read_stress_op.inputs.mesh_scoping.Connect(my_elements_scoping) # by default the result is read on one time set average_op = dpf.operators.averaging.to_nodal_fc() average_op.inputs.fields_container.Connect(read_stress_op.outputs.fields_container) eqv_op = dpf.operators.invariant.von_mises_eqv_fc() eqv_op.inputs.fields_container.Connect(average_op.outputs.fields_container) my_stress_eqv_fc = eqv_op.outputs.fields_container.GetData() my_stress_eqv1 = my_stress_eqv_fc.GetFieldByTimeId(1) #see node ids of the field my_stress_eqv1.Scoping.Ids #see displacement norm data my_stress_eqv1.Data