How to control the result ids order when using DPF/pyDPF?
Chemsdine CHEMAI
Member, Employee Posts: 201
✭✭✭✭
How to control the result ids order when using DPF/pyDPF?
While requesting a result, the order of the result items are completely random (especially for elemnodes results). The solution there is to use the rescope operator to "force" DPF/pyDPF to output the items in the wanted order.
Tagged:
0
Answers
-
One needs to use the
rescope
operator.Here is an example in Cpython :
from ansys import dpf from ansys.dpf import core as dpf f_rst = r'C:\file.rst' ds = dpf.DataSources(f_rst) model = dpf.Model(ds) mesh = model.metadata.meshed_region stressX=dpf.operators.result.stress_X() stressX.inputs.mesh_scoping(mesh.nodes.scoping) stressX.inputs.data_sources(ds) stressX_fields=stressX.outputs.fields_container() print(stressX_fields[0].scoping.ids[:10]) rescope = dpf.operators.scoping.rescope() rescope.inputs.mesh_scoping(mesh.nodes.scoping) rescope.inputs.fields(stressX_fields) rescope_field=rescope.outputs.fields_as_fields_container print(rescope_field.get_data()[0].scoping.ids[:10])
0