xref: /libCEED/rust/libceed/README.md (revision b7c9bbdafc9b91976b65f80ebb2c5357c2efd8bc)
1# libceed: efficient, extensible discretization
2
3This crate provides an interface to [libCEED](https://libceed.readthedocs.io),
4which is a performance-portable library for extensible element-based
5discretization for partial differential equations and related computational
6problems. The formulation is algebraic and intended to be lightweight and easy
7to incorporate in higher level abstractions. See the [libCEED user
8manual](https://libceed.readthedocs.io) for details on [interface
9concepts](https://libceed.readthedocs.io/en/latest/libCEEDapi/) and extensive
10examples.
11
12![libCEED operator decomposition](https://libceed.readthedocs.io/en/latest/_images/libCEED.png)
13
14## Usage
15
16To call libCEED from a Rust package, the following `Cargo.toml` can be used.
17```toml
18[dependencies]
19libceed = "0.9.0"
20```
21
22For a development version of the libCEED Rust bindings, use the following `Cargo.toml`.
23```toml
24[dependencies]
25libceed = { git = "https://github.com/CEED/libCEED", branch = "main" }
26```
27
28```rust
29extern crate libceed;
30
31fn main() -> Result<(), libceed::CeedError> {
32    let ceed = libceed::Ceed::init("/cpu/self/ref");
33    let xc = ceed.vector_from_slice(&[0., 0.5, 1.0])?;
34    let xs = xc.view();
35    assert_eq!(xs[..], [0., 0.5, 1.0]);
36    Ok(())
37}
38```
39
40This crate provides modules for each object, but they are usually created from
41the `Ceed` object as with the vector above. The resource string passed to
42`Ceed::init` is used to identify the "backend", which includes algorithmic
43strategies and hardware such as NVIDIA and AMD GPUs. See the [libCEED
44documentation](https://libceed.readthedocs.io/en/latest/gettingstarted/#backends)
45for more information on available backends.
46
47## Examples
48
49Examples of libCEED can be found in the [libCEED repository](https://github.com/CEED/libCEED) under the
50`examples/rust` directory.
51
52## License: BSD-2-Clause
53
54## Contributing
55
56The `libceed` crate is developed within the [libCEED
57repository](https://github.com/CEED/libCEED). See the [contributing
58guidelines](https://libceed.readthedocs.io/en/latest/CONTRIBUTING/) for details.
59