How to control the result ids order when using DPF/pyDPF?

Chemsdine CHEMAI
Chemsdine CHEMAI Member, Employee Posts: 201
100 Likes 100 Comments Second Anniversary Ansys Employee
✭✭✭✭
edited February 19 in Structures

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:

Answers

  • Chemsdine CHEMAI
    Chemsdine CHEMAI Member, Employee Posts: 201
    100 Likes 100 Comments Second Anniversary Ansys Employee
    ✭✭✭✭
    Answer ✓

    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])