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