Skip to content

MeshIndex

MeshIndex dataclass

MeshIndex(node_ids: ndarray, node_coords: ndarray, node_ndf: ndarray, node_core_map: List[List[int]], element_ids: ndarray, element_connectivity: List[ndarray], element_centroids: ndarray, element_types: ndarray, material_tags: ndarray, section_tags: ndarray, region_tags: ndarray, core_ids: ndarray, element_id_to_index: Dict[int, int], node_tag_start: int = 1, element_tag_start: int = 1)

Immutable snapshot of assembled mesh data for efficient masking/filtering.

This structure is created after mesh assembly and stores the minimal arrays needed to perform fast vectorized spatial and attribute-based queries.

Attributes:

Name Type Description
node_ids ndarray

1D array of node IDs, zero-based indices derived from the assembled grid ordering. Shape (N,).

node_coords ndarray

Nodal coordinates. Shape (N, 3).

node_ndf ndarray

Degrees of freedom per node. Shape (N,).

node_core_map List[List[int]]

List where each item is a list of core IDs that the corresponding node belongs to (a node can be part of multiple cores). Shape (N,).

element_ids ndarray

1D array of element IDs, which can be cell indices or explicit identifiers. Shape (M,).

element_connectivity List[ndarray]

A list where each item is a 1D array of node indices (referencing node_ids) for that element.

element_centroids ndarray

Precomputed centroid coordinates for each element. Shape (M, 3).

element_types ndarray

Array of string or object types for each element. Shape (M,).

material_tags ndarray

Material tag for each element. Shape (M,).

section_tags ndarray

Section tag for each element. Shape (M,).

region_tags ndarray

Region tag for each element. Shape (M,).

core_ids ndarray

Partition/core ID for each element. Shape (M,).

element_id_to_index Dict[int, int]

A mapping from an explicit element ID to its 0-based row index in the element_ids array.

Example
import numpy as np
from femora.components.mask.mask_base import MeshIndex

# Assuming a simple mesh has been assembled
mesh_index = MeshIndex(
    node_ids=np.array([0, 1, 2]),
    node_coords=np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]),
    node_ndf=np.array([3, 3, 3]),
    node_core_map=[[0], [0], [0]],
    element_ids=np.array([0]),
    element_connectivity=[np.array([0, 1, 2])],
    element_centroids=np.array([[0.33, 0.33, 0.0]]),
    element_types=np.array(["TRIANGLE"]),
    material_tags=np.array([1]),
    section_tags=np.array([1]),
    region_tags=np.array([0]),
    core_ids=np.array([0]),
    element_id_to_index={0: 0}
)
print(mesh_index.node_ids.shape)
# Output: (3,)