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::Portabletrait (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), anddump::Dump/dump(…)(full content: matrix grids, value tables, connectivity). Seedump.
§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::SubModelvariants. - 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
Aggregateimplementation for a struct whose only collection field is namedsubs: Vec<Handle<Sub>>. - impl_
aggregate_ dump - Derive
crate::dump::Dumpfor anAggregatewhoseSubis itselfDump: the one-lineDisplaysummary, then each sub-object’s fulldumpindented under a── [i] ──marker. - impl_
aggregate_ std_ traits - Generate
Index,IntoIterator,fmt::Debug,fmt::Display, and theT::union_subs(a, b)constructor (sub | sub, returningResult<T>) for a concrete type that implementsAggregate. - impl_
field_ ops - Generate
Add/Sub/Mul/Divfor an aggregateField, both field ∘ field (viaField::merge_field, per(support, component)with passthrough) and field ∘ scalar (viaField::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 aResult:(&a + &b)?,(&a * 2.0)?. - impl_
subfield_ field_ ops - Generate
Add/Sub/Mul/Divbetween twoSubFieldcontainers of the same type, delegating toSubField::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 aResult:(&a + &b)?. Division does not guard against zero (numpy-likeinf/nan). - impl_
subfield_ scalar_ ops - Generate
Add/Sub/Mul/Div<f64>for aSubFieldcontainer: the consuming versions mutate every value in place and returnself(zero-copy); the reference versions clone first. The scalar may stand on the left too:2.0 * field,1.0 - field,1.0 / fieldapplys ∘ valueto every value. - named_
enum - Implement the Python conversion of a
Namedtype: a Pythonstrin, the value out — or aValueErrornaming 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.