_slope module

Slope class for pyrockfall

This module defines the Slope class, which represents a slope geometry for rockfall simulation. A slope is defined by:

  • Nodes: coordinates of the geometry (mandatory).

  • Elements: connectivity between nodes (optional; if omitted, sequential connectivity is assumed).

  • Materials: material assignment to elements, with optional support for material tables and IDs.

The class supports stochastic perturbation of nodes, material assignment, combination of contiguous slopes, and efficient queries.

class pyrockfall._slope.Slope(geometry: Geometry, materials: Material | Sequence[Material], materialIDs: Sequence[int] | NDArray[integer] | None = None)[source]

Bases: object

Represents a slope geometry for rockfall simulations.

Parameters:
  • nodes (np.ndarray of shape (N, D)) – Node coordinates, where N is the number of nodes and D is the number of dimensions (2 or 3). Internally stored transposed as shape (D, N) for efficient vectorised operations.

  • materials (Union[Material, List[Material], np.ndarray]) – Material assignment. Can be: - A single Material (applied to all elements). - A list/array of length E (one Material per element). - A list of unique materials (materialTable) if materialIDs is also provided.

  • elements (Optional[np.ndarray of shape (E, M)], default=None) – Connectivity array. If not provided, defaults to sequential pairs [[0, 1], [1, 2], …, [E, E+1]] with E = len(materials).

  • materialIDs (Optional[np.ndarray of shape (E,)], default=None) – Integer material IDs mapping each element to an entry in materials (interpreted as the material table). If provided, materials must be the material table. If omitted, materials is interpreted directly as per-element materials.

nodes

Node coordinates (always returned as (N, D)).

Type:

np.ndarray of shape (N, D)

elements

Element connectivity array.

Type:

np.ndarray of shape (E, M)

materialTable

Unique materials used in the slope.

Type:

List[Material]

materialIDs

Integer material IDs mapping each element to an entry in materialTable.

Type:

np.ndarray of shape (E,)

nodes_std

Standard deviations for stochastic node perturbations.

Type:

np.ndarray of shape (D, N)

property materials: List[Material]

Material object associated with each element.

Returns:

A list of length equal to the number of elements, where entry i is the Material object of element i.

Return type:

list of Material

property materialTable: List[Material]

Unique materials used in this slope.

Type:

list of Material

property materialIDs: ndarray

Material IDs per element (indices into materialTable).

Type:

np.ndarray of shape (E,)