rustfront
Evaluate MFront material behaviours (constitutive laws) at a material point, in pure Rust.
MFront compiles material behaviours (elasticity, plasticity, creep, …) into
shared libraries. rustfront loads the libraries generated with MFront's
generic interface and integrates a behaviour at one material point, from
Rust code such as the pyrucast finite-element library.
It talks to the generated library directly: no MGIS, no C or C++ build dependency, nothing to compile but Rust.
Status: early development. Small strain, finite strain and general behaviours, isotropic or orthotropic, point-wise models (
@DSL DefaultModel, …) and material properties (@DSL MaterialLaw), for every modelling hypothesis, generated by TFEL 5.1.0 or later. Finite strain behaviours compute the Cauchy stress or either Piola-Kirchhoff stress, with any of their tangent operators; orthotropic behaviours come with the rotations between the global frame and their material frame.
The arrays of a material point (gradients, thermodynamic forces, material
properties, internal and external state variables) are borrowed from the
caller, who can keep the values of all its points in contiguous storage.
Only loading a library is unsafe; integrating is safe.
Requirements
- Behaviours compiled by MFront (TFEL 5.1.0 or later) with the
genericinterface:mfront --obuild --interface=generic Norton.mfront. - Rust 1.88 or later.
- To run the tests,
mfrontin thePATH: the tests compile the behaviours oftests/behavioursand fail without it../scripts/check.shruns every check of the CI, and./scripts/install-tfel.sh <version> <prefix>builds and installs a TFEL version.
Try it
With mfront, mtest and tfel-config (TFEL 5.1.0 or later), cargo and
python3 in the PATH:
The script compiles the test behaviours of tests/behaviours, runs the
minimal example, then runs every case of mtest-rs/cases with MTest and with
mtest-rs, compares the two result files column by column with
scripts/compare.py, and checks that both make the same number of Newton
iterations at every step. Everything it writes goes to target/try.
The MTest of TFEL 5.1 and before assembles the residual of a finite strain behaviour with a mistake in the rows of the shear, fixed in TFEL's master branch, which mtest-rs follows: with such an MTest, the finite strain cases agree in results, not in iterations, and the case with free shear components is compared with MTest's results on the same test with the shear imposed.
Minimal example
examples/minimal.rs loads a behaviour, prints its
description, integrates it once at one material point and prints the stress
and the tangent operator:
mtest-rs
mtest-rs, in this repository, tests a behaviour at one material
point over a loading history: an unofficial, independent reimplementation of
a subset of MTest built on rustfront, reading the same .mtest files and
writing the same .res files.
Relation to MGIS
MGIS is the official library for calling MFront behaviours from a solver,
with C, Fortran, Python and Julia bindings; Rust bindings are on its roadmap
(thelfer/MFrontGenericInterfaceSupport#376).
rustfront takes another route: it reads the description each behaviour
exports and calls the behaviour itself, without going through MGIS.
Releasing
rustfront and mtest-rs share one version, declared twice in the root
Cargo.toml: in [workspace.package], and in the rustfront entry of
[workspace.dependencies]. To release:
# set the new version on both lines of Cargo.toml, then
The tag starts .github/workflows/release.yml: it checks that the tag matches
Cargo.toml, runs the CI, publishes rustfront then mtest-rs on crates.io
through Trusted Publishing (no token stored in GitHub), and creates the GitHub
release. Each crate must have this workflow as its trusted publisher on
crates.io: owner Pyrucast, repository rustfront, workflow release.yml,
no environment.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.