pyDPF - element nodal forces - Element with id x has higher number of elementary data...

Options
total_obliteration
total_obliteration Member Posts: 2
First Comment
edited May 13 in Structures

Hello,
Trying to extract contact reaction force in pyDPF. The code below returns:

ENF:495<-mapdl::rst::ENF:500<-Element with id 192983 has higher number of elementary data (32) than number of nodes (8). Nodal rotation to global coordinate system using Euler nodes angles can't be achieved, failed to read element nodal forces from rst file.

rst_file = glob.glob('*.rst')[1]
model = dpf.Model(rst_file)
global_mesh = model.metadata.meshed_region

#results - element nodal force
results = model.results
element_nodal_forces = results.element_nodal_forces().outputs.fields_container()

My approach is as follows, could not have tested due to error above. Any advise appreciated.

#get NSs
get_NSs = model.metadata.available_named_selections
ns = 'CONTACT'
find_ns = [s for s in get_NSs if s.startswith(ns)]
ns = find_ns[2]
ns

#select NS nodes
scoping_NS = model.metadata.named_selection(ns)
print(scoping_NS)

#filter mesh by NS scoping - result is only CONTA+TARGE elems
mesh174_op = dpf.operators.mesh.from_scoping(
    scoping=scoping_NS,
    inclusive=0,
    nodes_only=False,
    mesh=global_mesh)

mesh174 = mesh174_op.outputs.mesh()
print(mesh174)

#only CONTA+TARGE elems
etypes = mesh174.property_field("apdl_element_type")
etypes = pd.Series(etypes.data_as_list)
print(etypes.unique())

#extract and sum nodal forces - from 
element_nodal_forces = model.results.element_nodal_forces.on_mesh_scoping(scoping_NS).eval()

element_nodal_forces_df = pd.DataFrame(element_nodal_forces[0].data, columns = ['fx', 'fy', 'fz'])
element_nodal_forces_sum = element_nodal_forces_df.sum()
print(element_nodal_forces_sum)

I achieved the desired effect using pyMAPDL like below (here, printed for etypes for comparison, trying to figure out how Mechanical calculates the contact reaction force):

#select NS and print fsum by type - CONT ONLY
etypes = ['154', '170', '174', '186', '187']
fsum_dict = {}

print('fsum - CONT ONLY')
for etype in etypes:
    mapdl.esel('all')
    mapdl.cmsel(type_='S', name=named_selection)
    mapdl.esel('r', 'ename', '', int(etype))
    ecount = mapdl.get(entity='elem', item1='count')
    
    print('etype: ' + str(int(etype)) + '; elem count: ' + str(int(ecount)))

    mapdl.fsum(item='CONT')
    f_x = round(mapdl.get(entity='FSUM', item1='ITEM', it1num='FX'), 2)
    f_y = round(mapdl.get(entity='FSUM', item1='ITEM', it1num='FY'), 2)
    f_z = round(mapdl.get(entity='FSUM', item1='ITEM', it1num='FZ'), 2)
    fsum_dict[etype] = [f_x, f_y, f_z]
fsum_dict
Tagged: