Skip to content

shore.project.commands ​

Commands: the only way to change a Project (ADR 0004).

A command is a frozen dataclass. apply changes the project and returns an Undo (or None for output-only commands such as WriteGeo); to_source renders the command as the one line of public Python API that re-issues it, which is what the journal records.

Node-array changes (march, snap) are undone from snapshots that the UndoCache keeps on disk, not in RAM: a 1e7-node grid is 240 MB.

A project holds named geometries and named components (ADR 0016); mesh commands act on the current component. Commands that read files name those fields in inputs: Project.save copies the files into the project, and a replay resolves relative input paths against input_root (the saved project's directory).

resolve_input function ​

python
resolve_input(path: str) -> str

source

path, relative to input_root when that is set and path is relative.

Cancelled class ​

python
class Cancelled(ShoreError)

source

Raised inside a long command when its CancelToken was set.

CancelToken class ​

python
CancelToken()

source

Cooperative cancellation flag, checked once per layer / sweep.

CancelToken.cancel method ​

python
cancel() -> None

source

CancelToken.check method ​

python
check() -> None

source

Context dataclass ​

python
Context(progress: ProgressFn | None = None, cancel: CancelToken | None = None)

source

Per-execution hooks: progress reporting and cancellation.

Context.report method ​

python
report(fraction: float, message: str = '') -> None

source

Context.check method ​

python
check() -> None

source

Undo dataclass ​

python
Undo(restore: Callable[[], None])

source

How to revert one applied command.

UndoCache class ​

python
UndoCache(root: Path | None = None)

source

On-disk store of node-array snapshots, deleted with the project.

UndoCache.snapshot method ​

python
snapshot(mesh: Mesh) -> Callable[[], None]

source

Save every block's nodes; return a function restoring them in place.

UndoCache.close method ​

python
close() -> None

source

Command class ​

python
class Command(ABC)

source

Base of all commands. Subclasses are frozen dataclasses.

Command.apply method ​

python
apply(project: Project, ctx: Context) -> Undo | None

source

Command.to_source method ​

python
to_source() -> str

source

p.<method>(...) with positional fields and non-default keywords.

LoadGeometry dataclass ​

python
LoadGeometry(
    path: str,
    anchor_strategy: str = 'auto',
    skip_hygiene: bool = False,
    name: str = 'body',
)

Bases: Command
source

Load a geometry (STL or STEP/IGES/BREP) under name.

Reloading a name replaces that geometry and discards the meshes of the components built on it (ADR 0016).

LoadGeometry.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

UseComponent dataclass ​

python
UseComponent(name: str)

Bases: Command
source

Make name the current component, creating it empty if new (ADR 0016).

UseComponent.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

BuildTopology dataclass ​

python
BuildTopology(
    topology: str,
    nk: int,
    ds: float = 0.001,
    growth: float = 1.15,
    k_law: str = 'geometric',
    k_beta: float = 3.0,
    k_thickness: float | None = None,
    options: dict[str, Any] = field(default_factory=dict),
    params: dict[str, Any] = field(default_factory=dict),
    geometry: str = 'body',
)

Bases: Command
source

Build the topology's blocks on the body (shore mesh stage 2).

The k-spacing fields define the wall-normal law used both by the topology (seam pinning) and by March. options are the topology constructor's arguments (ch, oh); params go to its build.

BuildTopology.to_source method ​

python
to_source() -> str

source

BuildTopology.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

BuildState dataclass ​

python
BuildState(
    topology: str,
    nk: int,
    ds: float = 0.0,
    growth: float = 0.0,
    spacing: Any = None,
    writer: Callable[[Path], None] | None = None,
    marchable: bool = True,
    geometries: tuple[str, ...] = (),
)

source

What later commands need from the command that made the mesh.

March dataclass ​

python
March(
    smooth_strength: float = 0.2,
    smooth_iters: int = 2,
    blend_normals_k: int = 0,
    smooth_mode: str = 'limited',
    march_scheme: str = 'algebraic',
)

Bases: Command
source

Extrude all blocks from the wall (shore mesh stage 3).

March.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

Snap dataclass ​

python
Snap(exact: bool = False)

Bases: Command
source

Project associated nodes onto their geometry (ADR 0003).

Snap.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

Associate dataclass ​

python
Associate(
    block: str,
    entity: str,
    geometry: str = 'body',
    kind: str = 'body',
    indices: tuple[int, ...] = (),
)

Bases: Command
source

Associate a block face, edge or vertex with geometry (ADR 0003, 0039).

entity is a face ("k_lo"), an edge ("i_lo_k_lo") or a vertex ("v0" .. "v7", HexBlock.vertices() order) of block block of the current component. kind is "body", "surface", "curve" or "point" with entity indices of geometry geometry (none for "body"), or "none" to clear. An entity may be associated with geometry of its own dimension or higher: a face with surfaces or the body, an edge also with curves, a vertex also with a point. Nodes move only on snap.

Associate.to_source method ​

python
to_source() -> str

source

Associate.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

Redistribute dataclass ​

python
Redistribute(
    block: str,
    edge: str,
    law: str = 'uniform',
    beta: float = 3.0,
    cluster_at: float | None = None,
    first_step: float | None = None,
    last_step: float | None = None,
    interior: str = 'uniform',
)

Bases: Command
source

Redistribute the nodes along a block edge's axis (ADR 0041).

The spacing law (uniform, tanh, tanh2 with beta and cluster_at, pinned with first_step / last_step lengths and an interior law) is taken over the arc length of edge of block (current component) and applied, as arc-length fractions, to every grid line of the block along that axis, and through SHARED / DIRICHLET seams to the blocks sharing a face that contains the axis. Nodes stay on their lines' old polylines; line ends do not move. Associated nodes are not re-snapped: run snap after.

Redistribute.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

Orthogonalize dataclass ​

python
Orthogonalize(strength: float = 1.0)

Bases: Command
source

Make the grid lines leave the walls along their normal (ADR 0048).

Every block of the current mesh with exactly one WALL face has its lines across the wall reshaped (shore.mesh.orthogonal, tangent strength times the chord); blocks whose faces the seams change are re-filled by TFI. Refused, with nothing changed, if a block that was valid would be inverted (lower strength).

Orthogonalize.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

WallLayer dataclass ​

python
WallLayer(first_step: float)

Bases: Command
source

Cluster the nodes towards the walls (ADR 0050): on every line across the wall of each block with one WALL face, geometric cells from the wall with the first first_step long (an absolute length), on the line's own polyline (after orthogonalize: along the wall normal). Refused if a line cannot hold it or a valid block would invert.

WallLayer.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

FillFace dataclass ​

python
FillFace(
    block: str,
    face: str,
    surface: int,
    smoothing: str = 'elliptic',
    geometry: str = 'body',
)

Bases: Command
source

Rebuild one block face from its boundary on a CAD surface (ADR 0007).

The face's four boundary rows stay as they are; the interior is filled by shore.surface.tfi.surface_grid on SURFACE entity number surface of the loaded geometry.

FillFace.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

CreateBlocking dataclass ​

python
CreateBlocking(
    ni: int,
    nj: int,
    nk: int,
    geometry: str = 'body',
    margin: float = 0.0,
    vmin: tuple[float, float, float] | None = None,
    vmax: tuple[float, float, float] | None = None,
)

Bases: Command
source

Start the current component's blocking with one block (ADR 0042).

The block is the bounding box of geometry geometry, each side moved out by margin times the box's extent along that axis, or the box between vmin and vmax; it has ni x nj x nk nodes. Replaces the component's blocking; its mesh changes only on premesh.

CreateBlocking.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

SplitBlocking dataclass ​

python
SplitBlocking(block: str, axis: str, fraction: float)

Bases: Command
source

Cut block block of the blocking across axis at the node nearest fraction of it, and every block sharing a cut edge with it (ADR 0042). The low part keeps the label; the high part is b<n>, n counting up.

SplitBlocking.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

DeleteBlocks dataclass ​

python
DeleteBlocks(blocks: tuple[str, ...])

Bases: Command
source

Remove blocks blocks from the blocking; the faces they leave become boundary faces (ADR 0042).

DeleteBlocks.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

Ogrid dataclass ​

python
Ogrid(
    blocks: tuple[str, ...] = (),
    faces: tuple[tuple[str, str], ...] = (),
    exclude: tuple[tuple[str, str], ...] = (),
    factor: float = 0.5,
    nodes: int = 5,
)

Bases: Command
source

Insert an O-grid in the blocking (ADR 0043): a layer of blocks on the faces of the block set blocks (every block when empty), faces or all the set's boundary faces less exclude ((block, face) pairs); see shore.mesh.blocking.ogrid. factor sizes it, nodes across.

Ogrid.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

MoveVertex dataclass ​

python
MoveVertex(block: str, vertex: str, xyz: tuple[float, float, float])

Bases: Command
source

Move a blocking vertex (ADR 0045): vertex vertex (v0..v7) of block block to xyz, projected onto its association (own or inherited) when it has one, so an associated vertex slides on its geometry.

MoveVertex.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

SymmetryPlane dataclass ​

python
SymmetryPlane(point: tuple[float, float, float], normal: tuple[float, float, float])

Bases: Command
source

Declare a symmetry plane of the current blocking (ADR 0053): point on it, normal to it. premesh makes the boundary faces lying on it without an association SYMMETRY faces; orthogonalize keeps the lines leaving the wall from the plane in the plane.

SymmetryPlane.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

AssociateBlocking dataclass ​

python
AssociateBlocking(
    block: str,
    entity: str,
    geometry: str = 'body',
    kind: str = 'body',
    indices: tuple[int, ...] = (),
)

Bases: Command
source

Associate a face, edge or vertex of a blocking block with geometry (ADR 0042): as associate (ADR 0039), on the blocking. Entities without an association of their own inherit one on premesh.

AssociateBlocking.to_source method ​

python
to_source() -> str

source

AssociateBlocking.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

Premesh dataclass ​

python
Premesh(exact: bool = False)

Bases: Command
source

Make the current component's mesh from its blocking (ADR 0042): edges, faces and blocks by TFI, projected onto their associations (exact: tier-2 CAD projection). Replaces the mesh.

Premesh.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

WriteGeo dataclass ​

python
WriteGeo(stem: str, per_block: bool = False)

Bases: Command
source

Write .geo files (output only).

Naming: a primitive's own rule (shore primitive), unless per_block; otherwise shore mesh's rule: one <stem>.geo for a single non-cubed-sphere block, else <stem>_<label>.geo per block (always the latter with per_block, as shore split and shore cap-tip write).

WriteGeo.apply method ​

python
apply(project: Project, ctx: Context) -> None

source

WriteAdjacency dataclass ​

python
WriteAdjacency(path: str)

Bases: Command
source

Write the .adjacency.json sidecar (output only).

WriteAdjacency.apply method ​

python
apply(project: Project, ctx: Context) -> None

source

WriteCgns dataclass ​

python
WriteCgns(path: str, components: tuple[str, ...] = ())

Bases: Command
source

Write a CGNS file: a base per component, a zone per block (ADR 0035; output only).

WriteCgns.apply method ​

python
apply(project: Project, ctx: Context) -> None

source

WritePlot3d dataclass ​

python
WritePlot3d(path: str, components: tuple[str, ...] = ())

Bases: Command
source

Write a multi-block Plot3D grid file of the components' blocks (ADR 0035; output only).

WritePlot3d.apply method ​

python
apply(project: Project, ctx: Context) -> None

source

BuildPrimitive dataclass ​

python
BuildPrimitive(kind: str, params: dict[str, Any] = field(default_factory=dict))

Bases: Command
source

Build a parametric primitive (shore primitive); replaces the mesh.

BuildPrimitive.to_source method ​

python
to_source() -> str

source

BuildPrimitive.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

BuildTipCap dataclass ​

python
BuildTipCap(
    body_geo: str,
    tip: str = 'jlo',
    le_frac: float = 0.05,
    te_frac: float | None = None,
    span_axis: str = 'z',
    tip_inset: float | None = None,
    nk: int | None = None,
    n_cap_j: int = 12,
    cap_j_spacing: str = 'tanh',
    cap_j_beta: float = 4.0,
    auto_round_te: bool = True,
    te_thickness: float | None = None,
    te_thickness_frac: float | None = 0.002,
    core_frac: float = 0.5,
    flare_deg: float = 30.0,
)

Bases: Command
source

Wing-tip cap from a C-grid body .geo (shore cap-tip); replaces the mesh.

BuildTipCap.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

BuildCollar dataclass ​

python
BuildCollar(
    other: str,
    seed: tuple[float, float, float],
    n_loop: int,
    ds_surface: float,
    growth_surface: float,
    m_a: int,
    m_b: int,
    ds_wall: float,
    growth_wall: float,
    nk: int,
    label: str = 'collar',
    plane: tuple[tuple[float, float, float], tuple[float, float, float]] | None = None,
    geometry: str = 'body',
    loop_law: str = 'uniform',
    loop_beta: float = 3.0,
    loop_cluster_at: float | None = None,
    loop_curvature: float = 0.0,
    split: bool = False,
    wake_length: float | None = None,
    volume: str | None = None,
)

Bases: Command
source

Collar block around the junction of the loaded body and other (ADR 0010).

Body A is the project's geometry, body B is loaded from the file other (its path is what the journal records). Surface steps are ds_surface * growth_surface**j (m_a on A, m_b on B), wall-normal steps ds_wall * growth_wall**k (nk of them). With plane ((point, normal)) the half-collar of a half model (ADR 0013). The nodes along the junction curve follow Spacing1D(loop_law, beta=loop_beta, cluster_at=loop_cluster_at) and loop_curvature (ADR 0020). With split, split_collar (ADR 0024): the loop is cut at sharp corners, with wakes of wake_length (default: the collar's width on A), six blocks per piece (closed loops only). volume is CollarParams.volume (ADR 0025): "stations" or "smoothed"; None, the default ("smoothed"; "stations" when a project saved before format 3 replays, ADR 0026). Replaces the mesh with the collar's block(s), a separate Chimera component.

BuildCollar.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

LoadBlocks dataclass ​

python
LoadBlocks(geo_paths: tuple[str, ...], adjacency: tuple[str, ...] = ())

Bases: Command
source

Blocks from .geo files, wired from adjacency sidecars; replaces the mesh.

LoadBlocks.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

Split dataclass ​

python
Split(splits: tuple[tuple[str, str, tuple[int, ...]], ...])

Bases: Command
source

Split blocks by (label, axis, at) directives (shore split).

Split.apply method ​

python
apply(project: Project, ctx: Context) -> Undo

source

WriteGrd dataclass ​

python
WriteGrd(path: str, geo_paths: tuple[str, ...])

Bases: Command
source

Pack .geo files into an Xall .grd (shore grd, output only).

Packs from the .geo files, not from memory, so the .grd carries the .geo print precision exactly as the file pipeline does.

WriteGrd.apply method ​

python
apply(project: Project, ctx: Context) -> None

source

WriteCcPar dataclass ​

python
WriteCcPar(
    adjacency: str,
    path: str,
    grd_filename: str,
    output_basename: str = 'cc.',
    free_face_bc: int = 40,
    multigrid_levels: tuple[int, int] = (4, 1),
    boundary_layer_thickness: float = -0.1,
    numerical_beach: float = -1.0,
    meta: dict[str, dict[str, Any]] = field(default_factory=dict),
    boxes: tuple[dict[str, Any], ...] = (),
)

Bases: Command
source

Xall cc.par from an adjacency sidecar (shore cc-par, output only).

meta maps block labels to BlockMeta overrides (level, group, priority, comment, free_face_bc); boxes is a list of marker-box JSON entries.

WriteCcPar.apply method ​

python
apply(project: Project, ctx: Context) -> None

source

WriteXall dataclass ​

python
WriteXall(
    directory: str,
    grd: str = 'mesh.grd',
    np: int = 1,
    components: dict[str, dict[str, Any]] = field(default_factory=dict),
    output_basename: str = 'cc.',
    multigrid_levels: tuple[int, int] = (4, 1),
    boundary_layer_thickness: float = -0.1,
    numerical_beach: float = -1.0,
)

Bases: Command
source

The Xall files of the whole run, every component (ADR 0016, 0017; output only).

For each component with a mesh, in creation order, into directory/<component>/: the .geo files (one per block), the adjacency sidecar, <component>.grd and cc.par, written by the same commands as write_geo / write_adjacency / write_grd / write_cc_par. Then, in directory, grd and cc.par merged from them (merge_grd, merge_cc_par) and one proc.input balanced over the merged .grd on np ranks.

The cc.par header options apply to every component (merge_cc_par requires them to agree). components maps a component to its options: free_face_bc / meta / boxes for its cc.par (as write_cc_par), body for all its blocks in proc.input, and proc_meta (block label -> proc / group / body) per block. All of it is checked before anything is written.

WriteXall.apply method ​

python
apply(project: Project, ctx: Context) -> None

source

WriteProcInput dataclass ​

python
WriteProcInput(
    grd: str,
    path: str,
    np: int = 1,
    meta: dict[str, dict[str, int]] = field(default_factory=dict),
    header_comment: str = 'generated by SHORE',
)

Bases: Command
source

Xall proc.input from a .grd (shore proc-input, output only).

meta maps 1-based block indices (as strings) to proc / group / body overrides.

WriteProcInput.apply method ​

python
apply(project: Project, ctx: Context) -> None

source

Released under the MIT License.