Skip to content

How to extract element nodal forces on selected nodes #433

@ezyman

Description

@ezyman

I am using Ansys pdf in Mechanical (2022R1). I run a simple static structural analysis and try to extract nodal element forces on selected nodes. I have written the following script, but the answer I get after running it is wrong. I wonder if I have extracted the forces properly. This issue is almost similar to that raised by @py-1337.

# Import DPF
import mech_dpf
import Ans.DataProcessing as dpf
mech_dpf.setExtAPI(ExtAPI)

analysis_idx = 0

# General Setup / Entry Points
model = ExtAPI.DataModel.Project.Model
geom = model.Geometry
analysis = model.Analyses[analysis_idx]
solution = analysis.Solution

# Get the data source 
dataSource = dpf.DataSources(analysis.ResultFileName)

# Create Named Selection Operator
ns_op = dpf.operators.scoping.on_named_selection()
ns_op.inputs.data_sources.Connect(dataSource)
ns_op.inputs.requested_location.Connect('Nodal')
ns_op.inputs.named_selection_name.Connect('WELDNODES')

# Get node numbers for nodes in named selection
mesh_data = ns_op.outputs.mesh_scoping.GetData()
mesh_data.Ids #  node Ids

# Get complete mesh
model=dpf.Model(dataSource)
mesh = model.Mesh

my_mesh_scoping = dpf.MeshScopingFactory.NodalScoping(mesh_data.Ids)
my_mesh = mesh

enf=dpf.operators.result.element_nodal_forces()
enf.inputs.data_sources.Connect(dataSource)
enf.inputs.mesh_scoping.Connect(my_mesh_scoping)
enf.inputs.mesh.Connect(my_mesh)
enf.inputs.requested_location.Connect(dpf.locations.nodal)

# Get output data
result_fields_container = enf.outputs.fields_container.GetData()[0]
#result_fields_container.GetEntityDataById(89)

# Compute the total element nodal force along the weld line
op = dpf.operators.math.accumulate()
op.inputs.fieldA.Connect(result_fields_container)
enf_total = op.outputs.field.GetData()
enf_total.Data

The output data is wrong, hence "enf_total" is wrong.

Any idea on where I could have done wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions