xref: /libCEED/rust/libceed/README.md (revision 60ef3feef7f5137af55ea7336903743d94ee71a8)
1a1cbad85SJed Brown# libceed: efficient, extensible discretization
2a1cbad85SJed Brown
37ed177dbSJed Brown[![GitHub Actions](https://github.com/CEED/libCEED/actions/workflows/rust-test-with-style.yml/badge.svg)](https://github.com/CEED/libCEED/actions/workflows/rust-test-with-style.yml)
47ed177dbSJed Brown[![Documentation](https://docs.rs/libceed/badge.svg)](https://docs.rs/libceed)
57ed177dbSJed Brown
613964f07SJed BrownThis crate provides an interface to [libCEED](https://libceed.org), which is a performance-portable library for extensible element-based discretization for partial differential equations and related computational problems.
77ed177dbSJed BrownThe formulation is algebraic and intended to be lightweight and easy to incorporate in higher level abstractions.
813964f07SJed BrownSee the [libCEED user manual](https://libceed.org) for details on [interface concepts](https://libceed.org/en/latest/libCEEDapi/) and extensive examples.
9a1cbad85SJed Brown
1013964f07SJed Brown![libCEED operator decomposition](https://libceed.org/en/latest/_images/libCEED.png)
11a1cbad85SJed Brown
12a1cbad85SJed Brown## Usage
13a1cbad85SJed Brown
14a1cbad85SJed BrownTo call libCEED from a Rust package, the following `Cargo.toml` can be used.
15a1cbad85SJed Brown```toml
16a1cbad85SJed Brown[dependencies]
17*4018a20aSJeremy L Thompsonlibceed = "0.12.0"
18a1cbad85SJed Brown```
19a1cbad85SJed Brown
20a1cbad85SJed BrownFor a development version of the libCEED Rust bindings, use the following `Cargo.toml`.
21a1cbad85SJed Brown```toml
22a1cbad85SJed Brown[dependencies]
23a1cbad85SJed Brownlibceed = { git = "https://github.com/CEED/libCEED", branch = "main" }
24a1cbad85SJed Brown```
25a1cbad85SJed Brown
26a1cbad85SJed Brown```rust
27a1cbad85SJed Brownextern crate libceed;
28a1cbad85SJed Brown
2989d15d5fSJeremy L Thompsonfn main() -> libceed::Result<()> {
30a1cbad85SJed Brown    let ceed = libceed::Ceed::init("/cpu/self/ref");
31c68be7a2SJeremy L Thompson    let xc = ceed.vector_from_slice(&[0., 0.5, 1.0])?;
32e78171edSJeremy L Thompson    let xs = xc.view()?;
33a1cbad85SJed Brown    assert_eq!(xs[..], [0., 0.5, 1.0]);
34c68be7a2SJeremy L Thompson    Ok(())
35a1cbad85SJed Brown}
36a1cbad85SJed Brown```
37a1cbad85SJed Brown
387ed177dbSJed BrownThis crate provides modules for each object, but they are usually created from the `Ceed` object as with the vector above.
397ed177dbSJed BrownThe resource string passed to `Ceed::init` is used to identify the "backend", which includes algorithmic strategies and hardware such as NVIDIA and AMD GPUs.
4013964f07SJed BrownSee the [libCEED documentation](https://libceed.org/en/latest/gettingstarted/#backends) for more information on available backends.
41a1cbad85SJed Brown
42a1cbad85SJed Brown## Examples
43a1cbad85SJed Brown
447ed177dbSJed BrownExamples of libCEED can be found in the [libCEED repository](https://github.com/CEED/libCEED) under the `examples/rust` directory.
457ed177dbSJed Brown
467ed177dbSJed Brown## Documentation
477ed177dbSJed Brown
487ed177dbSJed BrownThis crate uses `katexit` to render equations in the documentation.
497ed177dbSJed BrownTo build the [documentation](https://docs.rs/libceed) locally with `katexit` enabled, use
507ed177dbSJed Brown
517ed177dbSJed Brown```bash
527ed177dbSJed Browncargo doc --features=katexit
537ed177dbSJed Brown```
54a1cbad85SJed Brown
55a1cbad85SJed Brown## License: BSD-2-Clause
56a1cbad85SJed Brown
57a1cbad85SJed Brown## Contributing
58a1cbad85SJed Brown
597ed177dbSJed BrownThe `libceed` crate is developed within the [libCEED repository](https://github.com/CEED/libCEED).
6013964f07SJed BrownSee the [contributing guidelines](https://libceed.org/en/latest/CONTRIBUTING/) for details.
61