Skip to content

pyflightstream.workspace.sidecars (provisional)

Generated from the docstrings at build time: every one of the 29 names in the __all__ of pyflightstream.workspace.sidecars has an entry below. The names a guide or an example uses come first; the others follow under Advanced.

The files beside a geometry: its boundary inventory, provenance and raw-mesh sidecar.

A geometry of inputs/geometries/ carries a kind-qualified boundary inventory: <stem>.obj.boundaries.toml for raw-mesh declarations and <stem>.fsm.boundaries.toml for the saved simulation's inventory. Legacy <stem>.boundaries.toml files remain readable. An OBJ's declarations include [import], fs_build and named trailing-edge and base-region entries. <stem>.provenance.toml records where the geometry came from; the package never writes that provenance file. This module writes and checks the inventory (the boundary names read off an OBJ or a saved simulation), with the mesh's face count taken at the same time (FR-348, which the post carries and never counts: :func:recorded_mesh_faces), and reads each table of the sidecar with its own reader over one parse.

It also holds the TOML reader of the input library's artifact files, which the artifact resolvers and the HPC profile reader share.

Every public name is re-exported, unchanged, by :mod:pyflightstream.workspace.inputs, its path (AD-11).

Size exemption: one schema of a boundary sidecar, with its reader, writer and refresh beside it.

Used in the guides

pyflightstream.workspace.sidecars.write_inventory

write_inventory(
    geometry: str | Path, *, overwrite: bool = False
) -> Path

Write a kind-qualified boundary inventory beside a saved simulation or OBJ.

The surface order is read from the geometry (PFS-2029.06.02). A sidecar supplies declarations by name; it does not override the order that the solver assigns to the imported surfaces.

AN OBJ IS READ FROM ITS GROUPS (G30). It carries no mesh block, and its sidecar is written through :func:ensure_inventory, the function the matrix binding reaches it through as well, so pyfs-matrix inventory and a plan write the same file. An OBJ's existing sidecar is refused with overwrite too: beside a raw mesh it also carries the [import] table and the trailing edges, which a rewrite of the list would lose. An STL, which names no group, is refused as before.

Parameters:

Name Type Description Default
geometry str or Path

A saved simulation file carrying a mesh block, or an OBJ.

required
overwrite bool

Rewrite a saved simulation's sidecar that already exists. Without it an existing sidecar is refused, because the file may have been edited by the user after it was written.

False

Returns:

Type Description
Path

The sidecar written.

Raises:

Type Description
InputArtifactError

A geometry that cannot be read, that carries no mesh block, or whose block does not hold its shape, each naming the file; a sidecar that already exists, naming it and --overwrite; an OBJ's sidecar that already exists, with overwrite or without; an OBJ whose groups cannot be read (:func:obj_boundary_names).

Examples:

>>> from pathlib import Path
>>> from tempfile import TemporaryDirectory
>>> from pyflightstream.workspace.sidecars import write_inventory
>>> with TemporaryDirectory() as folder:
...     mesh = Path(folder) / "wing.obj"
...     _ = mesh.write_text("v 0 0 0\nv 1 0 0\nv 0 1 0\ng Wing\nf 1 2 3\n")
...     print(write_inventory(mesh).name)
wing.obj.boundaries.toml

Advanced

pyflightstream.workspace.sidecars.BASE_REGIONS_TABLE module-attribute

BASE_REGIONS_TABLE = 'base_regions'

pyflightstream.workspace.sidecars.DETECT_EVERYWHERE module-attribute

DETECT_EVERYWHERE = 'auto'

pyflightstream.workspace.sidecars.GEOMETRIES_README module-attribute

GEOMETRIES_README = 'README.md'

pyflightstream.workspace.sidecars.GEOMETRY_SIDECAR_KEYS module-attribute

GEOMETRY_SIDECAR_KEYS: Mapping[str, InputKey] = {
    "ports": InputKey(
        "Stable port identity to exact surface name; conditions belong to setup and MATRIX.",
        'a table such as [ports] with feed = "Inlet"',
    ),
    "boundaries": InputKey(
        "The mesh's boundary names in the solver's order, the name at position i being boundary i; read from a saved simulation by pyfs-mesh inventory, read from an OBJ's groups by the plan when it has no sidecar, written by hand for an STL.",
        "a list of names",
    ),
    "file": InputKey(
        "The file the inventory was read from, as pyfs-mesh inventory writes it; nothing reads it back.",
        "a file name",
    ),
    MESH_FACES_KEY: InputKey(
        "The mesh's face count, counted when the inventory is taken from a saved simulation or an OBJ; the post carries it as MESH_FACES, and warns where the run's recorded sha256 of the geometry is not mesh_sha256 (FR-348).",
        "a whole number",
    ),
    BOUNDARY_FACES_KEY: InputKey(
        "The face count of each boundary, in the order of boundaries, where the inventory's reader gives it; nothing reads it back.",
        "a list of whole numbers",
    ),
    MESH_SHA256_KEY: InputKey(
        "The sha256 of the file the faces were counted in; the post warns where a run's recorded sha256 of the geometry differs from it.",
        "a sha256, as text",
    ),
    "thin_boundaries": InputKey(
        "The boundaries the solver treats as thin surfaces, by their names in the boundary order; an empty list clears a saved selection. Absent, nothing is emitted.",
        'a list of names, as thin_boundaries = ["Wing"]',
        "SET_THIN_BOUNDARIES, DELETE_THIN_BOUNDARIES",
    ),
    MESH_FRAME_KEY: InputKey(
        "The frame the mesh is built in: what the mesh's +x, +y and +z point to. Absent means x aft, y right, z up, the expected frame; another right-handed axis-aligned frame is converted before the solver reads the mesh, and a left-handed one is refused.",
        'a list of three words, as ["forward", "left", "up"]',
    ),
    IMPORT_TABLE: InputKey(
        "How a raw mesh is imported: the unit it is written in and the operations applied right after.",
        "a table; see `[import]` below",
        "IMPORT",
    ),
    TRAILING_EDGES_TABLE: InputKey(
        "How a raw mesh's trailing edges are marked, which every raw mesh a workflow imports declares.",
        "a table; see `[trailing_edges]` below",
        "IMPORT_WAKE_EDGES_FROM_FILE, AUTO_DETECT_TRAILING_EDGES, DETECT_TRAILING_EDGES_BY_SURFACE",
    ),
    WAKE_TERMINATION_TABLE: InputKey(
        "Detects a raw mesh's wake-termination nodes, only when written.",
        "a table; see `[wake_termination]` below",
        "AUTO_DETECT_WAKE_TERMINATION_NODES, DETECT_WAKE_TERMINATION_NODES_BY_SURFACE",
    ),
    BASE_REGIONS_TABLE: InputKey(
        "Detects a raw mesh's base regions over the whole mesh, only when written.",
        "a table; see `[base_regions]` below",
        "AUTO_DETECT_BASE_REGIONS",
    ),
}

pyflightstream.workspace.sidecars.IMPORT_TABLE module-attribute

IMPORT_TABLE = 'import'

pyflightstream.workspace.sidecars.INVENTORY_SUFFIX module-attribute

INVENTORY_SUFFIX = '.boundaries.toml'

pyflightstream.workspace.sidecars.MESH_FRAME_FOLDER module-attribute

MESH_FRAME_FOLDER = 'mesh_frame'

pyflightstream.workspace.sidecars.MESH_FRAME_KEY module-attribute

MESH_FRAME_KEY = 'mesh_frame'

pyflightstream.workspace.sidecars.MESH_FRAME_RECORD module-attribute

MESH_FRAME_RECORD = 'mesh_frame.json'

pyflightstream.workspace.sidecars.OBJ_SUFFIX module-attribute

OBJ_SUFFIX = '.obj'

pyflightstream.workspace.sidecars.PROVENANCE_SUFFIX module-attribute

PROVENANCE_SUFFIX = '.provenance.toml'

pyflightstream.workspace.sidecars.RAW_MESH_CONDITION_KEYS module-attribute

RAW_MESH_CONDITION_KEYS: Mapping[
    str, Mapping[str, InputKey]
] = {
    TRAILING_EDGES_TABLE: {
        "files": InputKey(
            "Ordered points files, each with its own trailing-edge type.",
            "a nonempty list of file/type tables",
            "IMPORT_WAKE_EDGES_FROM_FILE",
        ),
        "none": InputKey(
            "Explicitly declares a body without a trailing edge; no wake is generated by it.",
            "true, alone in the table",
            "",
        ),
        "file": InputKey(
            "The points file beside the sidecar holding the mid-point of every trailing-edge mesh edge, under a line naming their length unit; the default route.",
            "a file name",
            "IMPORT_WAKE_EDGES_FROM_FILE",
        ),
        "type": InputKey(
            "The edge type every point of the file is given.",
            'text, default `"STANDARD"`',
            "IMPORT_WAKE_EDGES_FROM_FILE",
        ),
        "tolerance": InputKey(
            "The distance within which an edge's mid-point counts as a point of the file.",
            "m, > 0, default `0.0001`",
            "IMPORT_WAKE_EDGES_FROM_FILE",
        ),
        "detect": InputKey(
            "Marks the edges by the solver's detection instead of a file, over every surface or on the surfaces named.",
            '`"auto"`, or a table; see `detect = { ... }` below',
            "AUTO_DETECT_TRAILING_EDGES, DETECT_TRAILING_EDGES_BY_SURFACE",
        ),
    },
    WAKE_TERMINATION_TABLE: {
        "file": InputKey(
            "Explicit wake-termination node coordinates.",
            "a file name",
            "SELECT_MESH_NODE, MARK_WAKE_TERMINATION_NODES",
        ),
        "tolerance": InputKey(
            "Maximum distance to exactly one mesh vertex.",
            "m, > 0",
            "SELECT_MESH_NODE",
        ),
        "detect": InputKey(
            "Detects the wake-termination nodes over every surface, or on the surfaces named.",
            '`"auto"`, or `{ surfaces = ["<name>"] }`',
            "AUTO_DETECT_WAKE_TERMINATION_NODES, DETECT_WAKE_TERMINATION_NODES_BY_SURFACE",
        ),
    },
    BASE_REGIONS_TABLE: {
        "detect": InputKey(
            "Detects the base regions over the whole mesh; a named boundary is the row's BASE_REGIONS key's.",
            '`"auto"`',
            "AUTO_DETECT_BASE_REGIONS",
        )
    },
}

pyflightstream.workspace.sidecars.RAW_MESH_CONDITION_TABLES module-attribute

RAW_MESH_CONDITION_TABLES = (
    TRAILING_EDGES_TABLE,
    WAKE_TERMINATION_TABLE,
    BASE_REGIONS_TABLE,
)

pyflightstream.workspace.sidecars.SIDECAR_SUFFIXES module-attribute

SIDECAR_SUFFIXES = (
    INVENTORY_SUFFIX,
    PROVENANCE_SUFFIX,
    INSTRUCTION_SUFFIX,
    BUILD_RECORD_SUFFIX,
)

pyflightstream.workspace.sidecars.TRAILING_EDGES_TABLE module-attribute

TRAILING_EDGES_TABLE = 'trailing_edges'

pyflightstream.workspace.sidecars.TRAILING_EDGE_DETECT_KEYS module-attribute

TRAILING_EDGE_DETECT_KEYS: Mapping[str, InputKey] = {
    "surfaces": InputKey(
        "The surfaces to detect on, by the sidecar's names.",
        'a list of names, or `"all"` for every surface',
        "DETECT_TRAILING_EDGES_BY_SURFACE",
    ),
    "sweep_angle": InputKey(
        "The sweep angle set before the detection, only when stated.",
        "deg",
        "SET_TRAILING_EDGE_SWEEP_ANGLE",
    ),
    "bluntness_angle": InputKey(
        "The bluntness angle set before the detection, only when stated; refused on a build whose command database has no row for the command.",
        "deg",
        "SET_TRAILING_EDGE_BLUNTNESS_ANGLE",
    ),
}

pyflightstream.workspace.sidecars.WAKE_TERMINATION_TABLE module-attribute

WAKE_TERMINATION_TABLE = 'wake_termination'

pyflightstream.workspace.sidecars.boundaries_for_matrix

boundaries_for_matrix(geometry: str | Path) -> Path

Locate a saved simulation's inventory in the matrix's declared reading order.

Parameters:

Name Type Description Default
geometry str or Path

Saved simulation whose adjacent sidecars are searched.

required

Returns:

Type Description
Path

First existing sidecar, or the qualified FSM path when none exists.

pyflightstream.workspace.sidecars.ensure_inventory

ensure_inventory(
    geometry: str | Path,
    *,
    kind: Literal["obj", "fsm"] | None = None,
) -> Path

Return the boundary sidecar beside a geometry, writing an OBJ's from its groups (G30).

THE ONE PLACE A SIDECAR IS ASKED FOR. The matrix binding, which pyfs-matrix plan and pyfs-matrix run both pass through, and pyfs-mesh inventory (:func:write_inventory) reach the sidecar through this function, so an OBJ is treated alike wherever a user meets it:

  • an OBJ with no sidecar gets one, its boundaries read by :func:obj_boundary_names under a comment header naming the file's sha256 and RPT-078, and a line on stderr says so. It carries the list and nothing else: the [import] units and the trailing edges, which only the user can state, go beneath it.
  • an OBJ with a sidecar keeps it, never rewritten, because the file may carry tables and names the user wrote. When its boundaries differ from the groups, in names or in order, the run cites the sidecar's, as before, and a warning names both lists; when the groups cannot be read, the sidecar written by hand is that file's route and nothing is said.
  • any other geometry is left as it was: a saved simulation's sidecar is written by pyfs-mesh inventory from its mesh block, and an STL's by hand.

Parameters:

Name Type Description Default
geometry str or Path

The geometry the sidecar sits beside.

required
kind ('obj', 'fsm')

Filename kind for inventory writers; None preserves legacy run callers.

"obj"

Returns:

Type Description
Path

The sidecar beside geometry, which exists for every OBJ this returns for; for another geometry it exists only if written.

Raises:

Type Description
InputArtifactError

An OBJ with no sidecar whose groups cannot be read (:func:obj_boundary_names), naming the line and the sidecar to write by hand; an OBJ whose sidecar states no boundaries list, naming the list its groups make.

Warns:

Type Description
PyflightstreamWarning

An OBJ whose sidecar's boundaries differ from its groups, naming both lists.

pyflightstream.workspace.sidecars.inventory_sidecar

inventory_sidecar(
    geometry: str | Path,
    kind: Literal["obj", "fsm"] | None = None,
) -> Path

Return the sidecar path beside geometry, whether or not it exists.

Parameters:

Name Type Description Default
geometry str or Path

The geometry file.

required
kind ('obj', 'fsm')

Include the geometry kind for new inventories. With None, find an existing kind-qualified inventory, otherwise return the legacy name. The matrix's cross-kind fallback belongs to its own resolver.

"obj"

Returns:

Type Description
Path

The <stem>.boundaries.toml path beside it.

pyflightstream.workspace.sidecars.obj_boundary_names

obj_boundary_names(path: str | Path) -> tuple[str, ...]

Return measured OBJ boundary names in native order, preserving duplicates.

RPT-078 established face-bearing groups. GOAL-033 controls on 26.124, build 8172026 additionally measured an o-to-g transition, repeated g groups, a face prefix before the first g, and multiple names in a g statement. The latter uses only its first name, with a warning.

Repeated g groups remain separate boundaries; ambiguous labels must be selected by position downstream. Reverse g-to-o transitions, repeated o names, unnamed groups and multiword o names remain unmeasured here.

Parameters:

Name Type Description Default
path str or Path

The OBJ mesh file, read as UTF-8 text.

required

Returns:

Type Description
tuple of str

The group names in the order the file opens them, repeated names kept.

Raises:

Type Description
InputArtifactError

If the file cannot be read as text, holds no face under a measured group, or uses a variant that has not been measured (a group with no name or several words after o, a face before the first o, an o after g, or a name reopened where an o is involved). A face before the first g is measured and read as Boundary-1. The message points to writing the names by hand in the sidecar.

pyflightstream.workspace.sidecars.read_inventory

read_inventory(sidecar: str | Path) -> tuple[str, ...]

Return the ordered boundary names a sidecar states.

Parameters:

Name Type Description Default
sidecar str or Path

The <stem>.boundaries.toml file.

required

Returns:

Type Description
tuple of str

The boundary names in the order the sidecar lists them.

Raises:

Type Description
InputArtifactError

A sidecar without a boundaries list of strings, naming it.

pyflightstream.workspace.sidecars.read_marking_record

read_marking_record(
    geometry: str | Path,
) -> dict[str, Any] | None

Read a marking record and refuse changed or missing recorded inputs.

Parameters:

Name Type Description Default
geometry str or Path

Geometry beside the marking record.

required

Returns:

Type Description
dict or None

Validated record, or None when no record exists.

Raises:

Type Description
InputArtifactError

The record is unreadable or its input digests no longer match.

pyflightstream.workspace.sidecars.read_mesh_frame

read_mesh_frame(
    sidecar: str | Path,
) -> tuple[str, str, str] | None

Return the mesh_frame a geometry's sidecar declares, or None where it states none.

The key is a list of three words, what the mesh's +x, +y and +z point to, as mesh_frame = ["forward", "left", "up"]. pyflightstream expects ["aft", "right", "up"], and an absent key means exactly that, with no note.

Parameters:

Name Type Description Default
sidecar str or Path

The <stem>.boundaries.toml beside the geometry; a missing file states nothing.

required

Returns:

Type Description
tuple of str or None

The three words, lower case; None when the sidecar is absent or states no frame.

Raises:

Type Description
InputArtifactError

A declaration that is not three accepted words naming three axes, or that is left-handed, naming the sidecar and the declaration.

pyflightstream.workspace.sidecars.read_mesh_import

read_mesh_import(sidecar: str | Path) -> MeshImport | None

Return the [import] table a geometry's sidecar states, or None (G01, G03).

The table states the length unit a raw mesh is written in, and the mesh operations applied right after the import, in the order written::

boundaries = ["naca"]

[import]
units = "MILLIMETER"

[[import.operations]]
op = "rename"
surface = "naca"
to = "Wing"

Read at binding, beside :func:read_inventory, so a table that does not hold its shape is refused with the row before any seat is spent, an operation named by its position. Whether the unit is one IMPORT takes, whether the geometry is a raw mesh at all, and whether each cited surface exists at its step, is the builder's to judge, per build.

Parameters:

Name Type Description Default
sidecar str or Path

The <stem>.boundaries.toml beside the geometry.

required

Returns:

Type Description
MeshImport or None

None when the file holds no [import] table.

Raises:

Type Description
InputArtifactError

A file that does not read as TOML, an import key that is not a table, a table that states no units or a key it does not read, or an operation that does not hold its shape (its own keys, finite numbers, scale factors above zero, a named surface for a rename or a mirror), each naming the sidecar and the operation's position.

pyflightstream.workspace.sidecars.read_thin_boundaries

read_thin_boundaries(
    sidecar: str | Path,
) -> tuple[str, ...] | None

Return the boundaries a boundaries file marks thin (PFS-2256), refusing a bad value.

The reader is :func:pyflightstream.cases.mesh.thin_boundaries_of, which the build calls on the case's boundaries file; here its refusal is the workspace's.

Parameters:

Name Type Description Default
sidecar str or Path

The <stem>.boundaries.toml file; a missing file states nothing.

required

Returns:

Type Description
tuple of str or None

The names as written; () for an empty list, which clears a saved selection; None where the key is absent.

Raises:

Type Description
InputArtifactError

A file that does not read as TOML, or a value that is not a list of nonempty names.

pyflightstream.workspace.sidecars.refuse_a_frame_that_cannot_be_converted

refuse_a_frame_that_cannot_be_converted(
    geometry: str | Path,
) -> tuple[str, str, str] | None

Return the frame the geometry's sidecar declares, refusing the ones no conversion serves.

Parameters:

Name Type Description Default
geometry str or Path

The mesh the run opens.

required

Returns:

Type Description
tuple of str or None

The declared frame, or None where the sidecar states none.

Raises:

Type Description
InputArtifactError

A malformed or left-handed declaration, a saved simulation declared in a frame other than the expected one, or a mesh format other than OBJ declared in one.

pyflightstream.workspace.sidecars.stage_mesh_frame

stage_mesh_frame(
    sim_dir: str | Path, geometry: str | Path
) -> str | None

Convert the geometry to the expected frame inside the simulation folder, if declared.

Parameters:

Name Type Description Default
sim_dir str or Path

The simulation's folder.

required
geometry str or Path

The mesh as the library holds it.

required

Returns:

Type Description
str or None

The converted copy's path, absolute, when the mesh is declared in another frame; None otherwise, and the run opens the library's file as before.

Raises:

Type Description
InputArtifactError

As :func:refuse_a_frame_that_cannot_be_converted.