ansys / pydpf-post

Data Processing Framework - Post Processing Module
https://post.docs.pyansys.com
MIT License
43 stars 9 forks source link

how can we identify the node number of a particular result extracted in ansys.dpf.post (pyansys) in python? #72

Closed swatz3221 closed 2 years ago

swatz3221 commented 2 years ago

I have extracted the elastic strain energy density at each node in python from an ansys .rst file using ansys dpf post (solution.misc.nodal_elastic_strain_energy_density) but dont know the information about the nodes at which the results are extracted. I think the results are extracted in a random node manner. So can anyone suggest me to get the results according to the node format that was given in ansys mechanical Or atleast know the node number at the result in python.

question

rlagha commented 2 years ago

@swatz3221 , Once you load a given rst file with:

import ansys.dpf.post as post
sol = post.load_solution(r"c:\temp\file.rst")
res = sol.misc.nodal_reaction_force()

you can get the data at each field with : data = res.get_data_at_field(i) and their corresponding nodes ids with res.get_scoping_at_field(i)

you can also get the data with the fields container API:


fields = res.result_fields_container
#print(fields)
field = fields.get_field({"time":1})
#print(field)
field.data #return raw data
field.scoping.ids #returns the nodes or elements Ids
#or
ids = field.scoping.ids
for id in ids:
    field.get_entity_data_by_id(id)
swatz3221 commented 2 years ago

@swatz3221 , Once you load a given rst file with:

import ansys.dpf.post as post
sol = post.load_solution(r"c:\temp\file.rst")
res = sol.misc.nodal_reaction_force()

you can get the data at each field with : data = res.get_data_at_field(i) and their corresponding nodes ids with res.get_scoping_at_field(i)

you can also get the data with the fields container API:

fields = res.result_fields_container
#print(fields)
field = fields.get_field({"time":1})
#print(field)
field.data #return raw data
field.scoping.ids #returns the nodes or elements Ids
#or
ids = field.scoping.ids
for id in ids:
    field.get_entity_data_by_id(id)
swatz3221 commented 2 years ago

@rlagha Thank you so much. It worked ;) I appreciate your time and effort to the reply and it helped me alot.