Mesh Utilities#

Mesh Class#

SGMesh(points, cells[, point_data, ...])

Backend-neutral mesh container for Structure Genome I/O.

Node and Element Numbering#

The numbering module provides validation and utilities for node and element numbering.

Validation Functions#

validate_node_ids(node_ids[, n_nodes, format])

Validate node ID numbering according to format requirements.

validate_element_ids(element_ids[, format])

Validate element ID numbering according to format requirements.

Utility Functions#

get_node_id_mapping(mesh)

Extract node ID mapping from mesh.

ensure_node_ids(mesh)

Ensure mesh has node IDs in point_data.

ensure_element_ids(mesh)

Ensure mesh has element IDs in cell_data.

check_duplicate_ids(ids[, id_type])

Check for duplicate IDs in a list.

check_forbidden_ids(ids[, format, id_type])

Check for forbidden IDs according to format requirements.

renumber_elements(mesh)

Renumber elements sequentially starting from 1.

auto_renumber_for_format(mesh, format[, logger])

Automatically renumber nodes/elements to meet format requirements.

Format Numbering Requirements#

Each target format declares its node/element numbering constraints. The writers consult this registry and adjust numbering automatically, so explicit renumbering is normally unnecessary.

FormatNumberingRequirements(name, ...[, ...])

Numbering requirements for a target format.

normalize_format_name(file_format)

Normalize a user-provided format string.

get_numbering_requirements(file_format)

Get numbering requirements for a format.

Two module-level tables back these functions:

sgio.FORMAT_ALIASES

Maps format aliases to their canonical name (for example 'sc' to 'swiftcomp'). normalize_format_name() applies this mapping.

sgio.FORMAT_REQUIREMENTS

Maps each canonical format name to its FormatNumberingRequirements. get_numbering_requirements() looks up this table, resolving aliases first.

Mesh Validation Functions#

check_cell_ordering(mesh)

Check node ordering for supported cell types.

fix_cell_ordering(mesh)

Fix node ordering for supported cell types.

check_isolated_nodes(mesh)

Check if there are isolated/unconnected nodes in the mesh.