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