DPF mapping between node ID/index and MAPDL node ID
DPF seems to have two different types of node IDs at least in the context of MAPDL results: one is an internal node ID and another is the node ID in MAPDL. For example it is possible to have ANSYS node IDs 100,200,300 and the corresponding internal DPF ids would be 1,2,3. The mesh scoping commands like nodes_scoping = dpf.mesh_scoping_factory.nodal_scoping(range(400, 500)) seem to use internal node IDs, although the documentation is not explicit about that. I would like to create scoping based on the MAPDL node IDs. It is not clear from docs and examples how to do that. Can you please explain?
On a related point. Is there a vectorized way to convert internal node IDs to MAPDL node IDs and vice versa? I see id and index methods in Scoping but they only take a single argument so they would need to be run in a loop
Answers
-
Hello,
there is indeed a internal numbering and the actual node numbering. For a given field, you would get the values using get_entity_data_by_id(mapdl_node_number) or get_entity_data(dpf_node_index).
When you define a scoping, the ids of the scoping are the actual node numbers as defined in MAPDL. The following script shows the difference between node id (mapdl) and node index (dpf). The last line also shows that the scoping is indeed on mesh node ids and not dpf indexes
from ansys.dpf import core as dpf rst_file=r'D:\basicDemo23R1_files\dp0\SYS\MECH\file.rst' premium_server_context = dpf.AvailableServerContexts.premium premium_server = dpf.start_local_server( context=premium_server_context ) ds=dpf.DataSources(rst_file) model=dpf.Model(ds) print(model) node_range=list(range(400, 410)) mesh=model.metadata.meshed_region nodes_scoping = dpf.mesh_scoping_factory.nodal_scoping(node_range) u=dpf.operators.result.displacement(data_sources=ds) u_field=u.outputs.fields_container()[0] for nid in node_range: print("mapdl id {0}: {1}".format(nid,u_field.get_entity_data_by_id(nid))) print("dpf index {0}: {1}".format(nid,u_field.get_entity_data(nid))) u.inputs.mesh_scoping.connect(nodes_scoping) print(u.outputs.fields_container()[0])
To get the correspondence between indexes and ids, you could use this call which returns a dictionary whose keys are the dpf indexed and the values the actual node ids
mesh.nodes.mapping_id_to_index
0