Skip to main content

Crate pyrucast

Crate pyrucast 

Source
Expand description

pyrucast — finite-element library: Rust core, Python API.

Inspired by cast3m principles. The API conventions live in CONVENTIONS.md (repository root) and in the mdbook.

§Conventions

  • Every error goes through PyrucastError / Result.
  • Every serializable object uses the archive::portable::Portable trait (the byte contract of file save/load, identical on Linux and Windows).
  • Display comes in three layered levels, all wired to Python: Display/__str__ (one-line summary), Debug/__repr__ (bounded structure — never bulk content), and dump::Dump/dump(…) (full content: matrix grids, value tables, connectivity). See dump.

§Example

use pyrucast::archive::Portable;

#[derive(serde::Serialize, serde::Deserialize, PartialEq, Debug)]
struct Demo {
    values: Vec<f64>,
}

let a = Demo { values: vec![1.0, 2.0, 3.0] };
let bytes = a.to_bytes().unwrap();
let b = Demo::from_bytes(&bytes).unwrap();
assert_eq!(a, b);

Re-exports§

pub use error::PyrucastError;
pub use error::Result;

Modules§

aggregate
Common trait for the “parent” containers (Mesh, FiniteElementSpace, Model). Each is essentially a Vec<Handle<Sub>> and exposes the same access grammar (len, get, indexing, iteration).
archive
Saving and reloading a graph of objects.
atoms
Atoms — the indivisible types of pyrucast.
containers
Containers — the divisible objects of pyrucast.
coords
Coords — node coordinates with a stable identity.
dump
Third display level: content.
error
Unique error type of pyrucast.
handle
Object handles — pyrucast’s “object pile”, cast3m-style.
interrupt
Cooperative cancellation for long-running operators.
models
Per-physics implementations of crate::containers::model::SubModel variants.
named
Types whose values have a name — the textual form a user writes.
ops
Operators — the functions that consume containers and produce containers (or derived data).
parallel
Shared-memory parallelism helpers (rayon).

Macros§

impl_aggregate
Derive a complete Aggregate implementation for a struct whose only collection field is named subs: Vec<Handle<Sub>>.
impl_aggregate_dump
Derive crate::dump::Dump for an Aggregate whose Sub is itself Dump: the one-line Display summary, then each sub-object’s full dump indented under a ── [i] ── marker.
impl_aggregate_std_traits
Generate Index, IntoIterator, fmt::Debug, fmt::Display, and the T::union_subs(a, b) constructor (sub | sub, returning Result<T>) for a concrete type that implements Aggregate.
impl_field_ops
Generate Add/Sub/Mul/Div for an aggregate Field, both field ∘ field (via Field::merge_field, per (support, component) with passthrough) and field ∘ scalar (via Field::combine_scalar, broadcast over every value), the scalar standing on either side (&a - 1.0, 1.0 - &a). Rebuilding the aggregate can fail, so the output is a Result: (&a + &b)?, (&a * 2.0)?.
impl_subfield_field_ops
Generate Add/Sub/Mul/Div between two SubField containers of the same type, delegating to SubField::merge_components (per-component union with passthrough on a shared support). Combining can fail (different support), so — like the crate’s other fallible operators (e.g. &Matrix * &NodeField) — the output is a Result: (&a + &b)?. Division does not guard against zero (numpy-like inf/nan).
impl_subfield_scalar_ops
Generate Add/Sub/Mul/Div<f64> for a SubField container: the consuming versions mutate every value in place and return self (zero-copy); the reference versions clone first. The scalar may stand on the left too: 2.0 * field, 1.0 - field, 1.0 / field apply s ∘ value to every value.
named_enum
Implement the Python conversion of a Named type: a Python str in, the value out — or a ValueError naming what was not understood.
physics_operator
Declare a physics’ parent-level operator and its Python twin, from a single place in the physics’ own file.

Constants§

FEATURES
Features actually compiled into this binary, in a stable order.
VERSION
Library version (taken from Cargo.toml).