Skip to content

shore.mesh.blocking ​

Blocking: a block skeleton edited by commands, premeshed into blocks (ADR 0042).

A blocking is the topology of a multi-block grid without its nodes: skeleton vertices (points), hexahedral blocks over them (8 vertex ids each, in HexBlock.vertices() order: index 4 i + 2 j + k), a node count on every edge, and associations of vertices, edges and faces with geometry. Blocks touching each other share vertex ids, so a face or an edge is the same entity in every block that has it.

Editing keeps the blocking conforming:

  • split cuts a block across one axis and carries the cut through every block sharing a cut edge (the whole sheet), at the same node;
  • delete removes blocks (the hole they leave is a boundary).

premesh makes ordinary HexBlocks:

  • vertices are projected onto their associations;
  • each edge is a straight line of equally spaced nodes, projected onto its association and re-equidistributed along the projected polyline;
  • each face is a TFI of its four edges, projected onto its association;
  • each block is a TFI of its six faces. Edges and faces are made once and copied into every block that has them, so seams match bit for bit. Faces shared by two blocks become SHARED seams; boundary faces with an association are WALL, the others FREE.

An entity without its own association takes the one of the entities above it, lowest dimension first, when they agree: an edge the association of its associated faces, a vertex that of its associated edges, else of its faces.

face_corners function ​

python
face_corners(face: str) -> np.ndarray

source

Local vertex indices (2, 2) of face, over its along-axes (FACE_ALONG_AXES).

Blocking dataclass ​

python
Blocking(
    points: np.ndarray,
    blocks: list[tuple[str, tuple[int, ...]]],
    nodes: dict[tuple[int, int], int],
    associations: dict[EntityKey, Association] = field(default_factory=dict),
    next_label: int = 1,
    planes: tuple[Plane, ...] = (),
)

source

A block skeleton (see the module docstring).

Blocking.copy method ​

python
copy() -> Blocking

source

Blocking.labels method ​

python
labels() -> list[str]

source

Blocking.block method ​

python
block(label: str) -> tuple[int, ...]

source

Blocking.edge_count method ​

python
edge_count(a: int, b: int) -> int

source

Blocking.entity method ​

python
entity(label: str, name: str) -> tuple[EntityKey, str]

source

The key of face, edge or vertex name of block label, and which it is.

Blocking.shape method ​

python
shape(label: str) -> tuple[int, int, int]

source

Blocking.edges method ​

python
edges() -> dict[tuple[int, int], list[tuple[int, str]]]

source

Every edge (a < b) -> the (block index, edge name) that have it.

Blocking.polylines method ​

python
polylines() -> list[tuple[str, str, np.ndarray]]

source

Every edge once, as (block, edge name, nodes (n, 3)): its nodes equally spaced on the straight line between its skeleton vertices, in the direction of the edge in the first block that has it.

Blocking.centres method ​

python
centres(kind: str) -> list[tuple[str, str, np.ndarray]]

source

Skeleton centres of every "face" (once, named by its first block), "block" or "vertex" (its point, once, named v0..v7 by its first block): (block, name, centre), the name "" for a block.

Blocking.faces method ​

python
faces() -> dict[tuple[int, ...], list[tuple[int, str]]]

source

Every face (sorted vertex ids) -> the (block index, face name) that have it.

box function ​

python
box(vmin: Any, vmax: Any, ni: int, nj: int, nk: int, label: str = 'b0') -> Blocking

source

One block between the corners vmin and vmax, with ni x nj x nk nodes.

split function ​

python
split(blocking: Blocking, label: str, axis: str, fraction: float) -> Blocking

source

Cut block label across axis at the node nearest fraction of it.

Every block sharing a cut edge is cut too, at the same node, so the blocking stays conforming. The low part keeps the label, the high part gets a new one (b<n>).

ogrid function ​

python
ogrid(
    blocking: Blocking,
    labels: list[str] | tuple[str, ...] = (),
    faces: list[tuple[str, str]] | tuple[tuple[str, str], ...] = (),
    exclude: list[tuple[str, str]] | tuple[tuple[str, str], ...] = (),
    factor: float = 0.5,
    nodes: int = 5,
) -> Blocking

source

Insert an O-grid: a layer of blocks on faces of the block set labels.

The layered faces are faces ((block, face) pairs), or every face on the boundary of the set, less exclude; they all lie on the set's boundary. Boundary faces of the set that are not layered stay open: the O-grid passes through them, and they must be faces of the blocking's boundary. Every vertex of a layered face gets an inner copy, moved into the set by (1 - factor) times half the sum of its edges that leave the layered faces into the set (inside one block: the block scaled by factor about its centre). The set's blocks take the inner copies; each layered face gets a block between it and its copy, with nodes nodes across. Labels: the set's blocks keep theirs, the layer blocks are new b<n> in block and face order. With no labels, the set is every block.

move function ​

python
move(
    blocking: Blocking,
    label: str,
    vertex: str,
    xyz: Any,
    resolver: AssociationResolver | None = None,
) -> Blocking

source

Move vertex vertex (v0..v7) of block label to xyz: onto the projection of xyz on the vertex's association (own or inherited), when it has one, so an associated vertex slides on its geometry.

delete function ​

python
delete(blocking: Blocking, labels: list[str] | tuple[str, ...]) -> Blocking

source

Remove blocks labels; their faces left alone become boundary faces.

associate function ​

python
associate(
    blocking: Blocking,
    label: str,
    entity: str,
    association: Association | None,
) -> Blocking

source

Set (or with None clear) the association of entity of block label.

symmetry function ​

python
symmetry(blocking: Blocking, point: Any, normal: Any) -> Blocking

source

A copy of blocking with the symmetry plane through point (ADR 0053).

premesh makes the unassociated boundary faces lying on the plane SYMMETRY faces, and orthogonal_walls keeps the lines leaving the wall from the plane in it.

on_plane function ​

python
on_plane(points: np.ndarray, plane: Plane, tol: float) -> np.ndarray

source

Which of points (..., 3) lie within tol of plane.

plane_tolerance function ​

python
plane_tolerance(points: np.ndarray) -> float

source

1e-9 of the extent of points: their distance to a plane they lie on.

effective_associations function ​

python
effective_associations(blocking: Blocking) -> dict[EntityKey, Association]

source

Every entity's association: its own, else inherited (module docstring).

tfi_face function ​

python
tfi_face(
    i_lo: np.ndarray,
    i_hi: np.ndarray,
    j_lo: np.ndarray,
    j_hi: np.ndarray,
) -> np.ndarray

source

Coons patch (na, nb, 3) from its four boundary rows.

i_lo / i_hi are the rows at a = 0 / a = na - 1 (length nb), j_lo / j_hi those at b = 0 / b = nb - 1 (length na). The boundary is copied.

tfi_volume function ​

python
tfi_volume(x: np.ndarray) -> None

source

Fill the interior of x (ni, nj, nk, 3) by TFI of its six faces, in place.

premesh function ​

python
premesh(blocking: Blocking, resolver: AssociationResolver | None) -> list[HexBlock]

source

The blocking's blocks as HexBlocks (module docstring).

Released under the MIT License.