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
resolve_input(path: str) -> strpath, relative to input_root when that is set and path is relative.
Cancelled class
class Cancelled(ShoreError)Raised inside a long command when its CancelToken was set.
CancelToken class
CancelToken()Cooperative cancellation flag, checked once per layer / sweep.
CancelToken.cancel method
cancel() -> NoneCancelToken.check method
check() -> NoneContext dataclass
Context(progress: ProgressFn | None = None, cancel: CancelToken | None = None)Per-execution hooks: progress reporting and cancellation.
Context.report method
report(fraction: float, message: str = '') -> NoneContext.check method
check() -> NoneUndo dataclass
Undo(restore: Callable[[], None])How to revert one applied command.
UndoCache class
UndoCache(root: Path | None = None)On-disk store of node-array snapshots, deleted with the project.
UndoCache.snapshot method
snapshot(mesh: Mesh) -> Callable[[], None]Save every block's nodes; return a function restoring them in place.
UndoCache.close method
close() -> NoneCommand class
class Command(ABC)Base of all commands. Subclasses are frozen dataclasses.
Command.apply method
apply(project: Project, ctx: Context) -> Undo | NoneCommand.to_source method
to_source() -> strp.<method>(...) with positional fields and non-default keywords.
LoadGeometry dataclass
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
apply(project: Project, ctx: Context) -> UndoUseComponent dataclass
UseComponent(name: str)Bases: Command
source
Make name the current component, creating it empty if new (ADR 0016).
UseComponent.apply method
apply(project: Project, ctx: Context) -> UndoBuildTopology dataclass
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
to_source() -> strBuildTopology.apply method
apply(project: Project, ctx: Context) -> UndoBuildState dataclass
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, ...] = (),
)What later commands need from the command that made the mesh.
March dataclass
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
apply(project: Project, ctx: Context) -> UndoSnap dataclass
Snap(exact: bool = False)Bases: Command
source
Project associated nodes onto their geometry (ADR 0003).
Snap.apply method
apply(project: Project, ctx: Context) -> UndoAssociate dataclass
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
to_source() -> strAssociate.apply method
apply(project: Project, ctx: Context) -> UndoRedistribute dataclass
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
apply(project: Project, ctx: Context) -> UndoOrthogonalize dataclass
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
apply(project: Project, ctx: Context) -> UndoWallLayer dataclass
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
apply(project: Project, ctx: Context) -> UndoFillFace dataclass
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
apply(project: Project, ctx: Context) -> UndoCreateBlocking dataclass
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
apply(project: Project, ctx: Context) -> UndoSplitBlocking dataclass
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
apply(project: Project, ctx: Context) -> UndoDeleteBlocks dataclass
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
apply(project: Project, ctx: Context) -> UndoOgrid dataclass
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
apply(project: Project, ctx: Context) -> UndoMoveVertex dataclass
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
apply(project: Project, ctx: Context) -> UndoSymmetryPlane dataclass
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
apply(project: Project, ctx: Context) -> UndoAssociateBlocking dataclass
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
to_source() -> strAssociateBlocking.apply method
apply(project: Project, ctx: Context) -> UndoPremesh dataclass
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
apply(project: Project, ctx: Context) -> UndoWriteGeo dataclass
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
apply(project: Project, ctx: Context) -> NoneWriteAdjacency dataclass
WriteAdjacency(path: str)Bases: Command
source
Write the .adjacency.json sidecar (output only).
WriteAdjacency.apply method
apply(project: Project, ctx: Context) -> NoneWriteCgns dataclass
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
apply(project: Project, ctx: Context) -> NoneWritePlot3d dataclass
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
apply(project: Project, ctx: Context) -> NoneBuildPrimitive dataclass
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
to_source() -> strBuildPrimitive.apply method
apply(project: Project, ctx: Context) -> UndoBuildTipCap dataclass
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
apply(project: Project, ctx: Context) -> UndoBuildCollar dataclass
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
apply(project: Project, ctx: Context) -> UndoLoadBlocks dataclass
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
apply(project: Project, ctx: Context) -> UndoSplit dataclass
Split(splits: tuple[tuple[str, str, tuple[int, ...]], ...])Bases: Command
source
Split blocks by (label, axis, at) directives (shore split).
Split.apply method
apply(project: Project, ctx: Context) -> UndoWriteGrd dataclass
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
apply(project: Project, ctx: Context) -> NoneWriteCcPar dataclass
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
apply(project: Project, ctx: Context) -> NoneWriteXall dataclass
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
apply(project: Project, ctx: Context) -> NoneWriteProcInput dataclass
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
apply(project: Project, ctx: Context) -> None