How to extract nodal stress results from elemental named selection?

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 450
100 Answers 250 Likes 100 Comments First Anniversary
✭✭✭✭
edited June 2023 in Structures

How to extract nodal stress results from elemental named selection and save the mapped stress results modified using a function?

Tagged:

Answers

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 450
    100 Answers 250 Likes 100 Comments First Anniversary
    ✭✭✭✭
    Answer ✓

    Please change the index in line, this might vary: mapped_stress_x.update({str(node): normal_stress.PlotData.Values[2][index]})

    ns = Model.NamedSelections.Children[0]
    # Get element ids
    elements = ns.Location.Ids
    
    mesh = Model.Analyses[0].MeshData
    
    # Get nodes associated with elements
    nodes = mesh.NodeIdsFromElementIds(elements)
    
    # Add a result object
    normal_stress = Model.Analyses[0].Solution.AddNormalStress()
    # Scope named selection
    normal_stress.ScopingMethod = GeometryDefineByType.Component
    normal_stress.Location = ns
    ExtAPI.DataModel.Tree.Refresh()
    Model.Analyses[0].Solution.EvaluateAllResults()
    
    mapped_stress_x = {}
    # Get indexes of nodes
    for node in nodes:
        index = list(normal_stress.PlotData.Values[1]).index(node)
        mapped_stress_x.update({str(node): normal_stress.PlotData.Values[2][index]})