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