rustfront calls MFront behaviours from Rust, in pure Rust: it opens a library
generated with MFront's generic interface, reads the description the behaviour
exports, and integrates it at one material point. mtest-rs is an unofficial,
independent reimplementation of a subset of MTest built on it.
Two crates side by side; the root holds only the workspace (Cargo.toml: the
shared version, dependencies and lints), the shared configuration
(clippy.toml, rustfmt.toml) and the tooling of the repository.
rustfront/: the library.src/ffi.rs: the C structures of thegenericinterface (TFEL 5.1 headersMFront/GenericBehaviour/State.handBehaviourData.h).src/behaviour.rs:Behaviour::loadreads and checks the exported symbols (<behaviour>_<hypothesis>_<name>, else<behaviour>_<name>);Behaviour::integratechecks every array length, then calls the behaviour.src/material_property.rs:MaterialProperty::loadandevaluate, for the material properties (@DSL MaterialLaw), whose C interface differs.src/symbols.rs: the privateSymbolshelper shared by both loaders: the only place that looks symbols up, with typed reads, eachunsafeblock justified once.src/rotation.rs:Rotation,FrameandRotated, for the rotations of orthotropic behaviours, whichBehaviour::rotatecalls (_rotateArrayOf…, in place).src/voigt.rs: conversions between TFEL's storage of symmetric tensors (xx, yy, zz, √2·xy, √2·xz, √2·yz) and Voigt notation.examples/minimal.rs: the minimal example, whichrustfront/README.mdshows verbatim, with its output, and explains: change them together.tests/behaviours/*.mfront: test behaviours written for this repository, also compiled byscripts/try.shfor the cases ofmtest-rs/cases. Do not copy TFEL's own test behaviours: their licence is not ours.README.md: the page of the crate on crates.io, for its users.
mtest-rs/: the command line tool; it follows MTest's default algorithm exactly (Lagrange multipliers, convergence criteria, sub-steps), but for MTest's mistakes, which it does not copy: two in finite strain and two in the Anderson acceleration algorithms, fixed in TFEL's master branch, and the tangent operator MTest solves with when it compares it to the numerical one (seescripts/try.sh).finite_strain.rsconverts the stress measures and tangent operators to MTest's Cauchy stress and dσ/dF;acceleration.rsholds MTest's thirteen acceleration algorithms, written operation by operation as its own. A material property of the file is loaded as it is read and is an evolution, as in MTest.README.md: the page of the repository: the two crates, the comparison with MTest, the release.scripts/:check.sh(the checks of the CI),try.sh(mtest-rs against MTest, on the cases ofmtest-rs/casesand the reference files*.reftheir@Test<file>read),compare.py,install-tfel.sh,tfel-suite.py(mtest-rs against MTest on TFEL's MTest tests, those of the other interfaces ported to the generic one, read from a checkout of the TFEL sources: nothing of TFEL is copied here).
The licence files of each crate are links to those of the root.
Both crates share one version, declared in the root Cargo.toml
([workspace.package] and the rustfront entry of [workspace.dependencies]).
- Code, comments, documentation and commit messages in English.
- No
Resultthat cannot fail, noOptionwhoseNoneonly stands for a default value (clippy::unnecessary_wrapsis on, extended to the public API). - Simple, flat code: no function of one or two lines, no function called only once or twice; a local closure is fine when it is reused many times.
- One dependency,
libloading.mtest-rsdepends on nothing butrustfront: its parser, expression evaluator and linear solver are written by hand. - Only
Behaviour::loadisunsafe; everyunsafeblock has aSAFETY:comment. - The interface is generic: nothing in the code, comments or commits is specific to one solver (the README may cite users).
- Discuss a new public API before implementing it.
The tests compile the test behaviours with mfront and fail without it; the
comparison needs mtest. Both come with TFEL 5.1.0 or later:
export PATH="$HOME/.local/tfel-5.1.0/bin:$PATH"
export LD_LIBRARY_PATH="$HOME/.local/tfel-5.1.0/lib"
./scripts/check.sh # everything the CI checks
./scripts/check.sh test # or one check: fmt clippy test doc compare package msrv
./scripts/install-tfel.sh 5.2.0 ~/.local/tfel-5.2.0 # another TFEL versionmsrv needs the toolchain of rust-version (rustup toolchain install 1.88).
The CI runs the same script, for TFEL 5.1.0 and the latest stable TFEL.
A new check counts only once it has been seen failing: break it on purpose once, and check the exit code.
See "Releasing" in README.md: change the two version lines of Cargo.toml,
commit, push a tag vX.Y.Z; .github/workflows/release.yml publishes both
crates through crates.io's Trusted Publishing.
Cargo.toml carries the version of the next release: right after a release,
move to the next version. Otherwise check.sh package verifies mtest-rs
against the rustfront already published under that number, not against the
code of the repository.