pmmoto.core package

Submodules

pmmoto.core.boundary_types module

boundary_types.py

Possible boundary types for PMMoTo

pmmoto.core.boundary_types.boundary_order(boundaries: list[BoundaryType]) BoundaryType

Prove the boundary type for joining boundaries.

Fro edges and corners in 3D, this specifies the boundary type for the feature. #TODO Get rid of this and allow edges and corners to carry all types.

Parameters:

boundaries (list[BoundaryType]) – boundaries at given feature

Returns:

The one boundary type for the feature

Return type:

BoundaryType

pmmoto.core.communication module

pmmoto.core.domain module

pmmoto.core.domain_decompose module

pmmoto.core.domain_discretization module

pmmoto.core.features module

pmmoto.core.logging module

logging.py

Setup of the logger

class pmmoto.core.logging.MPIFormatter(*args: Any, **kwargs: Any)

Bases: Formatter

Custom formatter that includes MPI rank

Initialize the formatter with specified format strings.

Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.

Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to use one of %-formatting, str.format() ({}) formatting or string.Template formatting in your format string.

Changed in version 3.2: Added the style parameter.

format(record: LogRecord) str

Add mpi information

pmmoto.core.logging.get_logger() Logger

Get or create the logger instance

pmmoto.core.logging.setup_logger(name: str = 'pmmoto', log_dir: str = 'logs') Logger

Configure logging for both serial and parallel runs

Parameters:
  • name – Logger name (default: “pmmoto”)

  • log_dir – Directory to store log files (default: “logs”)

Returns:

Configured logger instance

Return type:

logging.Logger

pmmoto.core.orientation module

orientation.py

Defines orientation and feature indexing utilities for PMMoTo subdomains.

pmmoto.core.orientation.get_boundary_id(boundary_index: tuple[int, ...]) int

Determine boundary ID from a boundary index.

Parameters:
  • boundary_index (list[int] or tuple[int]) – Boundary index for [x, y, z],

  • -1 (values)

  • 0

  • 1.

Returns:

Encoded boundary ID.

Return type:

int

pmmoto.core.pmmoto module

pmmoto.core.subdomain module

pmmoto.core.subdomain_features module

pmmoto.core.subdomain_padded module

pmmoto.core.subdomain_verlet module

pmmoto.core.utils module

Core utility functions for PMMoTo.

This module provides utility functions for array manipulation, validation, MPI-aware operations, and subdomain/grid management.

pmmoto.core.utils.bin_image(subdomain: Subdomain, img: NDArray[T], own: bool = True) dict[T, int]

Count the number of times each unique element occurs in the input array.

Parameters:
  • subdomain – Subdomain object.

  • img (np.ndarray) – Input array.

  • own (bool) – If True, use only owned voxels.

Returns:

Mapping from element value to count.

Return type:

dict

pmmoto.core.utils.constant_pad_img(img: ndarray[Any, dtype[T]], pad: tuple[tuple[int, int], ...], pad_value: int | float) ndarray[Any, dtype[T]]

Pad a grid with a constant value.

Parameters:
  • img (np.ndarray) – Input array.

  • pad (list or tuple) – Padding amounts for each dimension.

  • pad_value (scalar) – Value to use for padding.

Returns:

The padded array.

Return type:

np.ndarray

pmmoto.core.utils.determine_maximum(img: ndarray[Any, dtype[T]]) int | float

Determine the global maximum of an input image.

Parameters:

img (np.ndarray) – Input array.

Returns:

Global maximum value.

Return type:

scalar

pmmoto.core.utils.own_img(subdomain: Subdomain, img: NDArray[T], own_voxels: None | NDArray[np.integer[Any]] = None) NDArray[T]

Return array with only nodes owned by the current process.

Parameters:
  • subdomain – Subdomain object with get_own_voxels method.

  • img (np.ndarray) – Input image.

  • own_voxels – NDArray of size 2*dims with bounds of image to extract

Returns:

Array of owned voxels.

Return type:

np.ndarray

pmmoto.core.utils.phase_exists(img: ndarray[Any, dtype[T]], phase: int | float) bool

Determine if a phase exists in the grid (globally).

Parameters:
  • img (np.ndarray) – Input array.

  • phase (int) – Phase value to check.

Returns:

True if phase exists, False otherwise.

Return type:

bool

pmmoto.core.utils.unpad(img: ndarray[Any, dtype[T]], pad: tuple[tuple[int, int], ...]) ndarray[Any, dtype[T]]

Remove padding from a NumPy array.

Parameters:
  • img (np.ndarray) – The padded array.

  • pad (list or tuple) – Padding

Returns:

The unpadded array.

Return type:

np.ndarray

pmmoto.core.voxels module