Skip to content

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 ​

python
Project(undo_root: str | Path | None = None)

source

Meshing project: geometries, components and the command history that made them.

Project.mesh property ​

python
mesh: Mesh | None

source

The current component's mesh.

Project.build property ​

python
build: BuildState | None

source

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

Project.blocking property ​

python
blocking: Blocking | None

source

The current component's blocking (ADR 0042).

Project.blockings property ​

python
blockings: dict[str, Blocking | None]

source

Each component's blocking (None without one), in creation order.

Project.require_blocking method ​

python
require_blocking(command: str) -> Blocking

source

Project.body property ​

python
body: Body | None

source

The geometry named "body" (the default of every command).

Project.geometries property ​

python
geometries: Mapping[str, Body]

source

Loaded geometries by name (read-only).

Project.components property ​

python
components: dict[str, Mesh | None]

source

Each component's mesh (None while empty), in creation order.

Project.current_component property ​

python
current_component: str

source

Project.require_geometry method ​

python
require_geometry(name: str, command: str) -> Body

source

Project.geometry_digest method ​

python
geometry_digest(name: str) -> str | None

source

SHA-256 of the file geometry name was loaded from (None if not loaded).

Project.set_geometry method ​

python
set_geometry(name: str, body: Body | None, digest: str | None = None) -> None

source

Register (or, with None, remove) geometry name; for commands.

Project.discard_built_on method ​

python
discard_built_on(name: str) -> dict[str, tuple[Mesh | None, BuildState | None]]

source

Empty the components whose mesh was built on geometry name; return their previous state for restore_components. For commands.

Project.restore_components method ​

python
restore_components(old: dict[str, tuple[Mesh | None, BuildState | None]]) -> None

source

Project.select_component method ​

python
select_component(name: str) -> bool

source

Make name current, creating it if new; True if it was created. For commands.

Project.drop_component method ​

python
drop_component(name: str) -> None

source

Remove component name (not the current one). For commands.

Project.load_geometry method ​

python
load_geometry(
    path: str | Path,
    anchor_strategy: str = 'auto',
    skip_hygiene: bool = False,
    *,
    name: str = 'body',
) -> None

source

Load geometry name from STL or STEP/IGES/BREP (ADR 0016).

Project.use_component method ​

python
use_component(name: str) -> None

source

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

Project.build_topology method ​

python
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,
) -> None

source

Build 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 ​

python
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,
) -> None

source

Extrude 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 ​

python
snap(exact: bool = False) -> None

source

Project associated nodes onto their geometry (any project geometry, ADR 0039).

Project.redistribute method ​

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',
) -> None

source

Apply 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 ​

python
associate(
    block: str,
    entity: str,
    geometry: str = 'body',
    kind: str = 'body',
    indices: Sequence[int] = (),
) -> None

source

Associate 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 ​

python
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,
) -> None

source

Start 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 ​

python
split_blocking(block: str, axis: str, fraction: float) -> None

source

Cut block across axis at fraction, through its sheet (SplitBlocking).

Project.delete_blocks method ​

python
delete_blocks(blocks: Sequence[str]) -> None

source

Remove blocking blocks blocks (DeleteBlocks).

Project.ogrid method ​

python
ogrid(
    blocks: Sequence[str] = (),
    *,
    faces: Sequence[Sequence[str]] = (),
    exclude: Sequence[Sequence[str]] = (),
    factor: float = 0.5,
    nodes: int = 5,
) -> None

source

Insert 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 ​

python
move_vertex(block: str, vertex: str, xyz: Sequence[float]) -> None

source

Move blocking vertex vertex (v0..v7) of block to xyz, onto its association if it has one (MoveVertex, ADR 0045).

Project.associate_blocking method ​

python
associate_blocking(
    block: str,
    entity: str,
    geometry: str = 'body',
    kind: str = 'body',
    indices: Sequence[int] = (),
) -> None

source

Associate face, edge or vertex entity of blocking block block with geometry, as associate does for mesh blocks (AssociateBlocking).

Project.symmetry_plane method ​

python
symmetry_plane(point: Sequence[float], normal: Sequence[float]) -> None

source

Declare a symmetry plane of the blocking through point, normal to normal (SymmetryPlane, ADR 0053).

Project.premesh method ​

python
premesh(exact: bool = False) -> None

source

Make the component's mesh from its blocking (Premesh, ADR 0042).

Project.orthogonalize method ​

python
orthogonalize(strength: float = 1.0) -> None

source

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

Project.wall_layer method ​

python
wall_layer(first_step: float) -> None

source

Cluster the nodes towards the walls, the first cell first_step long (WallLayer, ADR 0050).

Project.surface_grid method ​

python
surface_grid(
    block: str,
    face: str,
    *,
    surface: int,
    smoothing: str = 'elliptic',
    geometry: str = 'body',
) -> None

source

Rebuild face of block from its boundary on SURFACE entity surface of geometry (TFI + elliptic smoothing in (u, v), ADR 0007).

Project.build_primitive method ​

python
build_primitive(kind: str, **params: Any) -> None

source

Build a parametric primitive (box, annulus, flat_caps, h_grid_rect, h_grid_tube); see shore.pipeline.build_primitive.

Project.build_collar method ​

python
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,
) -> None

source

Collar 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 ​

python
build_tip_cap(body_geo: str | Path, **options: Any) -> None

source

Wing-tip cap from a C-grid body .geo; options as BuildTipCap.

Project.load_blocks method ​

python
load_blocks(
    geo_paths: list[str | Path],
    adjacency: list[str | Path] | tuple = (),
) -> None

source

Replace the mesh with blocks read from .geo files (+ sidecars).

Project.split method ​

python
split(splits: list[tuple[str, str, list[int] | tuple[int, ...]]]) -> None

source

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

Project.write_geo method ​

python
write_geo(stem: str | Path, per_block: bool = False) -> None

source

Write the .geo files (see WriteGeo for the naming rules).

Project.write_grd method ​

python
write_grd(path: str | Path, geo_paths: list[str | Path]) -> None

source

Pack .geo files into an Xall .grd.

Project.write_cc_par method ​

python
write_cc_par(adjacency: str | Path, path: str | Path, **options: Any) -> None

source

Write an Xall cc.par; options as WriteCcPar.

Project.write_proc_input method ​

python
write_proc_input(grd: str | Path, path: str | Path, **options: Any) -> None

source

Write an Xall proc.input; options as WriteProcInput.

Project.write_adjacency method ​

python
write_adjacency(path: str | Path) -> None

source

Write the .adjacency.json sidecar.

Project.write_cgns method ​

python
write_cgns(path: str | Path, components: Sequence[str] = ()) -> None

source

Write 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 ​

python
write_plot3d(path: str | Path, components: Sequence[str] = ()) -> None

source

Write the blocks of components (all with a mesh when empty) as one multi-block Plot3D grid file (ADR 0035).

Project.write_xall method ​

python
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,
) -> None

source

Write the Xall files of every component, merged; per-component and run-wide options as WriteXall (ADR 0016, 0017).

Project.execute method ​

python
execute(
    command: Command,
    *,
    progress: ProgressFn | None = None,
    cancel: CancelToken | None = None,
) -> None

source

Apply 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 ​

python
undo() -> Command

source

Revert the last state-changing command (and any outputs after it).

Project.rollback method ​

python
rollback(length: int) -> None

source

Revert 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 ​

python
redo() -> Command

source

Re-apply the last undone command.

Project.history property ​

python
history: list[Command]

source

Applied commands, oldest first (undone ones excluded).

Project.require_mesh method ​

python
require_mesh() -> tuple[Mesh, BuildState]

source

Project.journal method ​

python
journal() -> str

source

The history as a replayable Python script.

Project.save_journal method ​

python
save_journal(path: str | Path) -> Path

source

Project.save method ​

python
save(directory: str | Path) -> Path

source

Write the project directory, inputs included (see module docstring).

Project.load classmethod ​

python
load(directory: str | Path, *, replay: bool = True) -> Project

source

Replay 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 ​

python
close() -> None

source

Delete the on-disk undo snapshots.

run_journal function ​

python
run_journal(path: str | Path, input_dir: str | Path | None = None) -> Project

source

Execute 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.

Released under the MIT License.