sgio.get_node_id_mapping#

sgio.get_node_id_mapping(mesh) Dict[int, int]#

Extract node ID mapping from mesh.

Returns a dictionary mapping from original node IDs (from mesh.point_data[‘node_id’]) to array indices (0-based positions in mesh.points).

Parameters:

mesh (SGMesh) – Mesh object with optional point_data[‘node_id’].

Returns:

Mapping from original node ID to array index. If mesh has no ‘node_id’, returns identity mapping {1: 0, 2: 1, 3: 2, …}.

Return type:

dict[int, int]

Examples

>>> mesh = SGMesh(points, cells, point_data={'node_id': [10, 20, 30]})
>>> get_node_id_mapping(mesh)
{10: 0, 20: 1, 30: 2}
>>> # Mesh without node_id
>>> mesh = SGMesh(points, cells)
>>> get_node_id_mapping(mesh)
{1: 0, 2: 1, 3: 2}