How to 'probe' principal stresses for a set of nodes?
Pierre Thieffry
Member, Moderator, Employee Posts: 108
✭✭✭✭
Another customer request: how to probe for all principal stresses at once? This can't be done using regular probes.
Tagged:
0
Answers
-
Not really a probe, but I suggest the following which will display a message box with the values of the principal stresses. It uses DPF.
- import math
- import units
- import mech_dpf
- import Ans.DataProcessing as dpf
- clr.AddReference("Ans.UI.Toolkit.Base")
- clr.AddReference("Ans.UI.Toolkit")
- from Ansys.UI.Toolkit import *
- curSel=ExtAPI.SelectionManager.CurrentSelection
- # Need to have two faces selected, otherwise pass
- if (curSel.Ids.Count==0):
- mess_line1 = 'Please select at least one node'
- MessageBox.Show(mess_line1)
- pass
- meshData=ExtAPI.DataModel.Project.Model.Analyses[0].MeshData
- scoping=dpf.data.Scoping()
- scoping.Ids = curSel.Ids
- scoping.Location=dpf.enums.location.nodal
- an1=ExtAPI.DataModel.AnalysisByName(ExtAPI.DataModel.AnalysisNames[0])
- rstFile=an1.WorkingDir+'file.rst'
- dataSource = dpf.data.DataSources(rstFile)
- stressOp1 = dpf.operators.result.stress_principal_1()
- stressOp2 = dpf.operators.result.stress_principal_2()
- stressOp3 = dpf.operators.result.stress_principal_3()
- stressOp1.inputs.data_sources.Connect(dataSource)
- stressOp2.inputs.data_sources.Connect(dataSource)
- stressOp3.inputs.data_sources.Connect(dataSource)
- stressOp1.inputs.mesh_scoping.Connect(scoping)
- stressOp2.inputs.mesh_scoping.Connect(scoping)
- stressOp3.inputs.mesh_scoping.Connect(scoping)
- stressData1=stressOp1.outputs.fields_container.GetData()[0]
- stressData2=stressOp2.outputs.fields_container.GetData()[0]
- stressData3=stressOp3.outputs.fields_container.GetData()[0]
- stressData=[]
- for nid in curSel.Ids:
- stressData.append([nid,stressData1.GetEntityDataById(nid)[0],stressData2.GetEntityDataById(nid)[0],stressData3.GetEntityDataById(nid)[0]])
- # Display result
- mess_line='Node\tS1\tS2\tS3\n'
- for sd in stressData:
- mess_line+=str(sd[0])+'\t'+str(round(sd[1],2))+'\t'+str(round(sd[2],2))+'\t'+str(round(sd[3],2))+'\n'
- MessageBox.Show(mess_line)
2