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:
splitcuts a block across one axis and carries the cut through every block sharing a cut edge (the whole sheet), at the same node;deleteremoves 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
face_corners(face: str) -> np.ndarrayLocal vertex indices (2, 2) of face, over its along-axes (FACE_ALONG_AXES).
Blocking dataclass
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, ...] = (),
)A block skeleton (see the module docstring).
Blocking.copy method
copy() -> BlockingBlocking.labels method
labels() -> list[str]Blocking.block method
block(label: str) -> tuple[int, ...]Blocking.edge_count method
edge_count(a: int, b: int) -> intBlocking.entity method
entity(label: str, name: str) -> tuple[EntityKey, str]The key of face, edge or vertex name of block label, and which it is.
Blocking.shape method
shape(label: str) -> tuple[int, int, int]Blocking.edges method
edges() -> dict[tuple[int, int], list[tuple[int, str]]]Every edge (a < b) -> the (block index, edge name) that have it.
Blocking.polylines method
polylines() -> list[tuple[str, str, np.ndarray]]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
centres(kind: str) -> list[tuple[str, str, np.ndarray]]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
faces() -> dict[tuple[int, ...], list[tuple[int, str]]]Every face (sorted vertex ids) -> the (block index, face name) that have it.
box function
box(vmin: Any, vmax: Any, ni: int, nj: int, nk: int, label: str = 'b0') -> BlockingOne block between the corners vmin and vmax, with ni x nj x nk nodes.
split function
split(blocking: Blocking, label: str, axis: str, fraction: float) -> BlockingCut 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
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,
) -> BlockingInsert 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
move(
blocking: Blocking,
label: str,
vertex: str,
xyz: Any,
resolver: AssociationResolver | None = None,
) -> BlockingMove 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
delete(blocking: Blocking, labels: list[str] | tuple[str, ...]) -> BlockingRemove blocks labels; their faces left alone become boundary faces.
associate function
associate(
blocking: Blocking,
label: str,
entity: str,
association: Association | None,
) -> BlockingSet (or with None clear) the association of entity of block label.
symmetry function
symmetry(blocking: Blocking, point: Any, normal: Any) -> BlockingA 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
on_plane(points: np.ndarray, plane: Plane, tol: float) -> np.ndarrayWhich of points (..., 3) lie within tol of plane.
plane_tolerance function
plane_tolerance(points: np.ndarray) -> float1e-9 of the extent of points: their distance to a plane they lie on.
effective_associations function
effective_associations(blocking: Blocking) -> dict[EntityKey, Association]Every entity's association: its own, else inherited (module docstring).
tfi_face function
tfi_face(
i_lo: np.ndarray,
i_hi: np.ndarray,
j_lo: np.ndarray,
j_hi: np.ndarray,
) -> np.ndarrayCoons 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
tfi_volume(x: np.ndarray) -> NoneFill the interior of x (ni, nj, nk, 3) by TFI of its six faces, in place.
premesh function
premesh(blocking: Blocking, resolver: AssociationResolver | None) -> list[HexBlock]The blocking's blocks as HexBlocks (module docstring).