shore.project.project
Project: the stateful document the CLI, the Python API and the GUI drive.
Every change goes through a Command (shore.project.commands); the public methods below build one and execute it. The project keeps the applied commands as its history, so it can undo and redo them and render them as a journal: a plain Python script of the same method calls that shore run replays (ADR 0004).
A project holds named geometries and named components (ADR 0016): every mesh command acts on the current component (use_component; the default is "main"), and write_xall writes the Xall files of all of them.
On disk a project is a directory (format 3; 1 and 2 still load):
project.toml metadata: format, shore version, components
and their block labels, input hashes
journal.py the state-changing history, reading inputs/
inputs/ copies of every file the journal reads
adjacency.json the current component's face graph
grids/<component>/<n>.npz node arrays, checked on load
grids/<component>/adjacency.json each component's face graph (ADR 0033)Project.load checks the input copies against their hashes, replays journal.py with the inputs resolved against the project directory (wherever it now is), and requires every grid to match the saved one to GRID_TOLERANCE (1e-10 of the block's size, ADR 0061: the last bits depend on the machine), so a load is also a determinism check. Format-1 projects (one mesh, inputs at their journaled paths) still load. load(replay=False) (ADR 0033) skips the rebuild: the journal is recorded (geometries loaded, components selected), and each component's blocks are read from its grids and rewired from its face graph.
Project class
Project(undo_root: str | Path | None = None)Meshing project: geometries, components and the command history that made them.
Project.mesh property
mesh: Mesh | NoneThe current component's mesh.
Project.build property
build: BuildState | NoneWhat later commands need from the command that made the current mesh.
Project.blocking property
blocking: Blocking | NoneThe current component's blocking (ADR 0042).
Project.blockings property
blockings: dict[str, Blocking | None]Each component's blocking (None without one), in creation order.
Project.require_blocking method
require_blocking(command: str) -> BlockingProject.body property
body: Body | NoneThe geometry named "body" (the default of every command).
Project.geometries property
geometries: Mapping[str, Body]Loaded geometries by name (read-only).
Project.components property
components: dict[str, Mesh | None]Each component's mesh (None while empty), in creation order.
Project.current_component property
current_component: strProject.require_geometry method
require_geometry(name: str, command: str) -> BodyProject.geometry_digest method
geometry_digest(name: str) -> str | NoneSHA-256 of the file geometry name was loaded from (None if not loaded).
Project.set_geometry method
set_geometry(name: str, body: Body | None, digest: str | None = None) -> NoneRegister (or, with None, remove) geometry name; for commands.
Project.discard_built_on method
discard_built_on(name: str) -> dict[str, tuple[Mesh | None, BuildState | None]]Empty the components whose mesh was built on geometry name; return their previous state for restore_components. For commands.
Project.restore_components method
restore_components(old: dict[str, tuple[Mesh | None, BuildState | None]]) -> NoneProject.select_component method
select_component(name: str) -> boolMake name current, creating it if new; True if it was created. For commands.
Project.drop_component method
drop_component(name: str) -> NoneRemove component name (not the current one). For commands.
Project.load_geometry method
load_geometry(
path: str | Path,
anchor_strategy: str = 'auto',
skip_hygiene: bool = False,
*,
name: str = 'body',
) -> NoneLoad geometry name from STL or STEP/IGES/BREP (ADR 0016).
Project.use_component method
use_component(name: str) -> NoneMake component name current, creating it empty if new (ADR 0016).
Project.build_topology method
build_topology(
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] | None = None,
geometry: str = 'body',
**params: Any,
) -> NoneBuild the blocks of topology on geometry (see shore.pipeline.build_topology). A cubed sphere without theta_cap gets its default (30 deg, ADR 0054; 0.05 pi while a project saved before format 4 replays), journaled explicitly.
Project.march method
march(
smooth_strength: float = 0.2,
smooth_iters: int = 2,
blend_normals_k: int | None = None,
smooth_mode: str = 'limited',
march_scheme: str = 'algebraic',
*,
progress: ProgressFn | None = None,
cancel: CancelToken | None = None,
) -> NoneExtrude the blocks from the wall; progress / cancel are hooks.
blend_normals_k is removed (ADR 0034): 0 warns, anything else is refused when the command runs (a journal loaded without replay keeps it).
Project.snap method
snap(exact: bool = False) -> NoneProject associated nodes onto their geometry (any project geometry, ADR 0039).
Project.redistribute method
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',
) -> NoneApply a spacing law along edge of block to the lines of its axis, through the seams (Redistribute, ADR 0041); then snap if needed.
Project.associate method
associate(
block: str,
entity: str,
geometry: str = 'body',
kind: str = 'body',
indices: Sequence[int] = (),
) -> NoneAssociate face, edge or vertex entity of block (current component) with entities indices of kind kind of geometry geometry, or clear it (kind="none"); see Associate (ADR 0003, 0039).
Project.create_blocking method
create_blocking(
ni: int,
nj: int,
nk: int,
*,
geometry: str = 'body',
margin: float = 0.0,
vmin: Sequence[float] | None = None,
vmax: Sequence[float] | None = None,
) -> NoneStart the blocking with one block of ni x nj x nk nodes around geometry (bounding box grown by margin x its extent per side) or between vmin and vmax (CreateBlocking, ADR 0042).
Project.split_blocking method
split_blocking(block: str, axis: str, fraction: float) -> NoneCut block across axis at fraction, through its sheet (SplitBlocking).
Project.delete_blocks method
delete_blocks(blocks: Sequence[str]) -> NoneRemove blocking blocks blocks (DeleteBlocks).
Project.ogrid method
ogrid(
blocks: Sequence[str] = (),
*,
faces: Sequence[Sequence[str]] = (),
exclude: Sequence[Sequence[str]] = (),
factor: float = 0.5,
nodes: int = 5,
) -> NoneInsert an O-grid on the faces of blocking blocks blocks (all when empty): faces, or the set's boundary less exclude ((block, face) pairs), sized by factor, nodes across (Ogrid, ADR 0043).
Project.move_vertex method
move_vertex(block: str, vertex: str, xyz: Sequence[float]) -> NoneMove blocking vertex vertex (v0..v7) of block to xyz, onto its association if it has one (MoveVertex, ADR 0045).
Project.associate_blocking method
associate_blocking(
block: str,
entity: str,
geometry: str = 'body',
kind: str = 'body',
indices: Sequence[int] = (),
) -> NoneAssociate face, edge or vertex entity of blocking block block with geometry, as associate does for mesh blocks (AssociateBlocking).
Project.symmetry_plane method
symmetry_plane(point: Sequence[float], normal: Sequence[float]) -> NoneDeclare a symmetry plane of the blocking through point, normal to normal (SymmetryPlane, ADR 0053).
Project.premesh method
premesh(exact: bool = False) -> NoneMake the component's mesh from its blocking (Premesh, ADR 0042).
Project.orthogonalize method
orthogonalize(strength: float = 1.0) -> NoneMake the grid lines leave the walls along their normal (Orthogonalize, ADR 0048).
Project.wall_layer method
wall_layer(first_step: float) -> NoneCluster the nodes towards the walls, the first cell first_step long (WallLayer, ADR 0050).
Project.surface_grid method
surface_grid(
block: str,
face: str,
*,
surface: int,
smoothing: str = 'elliptic',
geometry: str = 'body',
) -> NoneRebuild face of block from its boundary on SURFACE entity surface of geometry (TFI + elliptic smoothing in (u, v), ADR 0007).
Project.build_primitive method
build_primitive(kind: str, **params: Any) -> NoneBuild a parametric primitive (box, annulus, flat_caps, h_grid_rect, h_grid_tube); see shore.pipeline.build_primitive.
Project.build_collar method
build_collar(
other: str | Path,
*,
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,
) -> NoneCollar block around the junction of geometry and other, a geometry name or a file path (ADR 0010, 0016); with plane the half-collar of a half model (ADR 0013); loop_* distribute the nodes along the junction curve (ADR 0020); split cuts the collar at sharp corners, with wakes of wake_length (ADR 0024); volume the outer-boundary construction (ADR 0025). Replaces the current component's mesh. See BuildCollar.
Project.build_tip_cap method
build_tip_cap(body_geo: str | Path, **options: Any) -> NoneWing-tip cap from a C-grid body .geo; options as BuildTipCap.
Project.load_blocks method
load_blocks(
geo_paths: list[str | Path],
adjacency: list[str | Path] | tuple = (),
) -> NoneReplace the mesh with blocks read from .geo files (+ sidecars).
Project.split method
split(splits: list[tuple[str, str, list[int] | tuple[int, ...]]]) -> NoneSplit blocks by (label, axis, at) directives.
Project.write_geo method
write_geo(stem: str | Path, per_block: bool = False) -> NoneWrite the .geo files (see WriteGeo for the naming rules).
Project.write_grd method
write_grd(path: str | Path, geo_paths: list[str | Path]) -> NonePack .geo files into an Xall .grd.
Project.write_cc_par method
write_cc_par(adjacency: str | Path, path: str | Path, **options: Any) -> NoneWrite an Xall cc.par; options as WriteCcPar.
Project.write_proc_input method
write_proc_input(grd: str | Path, path: str | Path, **options: Any) -> NoneWrite an Xall proc.input; options as WriteProcInput.
Project.write_adjacency method
write_adjacency(path: str | Path) -> NoneWrite the .adjacency.json sidecar.
Project.write_cgns method
write_cgns(path: str | Path, components: Sequence[str] = ()) -> NoneWrite a CGNS file of components (all with a mesh when empty): a base per component, a zone per block, 1-to-1 connections and BCs from the face graph (ADR 0035). Needs h5py (shore-mesh[cgns]).
Project.write_plot3d method
write_plot3d(path: str | Path, components: Sequence[str] = ()) -> NoneWrite the blocks of components (all with a mesh when empty) as one multi-block Plot3D grid file (ADR 0035).
Project.write_xall method
write_xall(
directory: str | Path,
*,
grd: str = 'mesh.grd',
np: int = 1,
components: dict[str, dict[str, Any]] | None = None,
output_basename: str = 'cc.',
multigrid_levels: tuple[int, int] = (4, 1),
boundary_layer_thickness: float = -0.1,
numerical_beach: float = -1.0,
) -> NoneWrite the Xall files of every component, merged; per-component and run-wide options as WriteXall (ADR 0016, 0017).
Project.execute method
execute(
command: Command,
*,
progress: ProgressFn | None = None,
cancel: CancelToken | None = None,
) -> NoneApply command, record it, and clear the redo stack.
While a project loads without replay (ADR 0033) only geometries and component switches are applied; the other commands are recorded.
Project.undo method
undo() -> CommandRevert the last state-changing command (and any outputs after it).
Project.rollback method
rollback(length: int) -> NoneRevert and forget every command after the first length (ADR 0062).
For a group of commands that failed part-way (a CLI command run on this project): the state-changing ones are restored, newest first, and none of them stays in the history or the redo stack.
Project.redo method
redo() -> CommandRe-apply the last undone command.
Project.history property
history: list[Command]Applied commands, oldest first (undone ones excluded).
Project.require_mesh method
require_mesh() -> tuple[Mesh, BuildState]Project.journal method
journal() -> strThe history as a replayable Python script.
Project.save_journal method
save_journal(path: str | Path) -> PathProject.save method
save(directory: str | Path) -> PathWrite the project directory, inputs included (see module docstring).
Project.load classmethod
load(directory: str | Path, *, replay: bool = True) -> ProjectReplay a project directory's journal and verify its saved grids.
With replay=False (ADR 0033) the journal is only recorded: geometries are loaded and components selected, but no mesh is rebuilt; each component's blocks come from its saved grids and face graph. The loaded history cannot be undone, and a loaded mesh cannot be marched.
Project.close method
close() -> NoneDelete the on-disk undo snapshots.
run_journal function
run_journal(path: str | Path, input_dir: str | Path | None = None) -> ProjectExecute a journal script and return the Project it built (p).
With input_dir, relative input paths in the journal resolve against it (a saved project's directory). A journal is Python: run only journals you trust.