
Summation of 2 damage results

Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.

def post_started(sender, analysis):# Do not edit this line
define_dpf_workflow(analysis)
def define_dpf_workflow(analysis):
analysis = ExtAPI.DataModel.AnalysisByName(ExtAPI.DataModel.AnalysisNames[0])
import mech_dpf
import Ans.DataProcessing as dpf
####################################
# Get IDs of damage object to combine
damageresults = ExtAPI.DataModel.GetObjectsByName("damage")
# build set with all nodes
all_scoped_nodes = [] # Create List of nodes
for damageobj in damageresults:
all_scoped_nodes.extend(damageobj.PlotData.Values[1]) # add nodes from each UDR
all_scoped_nodes_set = set(all_scoped_nodes) # create set - eliminate multiple entries
all_scoped_nodes = list(all_scoped_nodes_set) # create list from set
####################################
### Create new results
#analysis=ExtAPI.DataModel.AnalysisByName('Static Structural')
dataSource = dpf.DataSources(analysis.ResultFileName)
# Read mesh in results file
mesh_op = dpf.operators.mesh.mesh_provider() # operator instanciation
mesh_op.inputs.data_sources.Connect(dataSource)
mesh = mesh_op.outputs.mesh.GetData()
field_list = []
# go through all values of each damage results and feed them into created field
for damageobj in damageresults:
# Create Field of necessary size
numnodes = len(all_scoped_nodes) # number of nodes
field = dpf.FieldsFactory.CreateScalarField(numnodes) # create field with size
field.MeshedRegionSupport = mesh # attach mesh
field.ScopingIds = all_scoped_nodes # give list of nodes
field.Data = [0. for i in range(0,len(all_scoped_nodes))]# fill field with zeros
node_scope_udr = damageobj.PlotData.Values[1]
val_udr = damageobj.PlotData.Values[len(damageobj.PlotData.Values)-1]
for ii in range(0,len(node_scope_udr)):
index=field.ScopingIds.IndexOf(node_scope_udr[ii]) # get index of node in created field
field.UpdateEntityDataByEntityIndex(index,[val_udr[ii]])
field_list.append(field)
################################
sum_field_list = field_list[0]
for i in range(0,len(field_list)-1,1):
sum_field_list = dpf.operators.math.add(fieldA=sum_field_list,fieldB=field_list[i+1])
# Create field operator for plotting
combined_plot = dpf.operators.utility.forward_field() # operator instanciation
combined_plot.inputs.field.Connect(sum_field_list)
####################################
### create plotting workflow
dpf_workflow = dpf.Workflow()
dpf_workflow.Add(combined_plot)
dpf_workflow.SetOutputContour(combined_plot)
dpf_workflow.Record('wf_id', True)
this.WorkflowId = dpf_workflow.GetRecordedId()

Was this page helpful?