xref: /libCEED/rust/libceed/README.md (revision 6ecdb17925f89d32b3ac633c8523af3e7b374698)
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.8.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() {
32    let ceed = libceed::Ceed::init("/cpu/self/ref");
33    let xc = ceed.vector_from_slice(&[0., 0.5, 1.0]).unwrap();
34    let xs = xc.view();
35    assert_eq!(xs[..], [0., 0.5, 1.0]);
36}
37```
38
39This crate provides modules for each object, but they are usually created from
40the `Ceed` object as with the vector above. The resource string passed to
41`Ceed::init` is used to identify the "backend", which includes algorithmic
42strategies and hardware such as NVIDIA and AMD GPUs. See the [libCEED
43documentation](https://libceed.readthedocs.io/en/latest/gettingstarted/#backends)
44for more information on available backends.
45
46## Examples
47
48Examples of libCEED can be found in the [libCEED repository](https://github.com/CEED/libCEED) under the
49`examples/rust` directory.
50
51## License: BSD-2-Clause
52
53## Contributing
54
55The `libceed` crate is developed within the [libCEED
56repository](https://github.com/CEED/libCEED). See the [contributing
57guidelines](https://libceed.readthedocs.io/en/latest/CONTRIBUTING/) for details.
58